oampo / Audiolet

A JavaScript library for real-time audio synthesis and composition from within the browser
http://oampo.github.com/Audiolet/
Apache License 2.0
893 stars 118 forks source link

adding midi control groups #40

Closed kn0ll closed 12 years ago

kn0ll commented 12 years ago

this is in reference to issue #38. i couldn't wait so i went ahead at a first pass. i hosted examples of the basic midi control and an arpeggiator. i hope the documentation/examples sufficiently explain the commit.

i did realize too late, that both instrument and arpeggiation control groups really only make sense with some frequency lookup, which would be made much easier with something like music.js. for now- the notes are all just relative frequencies with no math behind them.

so there's a few minor issues, but i figured i'd get your feedback before moving forward.

thanks!

oampo commented 12 years ago

Okay, this is very interesting. Will have a proper look when I get a moment and then we can work to get this merged. Cheers for all the work! Joe

oampo commented 12 years ago

Hey Nic,

Sorry for the delay - have been super busy. I have half an idea for this which I want to explore properly and see whether it could work. Basically I'd quite like to make this more generic so it can deal with messages in the wider sense, and then MIDI would work as a subset of this. So you would have nodes which send, receive and process (probably JSON) messages, and we could pass midi through the processing graph this way. So, from your example something like this would happen:

  1. Create a Keyboard (which is a MessageNode with one output, which sends out note-on and note-off messages)
  2. Create an Arpeggiator (which is a MessageNode with one input and one output, reacts to note-on and note-off messages from the input and sends the arpeggiated messages to the output).
  3. Create a "Voicer" (equivalent to your Instrument - which is a MessageNode with one input and no outputs, which has a createVoice and destroyVoice function for the user to override)

Then on top of this we could fairly simply allow AudioletGroups to connect to/from MessageNodes in the same way as AudioletNodes do currently, without the need for a separate MidiGroup concept.

I'll try to jot down some example code, but what do you think to the general idea? As I say - it's more a refinement of what you've got than anything else, but I think it could help when working with (for example) OSC messages, WebSocket applications etc.

Joe

kn0ll commented 12 years ago

yea that makes perfect sense. the role of the midi/osc/etc subclass, perhaps, would be routing a general message to a specific method? for instance:

midiOut.send({ channel: 144, key: 40, velocity: 255 }) -> midi.noteOn(40, 255);
oscOut.send({ value: 0.2, path: '/gain' }); -> osc['/gain'](0.2);
oampo commented 12 years ago

Merged into version-2 branch. Will work on expanding the messaging feature from there.