yay! this is awesome
haven't tested it yet but does it loads midi files and perform operation based on the content?
for example I would need to take every midi notes in the midi file, analyze each note (0 -127) one by one.
Previously setting the PPQ to something like 960,
The goal is to write a square wave on the volume for every note, the square wave correspond to the note frequency + (some slight detuning)...
For every new note encountered I calculate the frequency in Hz to find the period and deduct the closer PPQ wait time
then for every note, while note on, I will add CC#7 (volume) 127, PPQ/2 wait time corresponding the period, 0 and so on until note off.
For a 440Hz note, this should adds 880 CC informations per second ( 440 times value =127 and 440 times value =0).
Knowing that MIDI baud rate is 31250 and a MIDI CC is 3 bytes long + start and stop bit for every bytes,
this gives us 26 bits serially sent for every CCs and a max possibility of 1200 CCs per seconds (31250/26)
then to write a square waves on the volume CC a max frequency of 600 Hz (as their is 2 states per period and 2 MIDI CC messages are needed).
I think that baud rate limitation do not apply if you use MIDI internally in a DAW...
At 120 BPM a quarter note is equal to 2Hz, if PPQ is 960 this gives us 960 Hz max resolution for writing a square wave on the volume CC ((2Hz * 960)/2 states of the square wave).
If you slightly vary the CC modulation frequency from the actual note this will give you a kind of pulse width modulation especially if the sound source is a square wave too.
This is a technique I have used to make timer modulation on the Sega PSG square wave and the technique used for a long time on Atari ST (known as "SID" sound) because these chips had no pulse width control built in...
I have implemented this technique in my SPSG VST too.
Your program might do the job to convert any midi file or if it can't, as is, at least I can make a list of midi file per note that I can later import
looking forward to your answer.
Here are possible frequencies for BPM 120 and PPQ 1920.
BPM= 120
PPQ = 1920
(Square waves takes 2 PPQ waits per cycle)
---------------------------------------------------------------------
wait value (PPQ) >> frequency of modulation (Hz)
wait 1 PPQ = 960
wait 2 PPQ = 480
wait 3 PPQ = 320
wait 4 PPQ = 240
wait 5 PPQ = 192
wait 6 PPQ = 160
wait 7 PPQ = 137
wait 8 PPQ = 120
wait 9 PPQ = 107
wait 10 PPQ = 96
wait 11 PPQ = 87.3
wait 12 PPQ = 80
wait 13 PPQ = 73.8
wait 14 PPQ = 68.6
wait 15 PPQ = 64
wait 16 PPQ = 60
wait 17 PPQ = 56.5
wait 18 PPQ = 53.3
wait 19 PPQ = 50.5
wait 20 PPQ = 48
wait 21 PPQ = 45.7
wait 22 PPQ = 43.6
wait 23 PPQ = 41.7
wait 24 PPQ = 40
wait 25 PPQ = 38.4
wait 26 PPQ = 36.9
wait 27 PPQ = 35.6
wait 28 PPQ = 34.3
wait 29 PPQ = 33.1
wait 30 PPQ = 32
wait 31 PPQ = 31
wait 32 PPQ = 30
and so on...
Last edited by Aly James (Jan 18, 2014 12:40 pm)