Trying to debug mystery sinewave using AKMIDISampler in Audiokit

笑着哭i 提交于 2019-12-01 07:32:53

I found out the cause of this issue. I learnt that the MIDI sequencer was creating an extra track when I gave it a specific number of MIDI tracks; for four tracks in my midi file, the sequencer was giving me five. This extra track is for tempo (as discovered here).

I also learnt that my first track was being ignored from my .plist (where I set up the stems for different songs).

My assumption that the first track is being used for the tempo track was tested, and when I created five tracks in my .plist to match the sequencer, the sinewave tone disappeared.

This lead to a workaround hack. I did this by duplicating the first sample in my .plist, which was being ignored anyway, and then hiding the sprite that represented this sound off screen. This works for now, but if anyone has an idea of how to control this tempo track and its use in AKSequencer I’d love to know more.

So in short: Make sure that the MIDI file has exact number of tracks that you want to use. Create the same number of AKMIDISampler to use in AKSequencer adding one for tempo track. Then beware that the first track in the sequencer is the tempo track and will not work playing samples.

This is a bit of a guess, but its a very common issue to have your audio files in a location that the sampler likes. Try putting the audiofiles in a Samples/ folder like in these examples:

http://audiokit.io/playgrounds/Playback/Sequencer/ http://audiokit.io/playgrounds/Playback/Sampler/

or I think a Sounds or "Sampler Instruments" folders work as well as in the Sampler Demo:

https://github.com/AudioKit/AudioKit/tree/master/Examples/iOS/SamplerDemo/SamplerDemo/Sounds

I had a mystery sinewave in my code as well. In my situation, it turns out I had an extra occurrence of the following code:

AudioKit.output = sampler

So I accidentally ended up specifying AudioKit.output twice. After removing the extra occurrence, the sinewave disappeared. I'm not sure how this caused the sinewave, but I'm leaving this answer here in case it helps others who might have a similar issue.

Another way to get this mystery sinewave is by using the normal approach to setting preferredSampleRate

//   try session.setPreferredSampleRate(preferredSampleRate)

in AppDelegate for Audio Session... instead of setting it in the AudioKit AKSettings, it will produce the mystery sinewave midi synth...

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!