I seem to ask for help a lot it seems lol.
So after completing my Zelda game and posting it here, it has left me with some free time. Enough time to catch up with things I have been putting off around the house. Lately I have been playing with some ideas and concepts, One of which requires an oscilloscope of audio in real time. I have been playing with the _memsound example and another example I have found on here. However I cant seem to get it quite right. What I see graphically is either behind (i=i+2) or ahead (i=i+3) of the audio. I have tried doing a bytes per second on the fly adjustment, a frames per second adjustment, and a "how much time has advanced on the audio since the last display refresh adjustment." Nothing seems to work quite right.
song&
= _SndOpen("Sounds\singing stars.mp3") 'replace drums.ogg with a sound file you have
leftchannel = _MemSound(song&, 1)
i = 0
PositionDifference = 2
_MemGet leftchannel
, leftchannel.OFFSET
+ i
, l%
'get sound data
Locate 1, 1:
Print leftchannel.OFFSET;
"/"; leftchannel.SIZE
, dframes
, leftchannel.ELEMENTSIZE
Line (x
, prevposl
)-(x
+ 1, nextposl
+ 2), _RGB32(254, 0, 0), BF
prevposl = nextposl
x = x + 1
x = 0
dframes = frames
frames = 0
i = i + 2
frames = frames + 1
_SndClose song&
'closing the sound releases the mem blocks
Function map!
(value!
, minRange!
, maxRange!
, newMinRange!
, newMaxRange!
) map! = ((value! - minRange!) / (maxRange! - minRange!)) * (newMaxRange! - newMinRange!) + newMinRange!