• 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
Re: old mtcoreaudio code doesn't work now
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: old mtcoreaudio code doesn't work now


  • Subject: Re: old mtcoreaudio code doesn't work now
  • From: Robert Ackerman <email@hidden>
  • Date: Sun, 23 Dec 2007 19:11:06 -0800


On Dec 22, 2007, at 12:37 AM, Michael Thornburgh wrote:


-[MTConversionBuffer initWithSourceSampleRate:channels:bufferFrames:destinationSampleRate:channels:bufferFrames:minimumBufferSeconds :] is the designated initializer. -[MTConversionBuffer initWithSourceDevice:destinationDevice:] is a convenience initializer that queries the given input and output devices for their properties and uses some reasonable defaults for other parameters. the third method Jaime mentions is an internal method (hence the leading "_" and absence from the public API in the header file) and should never be used by a client.


it looks like the designated initializer is the one you want. you could say something like

inConverter = [[MTConversionBuffer alloc] initWithSourceSampleRate: [shtoomDescription sampleRate] channels: [shtoomDescription channelsPerFrame] bufferFrames: SOME_REASONABLE_NUMBER_OF_FRAMES destinationSampleRate: [outputDevice nominalSampleRate] channels: [outputDevice channelsForDirection: kMTCoreAudioDevicePlaybackDirection] bufferFrames: [outputDevice deviceMaxVariableBufferSizeInFrames] * SR_ERROR_ALLOWANCE minimumBufferSeconds: 1.0];

-mike

i can't get it working right. i tried your suggestion with:


inConverter = [[MTConversionBuffer alloc]
initWithSourceSampleRate: [self sampleRate]
channels: 1
bufferFrames: inBufferSize
destinationSampleRate: [outputDevice nominalSampleRate]
channels: [outputDevice channelsForDirection: kMTCoreAudioDevicePlaybackDirection]
bufferFrames: [outputDevice deviceMaxVariableBufferSizeInFrames] * SR_ERROR_ALLOWANCE
minimumBufferSeconds: 1.0
];


outConverter = [[MTConversionBuffer alloc]
initWithSourceSampleRate: [inputDevice nominalSampleRate]
channels: [inputDevice channelsForDirection: kMTCoreAudioDeviceRecordDirection];
bufferFrames: outBufferSize
destinationSampleRate: [self sampleRate]
channels: 1
bufferFrames: ceil ( [outputDevice deviceMaxVariableBufferSizeInFrames] *SR_ERROR_ALLOWANCE )
minimumBufferSeconds: 1.0
];



and got a recording rate about 2 times too fast, with loud static on playback.


then i noticed a different initializer using the devices, so i tried:
	inConverter = [[MTConversionBuffer alloc]
		initWithSourceDevice: inputDevice
		destinationDevice: outputDevice
	];

	outConverter = [[MTConversionBuffer alloc]
		initWithSourceDevice: outputDevice
		destinationDevice: inputDevice
	];
}

and got no recording at all.

any ideas on what i might tinker with to get it working?

On Dec 21, 2007, at 11:08 AM, Robert Ackerman wrote:

On Dec 21, 2007, at 10:46 AM, Jaime Magiera wrote:

On Dec 21, 2007, at 12:53 PM, Robert Ackerman wrote:

it complains about a bad method call which, indeed, does not now exist:


inConverter = [[MTConversionBuffer alloc]
initWithSourceDescription:shtoomDescription
bufferFrames:inBufferSize
destinationDescription:[MTConversionBuffer descriptionForDevice:outputDevice forDirection:kMTCoreAudioDevicePlaybackDirection]
bufferFrames:ceil ( [outputDevice deviceMaxVariableBufferSizeInFrames] * SR_ERROR_ALLOWANCE )];


there is no such initializer, now.
so, i need to figure out how to translate everything in my allocConterer method to what MYConversionBuffer now expects.
my old code used a AudioStreamBasicDescription object to pass to the conversion buffer init. i see that initWithSourceSampleRate ends up creating such an object within itself, so that is my clue.
i will try to refactor my code to just pass in the params that method asks for.

Hello,

Looking at the MTConversionBuffer class, there are three init methods...

- initWithSourceDevice:(MTCoreAudioDevice *)inputDevice destinationDevice:(MTCoreAudioDevice *)outputDevice

- initWithSourceSampleRate:(Float64)srcRate channels: (UInt32)srcChans bufferFrames:(UInt32)srcFrames destinationSampleRate:(Float64)dstRate channels:(UInt32)dstChans bufferFrames:(UInt32)dstFrames minimumBufferSeconds: (Float64)minBufferSeconds

- (Boolean) _initAudioConverterWithSourceSampleRate: (Float64)srcRate channels:(UInt32)srcChans destinationSampleRate: (Float64)dstRate channels:(UInt32)dstChans

It looks like first two are usable in your situation. The third creates the actual Converter -- which may or may not be all you need. Note that MTConversionBuffer is a wrapper for AudioConverterRef, which you would allocate with...
extern OSStatus AudioConverterNew(
const AudioStreamBasicDescription*inSourceFormat,
const AudioStreamBasicDescription*inDestinationFormat,
AudioConverterRef*outAudioConverter);
What I would do is check elsewhere in the code and see if using MTConversionBuffer is necessary (does the wrapper provide an important functionality? or could you just use the AudioConverterRef and its accompanying setProperty/getProperty methods?)
does that help?
Jaime
thanks for responding --
i inherited the code which uses MTCoreAudio including MTConversionBuffer as a wrapper.
the MTConversionBuffer code handles reads/writes/flushes and callbacks to the app code, so i really don't want to elimiate it.
but i think i have enough to go on here. i will use one of the other init methods and see what happens.
b
_______________________________________________
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: old mtcoreaudio code doesn't work now
      • From: Jaime Magiera <email@hidden>
References: 
 >old mtcoreaudio code doesn't work now (From: Robert Ackerman <email@hidden>)
 >Re: old mtcoreaudio code doesn't work now (From: Jaime Magiera <email@hidden>)
 >Re: old mtcoreaudio code doesn't work now (From: Robert Ackerman <email@hidden>)
 >Re: old mtcoreaudio code doesn't work now (From: Jaime Magiera <email@hidden>)
 >Re: old mtcoreaudio code doesn't work now (From: Robert Ackerman <email@hidden>)
 >Re: old mtcoreaudio code doesn't work now (From: Michael Thornburgh <email@hidden>)

  • Prev by Date: AUAudioFilePlayer
  • Next by Date: Re: old mtcoreaudio code doesn't work now
  • Previous by thread: Re: old mtcoreaudio code doesn't work now
  • Next by thread: Re: old mtcoreaudio code doesn't work now
  • Index(es):
    • Date
    • Thread