2

I'm interested in developing a simple test application on ios (using Swift) in which moving the mouse cursor from left to right controls the frequency of the sound being played, according to a floating point position on a continuous grid. I'd be looking for something like this: https://www.szynalski.com/tone-generator/

I've created a basic visualization of the exponential frequency curve to help myself get started:

one octave frequency graph, darker colors represent the whole tones

The sound has to be generated at runtime and play continuously, and frequency changes should also be continuous/instantaneous (as with a pitch-bend). AudioKit seemed like a greatAPI to help me get something done quickly, but looking into it more, it looks like a lot of the well-documented convenience features apply only to pre-made audio. For example, the webpage says that the pitch-bend example is only for player sounds, not generated sound.

Looking through the tutorials, I don't see that my use case is covered -- maybe in the complex audio synth. There is also the question of how I will make frequency changes and audio be in a prioritized thread, as this is the main point of the application. I remember reading that using a UI event loop won't work.

To show that I've made an effort to find the solution, I'd like to link a few pages I've found:

This is an example of MIDI note output, but it isn't continuous: https://audiokit.io/playgrounds/Synthesis/Oscillator%20Bank/

One of the only frequency questions I've found on stackoverflow works with pitch detection with the microphone, which isn't really related: AudioKit (iOS) - Add observer for frequency / amplitude change

This talks about continuous oscillation, but doesn't describe how to change a frequency dynamically or generate a sound How to change frequency of AKMorphingOscillatorBank countinuously in Audiokit?

I think this is the closest thing I've found (generating sound, using run-time parameters to adjust the frequency): AudioKit: change sound based upon gyro data / swing phone around?

If the last page has the solution, then what do I do with AKOperationGenerator? I'd love to see a full example.

The question in short: how do I create a simple example in AudioKit (or do I need CoreAudio and AudioUnits?) in which a floating point coordinate updated continuously at runtime can be used to change the frequency of a generated sound continuously and instantaneously? How do I create such a sound (I imagine that I'd like to synthesize not only a sine wave, but also something that sounds more like a real instrument or FM synth), turn it on/off, and control it the way I need?

I'm a beginner with AudioKit, but I have the development environment all set-up. May I have a little help getting this off-the ground?

synchronizer
  • 1,563
  • 1
  • 7
  • 24
  • Well I played with one of the playgrounds and found that it's possible, but it's a little awkward. I'm not sure what the best/most efficient way to update the sound in a game loop is. The control flow is unclear. Audio needs to be prioritized. – synchronizer Aug 15 '19 at 16:31

1 Answers1

0

AKOscillatorBank does have a pitchBend option, and it is continuous. I've used it myself.

In fact, the Oscillator Bank example in the Synthesis Playground has a pitch bend slider, and when you have the piano key on, you can slide it up and down for continuous pitch change.

I know this thread is a little old, but hope it helps!

  • Thanks. However, I think the latest version of AudioKit has changes and deprecated a ton of things. A concrete example snippet or a link would come in handy. It's good to know this is possible though. – synchronizer Mar 28 '21 at 20:36