I'm trying to determine the exact number of samples/frames of a sound file. For this I am using the following formula
However, this always gives a number that is ever so slightly too large. In fact after a little experimentation
The output of running afinfo on the audio file shows that has a sample rate of 48kHz
Data format: 2 ch, 48000 Hz, 'aac ' (0x00000000) 0 bits/channel, 0 bytes/packet, 1024 frames/packet, 0 bytes/frame
estimated duration: 14.769229 sec
bit rate: 124145 bits per second
packet size upper bound: 661
audio data file offset: 4096
audio 708923 valid frames + 2112 priming + 645 remainder = 711680
However, if I CAShow my AUGraph, I get the following output
AudioUnitGraph 0x6BAE000:
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
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]
mLastUpdateError=0, eventsToProcess=F, isInitialized=T, isRunning=F