Re: Problems setting sample rate
Re: Problems setting sample rate
- Subject: Re: Problems setting sample rate
- From: email@hidden
- Date: Fri, 19 May 2006 15:32:27 -0400
Hi Bill,
Found this thread (or actually just a single message)
http://lists.apple.com/archives/coreaudio-api/2003/Sep/msg00050.html
This developer wrote a string of (apparently unanswered) messages about
the MBox, and this particular one mentions that the output seemed to be
scaled, which would probably produce the kind of distortion that I am
hearing. Is there a parameter that can be changed to test this theory?
The developer in the thread mentions scaling his Audio Stream...
- Rick
William Stewart wrote:
On 18/05/2006, at 1:23 PM, Rick Cohen wrote:
Hi Bill,
Very interesting stuff! See below...
On 5/18/06, William Stewart <email@hidden> wrote:
On 18/05/2006, at 12:04 PM, Rick Cohen wrote:
> OK, I got rid of the error by disconnecting the nodes of the graph
> before setting the property, then reconnecting before I initialize
the
> graph. However, the sound coming out is pretty bad! Mostly noise,
> followed by a brief recognizable bit of audio.
>
> - Rick
>
> On 5/18/06, Rick Cohen <email@hidden> wrote:
>> Hi folks,
>>
>> I have a device here (Digidesign Mbox) that allows the user to set
>> their sample rate from its own control panel, which is called Digi
>> CoreAudio Manager. Never mind the fact that this is not
available as
>> a control panel property, that is another subject :(
>>
>> Anyway, I'm attempting to set the sample rate of my graph to
48000 if
>> the Mbox is already set to 48000, prior to launching my app. I'm
>> able
>> to get that sample rate with the
>> kAudioDevicePropertyNominalSampleRate
>> property on the Audio Device.
You can also get this by just looking at the output unit's { Output
Scope, El==0 } sample rate.
Indeed you can! I tried this and it works.
>> When I try to set the property on my output unit and my audio
unit, I
>> am getting an error result of kAudioUnitErr_PropertyNotWritable
>> (-10865) when I initialize the graph.
>>
>> RequireNoErr(AudioUnitSetProperty(
>>
>> mOutputUnit,
>>
>> kAudioUnitProperty_SampleRate,
>>
>> kAudioUnitScope_Global,
>>
>> 0, // AudioUnitElement inElement,
>>
>> &sampleRate,
>>
>> sizeof(Float64)
>>
>> ));
>>
>>
>> RequireNoErr(AudioUnitSetProperty(
>>
>> mTargetUnit, // AudioUnit ci,
>>
>> kAudioUnitProperty_SampleRate,
>>
>> kAudioUnitScope_Global,
>>
>> 0, // AudioUnitElement inElement,
>>
>> &sampleRate,
>>
>> sizeof(Float64)
>>
>> ));
You can't really set sample rate as a global scope... Sample rate is
a format property, and formats are applied to input and output scopes.
You also can't set the format on the output scope, element == 0, on a
device output unit - that is the device side, and you can't change
the format of the device through the output unit... You can set the
format on the input scope, element == 0 of course -> this is the
format you are providing to the output unit.
I tried setting sample rate only on the output scope on my target AU,
and on the input scope on my output AU, and unfortunately got the same
bad noise result.
Are these calls succeeding? You have to make sure the AU is not
initialised, and that its input doesn't have an existing connection (or
input callback).
As for setting a sample rate on a graph - at a set up point there is
an example of this in the PlaySequence code in the SDK.
What I found in PlaySequence contradicted what I thought that I had
read in the mailing list archive. I could only find
AudioUnitSetProperty (... SampleRate ...) for the output scope of the
synth, and that was after the nodes were connected!
No - they appear to be connected, but they aren't actually connected
until the graph is initialised - just for this reason...
Do a CAShow (myGraph) both before and after these calls, and you'll see
the progress through this...
I thought that
you could only set sample rates while the nodes were disconnected.
Anyway, I changed my code to connect the nodes, and then to only set
the sample rate for the output of my target AU, not setting the sample
rate of the input scope on the output unit at all. That also resulted
in bad noisy output.
If you can just send me the code as something I can run, I'd be happy
to look over this...
Bill
- Rick
Bill
>>
>> result = AUGraphInitialize( mGraph );
>>
>> Any suggestions would be helpful. Thanks!
>>
>> - Rick
>>
> _______________________________________________
> Do not post admin requests to the list. They will be ignored.
> Coreaudio-api mailing list (email@hidden)
> Help/Unsubscribe/Update your Subscription:
40apple.com
>
> This email sent to email@hidden
--
mailto:email@hidden
tel: +1 408 974 4056
_____________________________________________________________________
___
__
"Much human ingenuity has gone into finding the ultimate Before.
The current state of knowledge can be summarized thus:
In the beginning, there was nothing, which exploded" - Terry Pratchett
_____________________________________________________________________
___
__
_______________________________________________
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