• 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: AudioDeviceRead and timestamps
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: AudioDeviceRead and timestamps


  • Subject: Re: AudioDeviceRead and timestamps
  • From: Jeff Moore <email@hidden>
  • Date: Fri, 20 Jun 2003 18:29:20 -0700

The PlayEffect sample code uses AudioDeviceRead. You can consult that code for a usage example.

I think that the root of your problem is that you aren't leaving enough slop when calculating the input time. The reason why is that the current time is already too late so you need to back off a bit (determined by experimentation) before subtracting the safety offset and the buffer size.

On Thursday, June 19, 2003, at 5:04 PM, Andrew Kimpton wrote:

I'm using AudioDeviceRead() during an output callback to also read the audio from the input device (this is USB Audio - so the input and output devices are different).

I've setup my BufferList and everything just fine - I get audio into my buffers without any problems. However there appears to be a +/- 1 sample 'wobble' in the acquired data.

I'm playing a generated 750Hz sine wave into the USB Audio Device (an EMI 2|6) through the SPDIF inputs. I can see (and hear) that on almost every buffer 'edge' a sample is either being repeated or dropped (so I don't hear a pure tone).

I create my startTime timestamp using the following code

AudioStampTime startTime;
memcpy(&startTime, inNow /* now as passed to the callback function*/, sizeof(AudioTimeStamp);
startTime.mSampleTime = startTime.mSampleTime - (Float64) mInputSafetyOffset - (Float64) mNumberFrames;

mInputSafetyOffset is retrieved at start time by querying the device and is the same as Daisy reports for the device in question. mNumberFrames is 512 in this case.

I've logged the startTime values and can see that the values I'm getting for sampleTime 'move' relative to each other between successive callbacks by small amounts (typically 0.2 - 0.5) so I may get difference in sample times between callbacks that looks like :

511.60823805
511.03020467
512.03594040
511.73845436
512.88922777

Am I supposed to be doing some sort of rounding to the sample time value ? It seems like perhaps I'm suffering from someone elses rounding ?

I've tried using AudioDeviceGetCurrentTime() to initalize my startTime instead of the now value the callback is given but that actually seemed to make things worse !

Has anyone else used AudioDeviceRead() in such a manner ?

Andrew 8-)
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.



--

Jeff Moore
Core Audio
Apple
_______________________________________________
coreaudio-api mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/coreaudio-api
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: AudioDeviceRead and timestamps
      • From: Andrew Kimpton <email@hidden>
    • Re: AudioDeviceRead and timestamps
      • From: Andrew Kimpton <email@hidden>
References: 
 >AudioDeviceRead and timestamps (From: Andrew Kimpton <email@hidden>)

  • Prev by Date: more AU info and plugins
  • Next by Date: Re: Known issues with VST-AU based AudioUnits
  • Previous by thread: AudioDeviceRead and timestamps
  • Next by thread: Re: AudioDeviceRead and timestamps
  • Index(es):
    • Date
    • Thread