Re: old mtcoreaudio code doesn't work now
Re: old mtcoreaudio code doesn't work now
- Subject: Re: old mtcoreaudio code doesn't work now
- From: dudley ackerman <email@hidden>
- Date: Sun, 6 Jan 2008 11:16:54 -0800
mtcoreaudio worked on tiger, now i am using the latest mtcoreaudio on
leopard and having a problem.
after having a problem recording yielding loud buzzing, i decided to
not use mtcoreaudio as a framework. i modified the imports and
included the files directly in my project. now, i get a failure
registering my output device.
is there something wrong in my setup?
i am trying to do a simple record and then playback:
- (void) setDeviceOpen:(BOOL)state
{
NSLog(@"setDeviceOpen:");
[receiveQueue release];
receiveQueue = nil;
if (state)
{
[inputDevice setDevicePaused:YES]; // lock out IO cycles while we
change a resource they use
[outputDevice setDevicePaused:YES];
[self allocNewConverter];
[outputDevice setDevicePaused:NO];
[inputDevice setDevicePaused:NO];
if ( ! ( [outputDevice deviceStart] && [inputDevice deviceStart] ))
{
NSLog(@"Device was unable to start.");
[self setDeviceOpen:NO];
return;
} else {
NSLog(@"Devices were able to start.");
receiveQueue = [[NSMutableArray alloc] initWithCapacity:16];
}
}
else
{
NSLog(@"Stopping devices.");
[inputDevice deviceStop];
[outputDevice deviceStop];
}
deviceOpen = state;
}
- (void) allocNewConverter
{
NSLog(@"allocNewConverter");
Float64 inScale = ([self sampleRate] / [outputDevice
nominalSampleRate]);
unsigned bfsz = [outputDevice deviceMaxVariableBufferSizeInFrames];
unsigned inBufferSize = ceil ( inScale * bfsz *
SR_ERROR_ALLOWANCE );
if (inBuffer) MTAudioBufferListDispose(inBuffer);
inBuffer = MTAudioBufferListNew(1, inBufferSize, NO);
[inConverter release];
inConverter = [[MTConversionBuffer alloc]
initWithSourceSampleRate: [self sampleRate]
channels: 1
bufferFrames: inBufferSize
destinationSampleRate: [outputDevice nominalSampleRate]
channels: [outputDevice channelsForDirection:
kMTCoreAudioDevicePlaybackDirection]
bufferFrames: [outputDevice deviceMaxVariableBufferSizeInFrames] *
SR_ERROR_ALLOWANCE
minimumBufferSeconds: 0
];
Float64 outScale = ([self sampleRate] / [inputDevice
nominalSampleRate]);
unsigned outBufferSize = ceil ( outScale * [inputDevice
deviceMaxVariableBufferSizeInFrames] * SR_ERROR_ALLOWANCE );
if (outBuffer) MTAudioBufferListDispose(outBuffer);
outBuffer = MTAudioBufferListNew(1, outBufferSize, NO);
[outConverter release];
outConverter = [[MTConversionBuffer alloc]
initWithSourceSampleRate: [inputDevice nominalSampleRate]
channels: [inputDevice channelsForDirection:
kMTCoreAudioDeviceRecordDirection]
bufferFrames: outBufferSize
destinationSampleRate: [self sampleRate]
channels: 1
bufferFrames: ceil ( [inputDevice
deviceMaxVariableBufferSizeInFrames] * SR_ERROR_ALLOWANCE )
minimumBufferSeconds: 0
];
}
_______________________________________________
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