Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Generate a sound (not from a file)

I'm building a small game prototype, and I'd like to be able to play simple sounds whose length/tone/pitch will vary based on what the user is doing.

This is surprisingly hard to do. Closest resource I found was:

http://www.tmroyal.com/playing-sounds-in-swift-audioengine.html

But this does not actually generate any sound on my device or on the iOS simulator.

Does anyone know of any working code to play ANY procedurally generated audio? Simple Sine Wave would do.

like image 366
Jamona Mican Avatar asked Feb 16 '15 16:02

Jamona Mican


2 Answers

https://gist.github.com/rgcottrell/5b876d9c5eea4c9e411c

This code on the other hand works, and it's beautifully written...

Success!

like image 142
Jamona Mican Avatar answered Oct 24 '22 05:10

Jamona Mican


You can try AudioKit.

It's an audio framework built on top of Core Audio. In their Continuous Control example they use a simple FM oscillator with controlled parameters.

like image 9
guardabrazo Avatar answered Oct 24 '22 05:10

guardabrazo