-
How does one retrieve the raw amplitude data from a file? I went through the documentation and got the simple_playback.c and simple_capture.c working, but I can't seem to figure out how to copy over the raw data to the main program and use it. I tried to cast the device pUserData to a float* but I am a bit lost. I ultimately want to play sound while keeping track of amplitude in real time. In the AudioFile library we can do something like, |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 6 replies
-
In the simple_playback example you'll see how there's a call to ma_decoder_config decoderConfig = ma_decoder_config_init(ma_format_f32, channels, sampleRate); |
Beta Was this translation helpful? Give feedback.
In the simple_playback example you'll see how there's a call to
ma_decoder_read_pcm_frames()
. You would use that. In the example it's outputting straight to the callback's output buffer, but instead you would just output it to your own buffer and do whatever it is you need to do. Just make sure that you copy the data over to the callback's output buffer eventually or else you won't hear anything. If you need your samples in floating point format, make sure you configure the decoder to output samples asma_format_f32
: