Updates made so far today on August 3rd
I added these new MIDI commands:
AUDIO MIDI POSITION midi audio index number (returns current position in seconds)
AUDIO MIDI LENGTH midi audio index number (returns total seconds in the streaming midi)
AUDIO SET MIDI POSITION midi audio index number, integer position in seconds
AUDIO MIDI PLAYING midi audio index number (returns true or false)
And if you're in the mood for experimentation when it comes to playing with the output buffer for graphical effects you can use this command:
AUDIO GET OUTPUT BUFFER audio index number, memblock memory pointer, buffer size (returns integer of the number of frames read into the buffer)
To experiment you'll need to know these few things:
1) The size of a frame is typically 4 bytes for stereo audio. I will add a command in the future to get the size of the frame for the audio.
2) The easiest thing to use for your buffer is a memblock. I'll paste some simple example source below.
3) The size of your memblock buffer should be 4096. In all my tests thus far this seems to be the safest size to use.
4) Keep your buffer reading of the bytes at a low amount. It seems if you read too many bytes you get ahead of the audio, and it'll freeze up the program. After calling the command to copy the output buffer, place a very small wait command afterwards.
`I used a 640x480 window
`Load your audio file
load audio 1, "youraudiohere.mp3"
`Create the memblock buffer with a size of 4096
make memblock 1, 4096
`Get the memory pointer to the memblock
BuffPtr = get memblock ptr(1)
`Start playing the audio
play audio 1
`The wait was placed here to help with graphical output timing
wait 400
do
cls
`Copy the output buffer to our memblock
result = audio get output buffer(1, BuffPtr, 4096)
linex = 0
liney = 0
`I processed 2 bytes each loop so 320*2 = 640 (width of the window)
if result > 320 then result = 320
if result > 0 and audio playing(1)
ink rgb(255,255,255), 0
print "Processing Frame Count: " + str$(result)
`Frame size is typically 4 bytes for most audio
`I processed each group of 2 bytes as being the left and right channel of audio
`This could be incorrect interpretation of those bytes, but I haven't found any
` reference for it yet.
for i = 0 to (((result-1)*4)/2) step 2
ink rgb(0,rnd(255),rnd(100)), 0
line linex, ((memblock byte(1,i+1))/2)+75, i, ((memblock byte(1,i+3))/2)+75
ink rgb(rnd(255),0,rnd(100)), 0
line linex, ((memblock byte(1,i))/2)+300, i, ((memblock byte(1,i+2))/2)+300
linex = i
`Place a small wait here to kill a little time for the song to update its own buffer
wait 5
next i
endif
loop
Remember you can interpret those copied bytes any way you wish. It'll be awesome to see if any of you create something cool from it.
Also, be sure to read through that list of commands in the first post, some of the original ones might have new information or return value data types.