Find out memoery consumed by sound sample?
BlitzMax Forums/BlitzMax Programming/Find out memoery consumed by sound sample?
| ||
Hi, is there a way to get the length in bytes of a sound sample in memory? For example, I may have loaded it as an ogg or wav, and I'd like to know how much RAM it consumes. Thanks! |
| ||
This does it. |
| ||
Thanks tonyG, looks like I need this bit:'determine mono/stero If sndSample.format = SF_MONO8 Or sndSample.format = SF_MONO16LE Or sndSample.format = SF_MONO16BE Then channels = 1 Else channels = 2 End If 'determine bitrate & calculate size If sndSample.format = SF_MONO8 Or sndSample.format = SF_STEREO8 Then bitRate = 8 sampleSize = sndSample.length * channels Else bitRate = 16 sampleSize = sndSample.length * channels * 2 End If I wonder if there are any other formats missing that I should include? |
| ||
From the readily available documentation : Function CreateAudioSample:TAudioSample( length,hertz,format ) Returns An audio sample object. Description Create an audio sample. Information length is the number of samples to allocate for the sample. hertz is the frequency in samples per second (hz) the audio sample will be played. format should be one of: Format Description SF_MONO8 Mono unsigned 8 bit SF_MONO16LE Mono signed 16 bit little endian SF_MONO16BE Mono signed 16 bit big endian SF_STEREO8 Stereo unsigned 8 bit SF_STEREO16LE Stereo signed 16 bit little endian SF_STEREO16BE Stereo signed 16 bit big endian <edit> Although checking the code they get converted down. |
| ||
If it wasn't for me you'd have nothing to post ;-) Thx! |