Hi All,

I'm trying to determine the exact number of samples/frames of a sound file.
For this I am using the following formula

numFrames = numPackets * asbd.mFramesPerPacket


However, this always gives a number that is ever so slightly too large. In
fact after a little experimentation

numFrames = numPackets * asbd.mFramesPerPacket * (44100 / 48000)


The output of running afinfo on the audio file shows that has a sample rate
of 48kHz

File:           a01.caf
File type ID:   caff
Num Tracks:     1
----
Data format:     2 ch,  48000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0
bytes/packet, 1024 frames/packet, 0 bytes/frame
                no channel layout.
estimated duration: 14.769229 sec
audio bytes: 230083
audio packets: 695
bit rate: 124145 bits per second
packet size upper bound: 661
maximum packet size: 661
audio data file offset: 4096
optimized
audio 708923 valid frames + 2112 priming + 645 remainder = 711680
----


However, if I CAShow my AUGraph, I get the following output

AudioUnitGraph 0x6BAE000:
  Member Nodes:
node 1: 'aumx' 'smxr' 'appl', instance 0x86bae06a O I
node 2: 'auou' 'sys ' 'appl', instance 0x86bae06b O I
node 3: 'augn' 'afpl' 'appl', instance 0x86bae06c O I
node 4: 'augn' 'afpl' 'appl', instance 0x86bae06d O I
node 5: 'augn' 'afpl' 'appl', instance 0x86bae06e O I
node 6: 'augn' 'afpl' 'appl', instance 0x86bae06f O I
node 7: 'augn' 'afpl' 'appl', instance 0x86bae070 O I
node 8: 'augn' 'afpl' 'appl', instance 0x86bae071 O I
node 9: 'augn' 'afpl' 'appl', instance 0x86bae072 O I
node 10: 'augn' 'afpl' 'appl', instance 0x86bae073 O I
node 11: 'augn' 'afpl' 'appl', instance 0x86bae074 O I
node 12: 'augn' 'afpl' 'appl', instance 0x86bae075 O I
node 13: 'augn' 'afpl' 'appl', instance 0x86bae076 O I
node 14: 'augn' 'afpl' 'appl', instance 0x86bae077 O I
  Connections:
node   3 bus   0 => node   1 bus   0  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   4 bus   0 => node   1 bus   1  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   5 bus   0 => node   1 bus   2  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   6 bus   0 => node   1 bus   3  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   7 bus   0 => node   1 bus   4  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   8 bus   0 => node   1 bus   5  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   9 bus   0 => node   1 bus   6  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node  10 bus   0 => node   1 bus   7  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node  11 bus   0 => node   1 bus   8  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node  12 bus   0 => node   1 bus   9  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node  13 bus   0 => node   1 bus  10  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node  14 bus   0 => node   1 bus  11  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   1 bus   0 => node   2 bus   0  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
  CurrentState:
mLastUpdateError=0, eventsToProcess=F, isInitialized=T, isRunning=F


Should I have to set the sample rate on all the intermediary nodes of the
graph, or should the sample rate propagate through the graph automatically?
How do I avoid doing the little hack mentioned above regarding the sample
rate to get the correct timings.

Thanks for your time,
Regards
Tim
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      ([email protected])
Help/Unsubscribe/Update your Subscription:
https://lists.apple.com/mailman/options/coreaudio-api/archive%40mail-archive.com

This email sent to [email protected]

Reply via email to