WIP 20121122 - Making some noise!

graph depicting a sound wave in green over black

I am going to use Sorollet.js in this experiment, just as I did with MACCHINA I.

Sorollet.js --in case you don't follow me-- is my little monophonic synthesiser ported to Javascript. It started life as a C synth that I used on a 64k intro, then I ported it to C++ and it also grew into a VSTi plug-in, and then I realised it would be better used if it lived on the web too. Thanks to the Web Audio API!

I did the initial port for MACCHINA I, but I wasn't really happy with the result. It was cumbersome, had much boiler plate and it definitely wasn't elegant! And that's why the github repository is still empty right now ;-)

I started rewriting it yesterday after I posted yesterday's WIP post. I always start with the key block: the voice, which is the smallest block in the synth--a voice emits sound.

For V1 I wasn't using prototypes, but it made some things such as constants quite complicated to do, and there were lots of getters/setters because of the almost literal C++ port. It didn't feel like native Javascript. Now I'm using a more classic prototype construction, and exposing most of the values as simple JS properties. I'm also assuming the programmer is a responsible person. This sort of laxity regarding class members feels like a Pythonic zen versus stressed, ultra verbose enterprise Java. Needless to say, I rather prefer the Pythonic way :-)

Once I got the voice sort of working I moved to rewriting the ADSR class. An ADSR envelope helps you define property changes over time. Wikipedia explains it better than me, so I'll simply add how I use ADSR envelopes: I use it for modifying the pitch and the volume. So that way you can build "complex" sounds that sort of trick the user into thinking this is a more advanced machine. For example one of my favourite tricks is starting with a very high note and then rapidly decreasing its pitch, and at the same time the volume also goes from high to low. This generates a bassdrum-like sound!

Unfortunately I don't have an example yet as I haven't totally finished with the ADSR class here. There were some errors in the way the transitions between states happened and I fixed these, and I also wanted to ensure the method names made sense. That always requires a lot of careful thinking and reconsidering.

Hopefully I'll have some online demo soon, so you can play with the synth online. It will be fun!