• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
How to setup the sample rate in an AUGraph
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

How to setup the sample rate in an AUGraph


  • Subject: How to setup the sample rate in an AUGraph
  • From: Laurent Noudohounsi <email@hidden>
  • Date: Thu, 20 Jul 2017 13:02:39 +0200

Hi CoreAudio team,

I have an AUGraph (I know that I should move on the new API but I cannot
for the moment) witht he simple schema:

FilePlayer -> Mixer -> Output

I added a custom notification callback in the FilePlayer in order to track
the end of the file.

In this way I have a callback function like this

static OSStatus CallbackRenderProc(void *inRefCon,
                                     AudioUnitRenderActionFlags
*ioActionFlags,
                                     const AudioTimeStamp *inTimeStamp,
                                     UInt32 inBusNumber,
                                     UInt32 inNumberFrames,
                                     AudioBufferList * ioData) {
if (*ioActionFlags & kAudioUnitRenderAction_PostRender) {
auto file_player = (AUFilePlayer*)inRefCon;

if (file_player->is_playing_) {
        file_player->last_frame_position_ += inNumberFrames;
}

if(file_player->last_frame_position_ > file_player->number_of_frames_) {
        file_player->is_finished_ = true;
        file_player->Stop(error);
        if (error) { return error.value(); }
}
}
}

and I attach to the audio unit like this

AudioUnitAddRenderNotify(audio_unit(), render_callback.inputProc,
render_callback.inputProcRefCon);


But I've some question about the behaviour of a custom callback within an
AUGraph.
Indeed, I've the feeling that the AUGraph use default settings for the
callback options. Like all the graph is in 44100kHz with 2 channels.

I see it when I use a mono file and inspect ioData->mNumberBuffers which is
2 instead of 1…


But my question is about the sampling rate.

I use a file with a sampling rate of 11025 (= 1/4 * 441000). The callback
tell me that the frame position reach the number of frames too early. For a
16sec file, I reach the end at 4sec (btw the 1/4 of 16sec)

So how can I handle this problem? Can I set global setting to the AUGraph
or should I set the format for every audio units?

If it's the case how could I use `kAudioUnitProperty_StreamFormat`??

I have this client format:

Sample Rate:        11025
Format ID:          lpcm
Format Flags:       9
Bytes per Packet:   4
Frames per Packet:  1
Bytes per Frame:    4
Channels per Frame: 1
Bits per Channel:   32

But when I get the property of the using hte FilePlayer audio unit I get
this:

Sample Rate:        44100
Format ID:          lpcm
Format Flags:       41
Bytes per Packet:   4
Frames per Packet:  1
Bytes per Frame:    4
Channels per Frame: 2
Bits per Channel:   32


And here is the description of my graph
AudioUnitGraph 0x7FD004:
  Member Nodes:
node 1: 'auou' 'def ' 'appl', instance 0x807fd070 O I
node 2: 'augn' 'afpl' 'appl', instance 0x807fd071 O I
node 3: 'aumx' 'smxr' 'appl', instance 0x807fd072 O I
  Connections:
node   3 bus   0 => node   1 bus   0  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
node   2 bus   0 => node   3 bus   0  [ 2 ch,  44100 Hz, 'lpcm'
(0x00000029) 32-bit little-endian float, deinterleaved]
  Input Callbacks:
{0x0, 0x0} => node   3 bus   1  [2 ch, 44100 Hz] // <— it's ok if
everything is NULL, for the moment I don't use it.


Thanks you for your help and feel free to tell me if you need more
information.
 _______________________________________________
Do not post admin requests to the list. They will be ignored.
Coreaudio-api mailing list      (email@hidden)
Help/Unsubscribe/Update your Subscription:

This email sent to email@hidden

  • Follow-Ups:
    • Re: How to setup the sample rate in an AUGraph
      • From: Brian Willoughby <email@hidden>
  • Prev by Date: Re: EXS24/SF2 sample limits on iOS
  • Next by Date: Re: EXS24/SF2 sample limits on iOS
  • Previous by thread: Re: why is ExtAudioFileSetProperty raises c++ exception?
  • Next by thread: Re: How to setup the sample rate in an AUGraph
  • Index(es):
    • Date
    • Thread