Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ofxAudioUnitFilePlayer::playAtSampleTime() acts the same as play() #23

Open
jasonlevine opened this issue May 23, 2015 · 2 comments
Open

Comments

@jasonlevine
Copy link
Contributor

Hi Adam,

I'm not sure if I've written about this before but recently noticed that calling playAtSampleTime(5 * 44100) will play the audio from the beginning of the file 5 seconds after the function call, which is exactly what play(5 * 44100) does. Logically, and from function definition, it seems like playAtSampleTime(5 * 44100) should start playing the audio file immediately from 5 seconds into the file. Is this correct? Is there a fix?

@admsyn
Copy link
Owner

admsyn commented May 23, 2015

Ah I guess the wording is a bit confusing. I think the reason I added that was to sync playback across multiple file players.

It's been awhile since I've looked at this code. I think the bit that controls your start frame is _region.mStartFrame, if you want to look into it yourself.

@jasonlevine
Copy link
Contributor Author

Ok so I walked through the code in the Xcode debugger:
playAtSampleTime(SR) sets _seekSampleTime to SR then calls play()
play() calls prime() and then prime() sets _region.mStartFrame to SR

So: startTime = mach_absolute_time() and _region.mStartFrame = SR
It seems like it should start playing immediately from 1 second into the track, but instead it starts from the beginning of the track, one second later.

Am I still misunderstanding? It seems like the intention of playAtSampleTime(SInt64 sampleTime) is to choose which sample of the audio file to start playback on by setting _region.mStartFrame to the desired frame when the region is primed as opposed to play(uint64_t startTime) where startTime is used create a timeStamp to schedule playback via FillOutAudioTimeStampWithHostTime(startTimeStamp, startTime);

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants