• 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: Michael Thornburgh <email@hidden>
  • Date: Sun, 6 Jan 2008 12:41:51 -0800


well, i don't know exactly how you're using your inConverter and outConverter. are you doing live play-through, recording and playing out immediately? or are you recording from the input device to a buffer or file or something with [self sampleRate] samples per second, and then later playing out that buffer to the output device?


if you're doing live play-through, then you have too many MTConversionBuffers. you'd just need one for the samples to flow through from input to output.

regardless of how you're hooking up these conversion buffers, judging only from the names, i don't think you're setting them up correctly. based on the names, it seems to me they should be configured:

inConverter: source side: from inputDevice; destination side: to outputDevice (for live play-through) or whatever "self" is (for recording and later playback).

outConverter: source side: from inputDevice (for live play- through) or whatever "self" is (for recording and later playback); destination side: to outputDevice.

the buffer sizes are probably also too small. they need to be big enough to hold *at least* one IOProc/IOTarget callback buffer's worth of samples, or you'll over- or under-flow the buffer during the input or output side's action. you want the buffers to be small to keep latency down, but IOProc dispatch jitter will cause over- or under- flow unless there's some slop. plus you have to be reading out samples fast enough to keep the input from overflowing, or feed samples in fast enough to keep the output from overflowing, if either end isn't real-time (like, in the record to or play back from a buffer or file or something case).

finally: be sure you're using MTCoreAudio 1.3.2 (the actual latest release), or later (if you're reading this in the far future), or MTConversionBuffers just won't work on Leopard.

HTH.

-mike


On Jan 6, 2008, at 11:16 AM, dudley ackerman wrote:

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
  • Follow-Ups:
    • Re: old mtcoreaudio code doesn't work now
      • From: dudley ackerman <email@hidden>
References: 
 >Re: old mtcoreaudio code doesn't work now (From: dudley ackerman <email@hidden>)

  • Prev by Date: Re: old mtcoreaudio code doesn't work now
  • Next by Date: Deprecated function forward compatability
  • 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