2

I'm looking to play short WAV files (about 1 second each) in certain sequences. The sequences are one measure of 16th notes, segmented into 4 parts, that are generated randomly. An example random sequence would be the following. Each "x" is a note and each "-" is a rest : "|x - - - | - x x - | x - x x | x x x x |"

Right now, I can only conceive of doing a similar thing by playing sounds from a MIDI bank with Audio Toolbox. I still don't know how I would make the sounds play in that certain sequence even with the MIDI bank. Also, there are 4 sequences that should play at once. Any pointers or even a small nudge in the right direction is greatly appreciated.

Marcus Kim
  • 283
  • 2
  • 12
  • i read you question twice and still don't understand what you are trying to do.... – Chris Jan 28 '20 at 07:43
  • @Chris I actually think I might be asking too much. Do you know of a way to arrange a drum beat by random programmatically? – Marcus Kim Jan 28 '20 at 08:07
  • if you know how to play a sound/drum, then it shouldn't be so hard to play it randomly? just do PlayAudio ? if Int.random(in: 0...1) == 1 { playSound() } else { wait() } – Chris Jan 28 '20 at 08:32
  • Hmm . . . not exactly what I'm looking to do. . . I downloaded the AudioKit framework and the tutorial playgrounds. . . I'll be back with an answer. . . Although, I think you were catching on to part of the answer – Marcus Kim Jan 28 '20 at 21:51

1 Answers1

0

I solved it by using the AudioKit framework. You can play your own sampled drum sounds and specify the position that they play within a measure. Too much to write in this answer. But you can go to AudioKit.io and download the playgrounds project. Inside you will see a playground file called Drum Sequencer. It explains the functionality really well!

Marcus Kim
  • 283
  • 2
  • 12