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

AudioPlayer schedule not working as expected #2832

Open
jasonayre opened this issue Mar 28, 2023 · 0 comments
Open

AudioPlayer schedule not working as expected #2832

jasonayre opened this issue Mar 28, 2023 · 0 comments
Labels

Comments

@jasonayre
Copy link
Contributor

macOS Version(s) Used to Build

macOS 12 Monterey

Xcode Version(s)

Xcode 14

Description

So I'm just trying to schedule a buffered AudioPlayer, at multiple, specific times. I am running entirely in offline mode. For context, my code currently looks like this, which I've had to do the following to avoid weird pops when playback starts: (sampleTimeDelay function just calculates the delay correctly based on the buffers sample rate)

          avNodeAsType().prepare(withFrameCount: buffer.frameLength)
          akNodeAsType().load(buffer: buffer)
          akNodeAsType().schedule(at: sampleTimeDelay(Float(delay)))
          akNodeAsType().play()

^ (I mention this in case any of it looks weird. Because I was also expecting to not have to call play on the node after scheduling, but if I remove play nothing plays back.)

Anyways, rather than calling the schedule function as above, I'm essentially just trying to do this:

      for time in trigger_at_times {
        akNodeAsType().schedule(at: sampleTimeDelay(Float(time)))
      }

But if I do that, then the last call to schedule overrides all the previous calls, and it only plays at the the time for the last value in the array.

So I thought I could work around it by using the completion handler to reschedule/ play the buffer after it stops (although that's not really what I want either because then if the sample is > length than the pause it won't trigger), but the completion handler isn't called at all when engine is in offline mode it looks like.

Any idea how I can achieve this, or whether I'm missing something obvious?

Crash Logs, Screenshots or Other Attachments (if applicable)

No response

@jasonayre jasonayre added the bug label Mar 28, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant