AudioKit: AKPlayer not loading AKAudioFile at all
This has been addressed in an upcoming bug fix. The problem was that AKPlayer was assuming the passed in AKAudioFile was opened forReading, whereas the AKMicrophone's associated file was forWriting.
AKAudioPlayer created a duplicated file object which is why it worked there. Should be updated very soon!
AudioKit crashes when try record after playing in AKPlayer
I'm pretty sure this will be solved in today's AudioKit 4.5.2 release, uploading now.
Synchronizing AKPlayer with AKSampleMetronome
you are calling the AVAudioTime playback function with a Double parameter. That's incorrect. If you want to start the AKPlayer with a seconds param, use player.play(when: time)
In general, you're close. This is how you do it:
let startTime: Double = 1
let hostTime = mach_absolute_time()
let now = AVAudioTime(hostTime: hostTime)
let avTime = now.offset(seconds: startTime)
metronome.setBeatTime(0, at: avTime)
player.play(at: avTime)
Basically you need to give a common clock to each unit (mach_absolute_time()), then use AVAudioTime to start them at the exact time. The metronome.setBeatTime is telling the metronome to reset it's 0 point at the passed in avTime.
Using toggle (on-off) switch on AKPlayer
To discover what is really happening here, you can log the contents of the tracks after each delete. For example:
for (i, track) in sequencer.tracks.enumerated() {
print("track: \(i)")
print(track.getMIDINoteData())
}
One possibility is that when you delete track 0, the tracks re-index themselves, which means the second delete call would have no effect.
Perhaps a safer and more predictable way to handle this would be to use track.clear()
rather than delete
. You can create the tracks you will need at the start and assign their output to the AKCallbackInstrument
only once at the setup stage. Then you can safely add notes to the tracks or clear events from the tracks as needed. Again, logging the track contents with track.getMIDINoteData()
will be helpful for debugging.
Also, I wouldn't recommend stopping and starting AudioKit more than you need to. Start AudioKit when you initialize your app, and leave it on unless you have a compelling reason to stop it.
AudioKit : AKNodeOutputPlot and AKMicrophone not working, potentially due to Lifecycle or MVVM architecture decisions
EDIT
AudioKit 4.6 fixed all the issues! Highly encourage MVVM/Modularization of AudioKit for your projects!
====
So after alot of experiments. I have come to a few conclusions:
In a separate project, I brought over my
AudioKitConfigurator
andMicrophone
classes, initialized them, hooked them to aAKNodeOutputPlot
and it worked flawlessly.In my very large project, no matter what I do, I cannot get the same classes to work at all.
For now, I am reverting back to an old build, slowly adding components until it breaks again, and will update the architecture one by one, as this problem is too complex and might be interacting with some other libraries. I have also downgraded from AudioKit 4.5.6, to AudioKit 4.5.3.
This is not a solution, but the only one that is workable right now. The good news is, it is entirely possible to format AudioKit to work with an MVVM architecture.
Related Topics
3 Component Dynamic Multi UIpickerview Swift
F# Asynchronous Http Request - Parse JSON Response
How to Horizontally Center Content of Horizontal Scrollview
Show Status Bar Only for iPhone X
Swift 4: How to Asynchronously Use Urlsessiondatatask But Have The Requests Be in a Timed Queue
How to Fill Triangle in Swift Using Core Graphics
Swift Applications Takes More Space on Disk
How to Send Multiple Buttons in Button.Addtarget Action? Swift3
Command Center Scrubber on Lock Screen Swift
Realitykit - Add Force to Entity at Specific Point
I Opened My App in Xcode 10 and Now I Have Errors in 9.4.1: Sdkapplicationdelegate (Facebookcore)
How to Pass a Completion Block to Another Class in Swift
User Specific Avatar in Jsqmessagesviewcontroller with Sdwebimage
How to Make First Responder in Swiftui Macos
Cannot Use Mutating Member ... Because Append
Nsextensionpointidentifier Error Only on Real Device
Continuous Rotation of Nsimageview (So It Appears to Be Animated)