After having turned my .ogg files into a memblock, the question still remains as to how I find the actual sound data within each byte as I attempt an Audio Level Meter.
There is a Wiki on the ogg pages here :-
http://en.wikipedia.org/wiki/Ogg_page
And tech specs here:-
http://tools.ietf.org/html/rfc3533#page-3
This program using EAP by Torrey Betts seems to work, but seems is a big word and I am having difficulty as the chosen file is a .ogg...:-
Rem Project: Audio Meter
Rem Created: 04/07/2009 21:06:12
Rem ***** Main Source File *****
`I used a 640x480 window
`Load your audio file
load audio 1,"hit.wav"
`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
loop audio 1
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 640 STEP 10
ink rgb(0,rnd(255),rnd(100)), 0
` line i,640, 1024,640
line linex,220- ((memblock byte(1,i))/2), 640, 220-((memblock byte(1,i))/2)
ink rgb(rnd(255),0,rnd(100)), 0
line linex, ((memblock byte(1,i+1))/2)+220, 640, ((memblock byte(1,i+1))/2)+220
next i
linex = i
`Place a small wait here to kill a little time for the song to update its own buffer
wait 1
`endif
loop
The command `audio get output buffer(audio number, Pointer, buffer size)` is undocumented, so was just wondering if anyone has solved this connundrum as to how to make an audio meter...
You`ll need a small wav file for that too...see enclosed
Any help decoding/extracting from .ogg much appreciated