开发者

extAudioFile data... am I getting the right stuff?

开发者 https://www.devze.com 2023-01-15 12:00 出处:网络
I am using the EXTAudioFileReadTest app provided in the Core Audio SDK documentation and I\'m trying to get all of the floating point values from the mData buffer so that I can draw a waveform with th

I am using the EXTAudioFileReadTest app provided in the Core Audio SDK documentation and I'm trying to get all of the floating point values from the mData buffer so that I can draw a waveform with them.

Currently, I'm printing out the floating point values for single channel and this is what I'm getting in the console:

2010-09-10 19:22:43.360 ExtAudioFileReadTest[71828:a0f] 0.127136

2010-09-10 19:22:43.360 ExtAudioFileReadTest[71828:a0f] -0.057033

2010-09-10 19:22:43.360 ExtAudioFileReadTest[71828:a0f] -0.146455

2010-09-10 19:22:43.360 ExtAudioFileReadTest[71828:a0f] 0.090759

2010-09-10 19:22:43.360 ExtAudioFileReadTest[71828:a0f] 0.240837

2010-09-10 19:22:43.360 ExtAudioFileReadTest[71828:a0f] -0.072719

2010-09-10 19:22:43.361 ExtAudioFileReadTest[71828:a0f] -0.258782

2010-09-10 19:22:43.361 ExtAudioFileReadTest[71828:a0f] -0.063972

2010-09-10 19:22:43.361 ExtAudioFileReadTest[71828:a0f] 0.088692

2010-09-10 19:22:43.361 ExtAudioFileReadTest[71828:a0f] 0.153571

2010-09-10 19:22:43.361 ExtAudioFileReadTest[71828:a0f] 0.080644

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] -0.087060

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] 0.196455

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] 0.167777

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] -0.192430

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] -0.209936

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] 0.012049

2010-09-10 19:22:43.383 ExtAudioFileReadTest[71828:a0f] 0.110493

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] 0.150715

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] 0.016413

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] -0.056843

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] 0.206117

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] 0.020673

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] -0.561129

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] -0.184265

2010-09-10 19:22:43.384 ExtAudioFileReadTest[71828:a0f] 0.620910

2010-09-10 19:22:43.385 ExtAudioFileReadTest[开发者_如何学Python71828:a0f] 0.309018

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] -0.371634

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] -0.238362

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] 0.125136

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] 0.139757

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] -0.023419

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] -0.142903

2010-09-10 19:22:43.385 ExtAudioFileReadTest[71828:a0f] 0.041068

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] 0.252621

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] -0.002240

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] -0.261686

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] -0.105053

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] 0.072798

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] 0.141572

2010-09-10 19:22:43.386 ExtAudioFileReadTest[71828:a0f] 0.110190

I guess i'm confused.. .as I was expecting to find some type of voltage sample and not a number between -1 and 1. What do these values actually mean? What would be a good formula for converting these values to some upper/lower limit that would be between 0 and 1?

Thanks in advance. I've been searching all over the place and can't find this information anywhere... especially not in the documentation.


this is normal.

the common floating point representation of audio samples modulate from [-1...1]; where the values -1 and 1 represent one sample at 0 dBFS.

a continuous stream of floating point values '0.0' represents a silent signal.

a signal with no DC offset will have equal weight in the positive and negative domains.

if you'd like to convert these values to [0...1], use the formula:

result = (0.5 * inputSample) + 0.5;

but you may have to use a more sophisticated algorithm if the signal extends beyond [-1...1].

in most cases, you should keep it at [-1...1] if you want to store it in floating point.


I think i've figured this out. I just graphed those points above in excel and it seems to look like a waveform. I didn't realize it was giving the negative voltages as well... but it makes sense.

0

精彩评论

暂无评论...
验证码 换一张
取 消