Sound generation

Monkey Forums/Monkey Programming/Sound generation

Simon(Posted 2012) [#1]
Is there any way to generate sound without using wav/mp3 files?


Rex Rhino(Posted 2012) [#2]
I am not an expert with Monkey by any means, I have just started learning... but I wrote a sound synthesis object for BlitzMax, so sound synthesis was one of the first things I looked to see if was possible in Monkey.

From my poking around, no... you can't.

There was two ways I implemented sound synthesis on BlitzMax. Originally, I wrote out a .wav file manually to disk, and loaded it back in. Later, Mark added functionality that allowed one to write directly to the audio stream and I used that.

However, on Monkey, you can't save binary data - You can only write using the SaveState command (which stores a string). And there doesn't seem to be any sort of audio stream commands. And more to the point, for certain platforms like HTML5, things like manipulation of audio streams don't exist.

That doesn't mean you can do something like procedural music though. I am working on a system that loads a bunch of small drum and synth samples, and plays randomize music. I just need to synthesize the samples beforehand and store them.


Simon(Posted 2012) [#3]
Ah OK, thanks for the info!


Rex Rhino(Posted 2012) [#4]
That being said, I have only owned Monkey for a few days, so don't take my opinion as the final word. I have read the entire manual, and studied all the examples, but I don't have a whole lot of actual coding experience with Monkey... I would be ecstatic for someone to prove me wrong.


zoqfotpik(Posted 2012) [#5]
Look into granular synthesis. Essentially playing very short fragments of sounds very fast. I think with Monkey you would need a sample for each note you wanted to play but then you could do a number of very interesting things with them (imagine a note played with an electric guitar, then a 5th above it with a grand piano, in 256th notes).


Samah(Posted 2012) [#6]
Check out this website that Taiphoz linked a while ago on his dev diary:
http://www.bfxr.net/

Generate all the sounds you like. :)


zoqfotpik(Posted 2012) [#7]
He's talking about realtime synthesis. Again, the easiest way to get a lot of strange sounds with a system like Monkey that can't mess with the sounds too much is to use granular synthesis, perhaps using fragments of sounds generated by bfxr or the like.


Jimbo(Posted 2012) [#8]
You could consider using Midi. I think Andoid devices have a Midi subsytem these days, iOS, does.


zoqfotpik(Posted 2012) [#9]
Does Monkey have midi?


Jimbo(Posted 2012) [#10]
Probably not - but it would be a very useful external module addition!