Synthesizer

Snap! oscillators (berkeley.edu)

i made a very poor synthesizer because why not, i think synthesizers are cool. as well as a couple of JavaScript blocks so that i can generate continuous audio in snap for this to work properly.

piano keyboard:

 S D   G H J   2 3   5 6 7
Z X C V B N M Q W E R T Y U I

i would like to add, among other things, different oscillator shapes other than sine waves, a third oscillator, and an amplitude envelope, but i must go to sleep for now. there is only an attack parameter for the ampltiude envelope currently

and also i would like to fix that bug where you press or let go of multiple keys simultaneously. and also make it compute faster with the least amount of JavaScript, but i'm not sure how feasible that is. although you already need to turn on JS for the audio to work anyway, so maybe i should offload expensive computations to javascript code.

also please make it so when any key pressed events can re-enter

Noted. I'll talk with Jens about it.

As someone who plays with audio this is very cool, I wish that Snap! had all of your custom blocks because cool stuff like this would be possible without JavaScript.

nope, sorry, if you need to synch music use either broadcast or - perhaps better - launch but not direct key events.

i needed it not to sync music, but for the piano keyboard.

for this:
oscillators script pic
since it doesn't re-enter, the user can only press one note at a time.

use launch, like jens said.

oh in the hat block sorry i didn't think of that

That actually introduces another issue, when you press and hold a key, it runs the hat block multiple times. To fix this, just have a list of the current keys pressed, and if it contains the key being pressed, stop this script. When you release a key, it can then remove the key from the list.