Marak / buddypond

Cloud OS and Instant Messenger
https://buddypond.com
Other
153 stars 17 forks source link

Implement `App.Midi` for mapping MIDI inputs and emitting MIDI data as JavaScript Events #74

Open Marak opened 2 years ago

Marak commented 2 years ago

To start, we require a simple MIDI Mapper that will emit MIDI data as JS events.

The basic concept is that a buddy can open App.Midi, plug in a MIDI device, and begin playing keys / pressing buttons on the MIDI Device.

App.Midi will then take the incoming MIDI data and emit something like desktop.emit("midi", noteData)

The expectation is that other Apps will be able to subscribe to this event using desktop.on("midi", "piano-plays-notes", fn)

This should be relatively simple to implement. The Event Emitter pattern is already built into desktop.on and desktop.emit.

Marak commented 2 years ago

Was relatively easy to implement. We now have App.Midi which can be opened from the Profile page or from any text area by typing /midi.

Was able to successfully connect a MIDI device and broadcast MIDI events on desktop.emit.

Next steps will be connecting the existing App.MidiFighter and App.Piano to optionally accept the MIDI data. Feel free to join us in #Alpha room if you are interested in MIDI support.

Screen Shot 2022-04-16 at 11 50 21 PM
Marak commented 2 years ago

Was able to connect App.Piano input to the desktop.emit("midi-message") event.

This means now if a Buddy connects a MIDI Controller they should be able to play the Piano! Awesome!

The mappings are currently very basic, but we can build on this pattern for other instruments.

IceGuye commented 2 years ago

Hey Marak, this is IceGuye. The midi setup is okay, but the piano does work like what it should be. So, the controller ID should be the note (pitch), the value should be the volume or if it doesn't support velocity/volume, that is fine, you should put 0 to sound off and positive 1 - 127 to sound on. Right now, you put the value as the note, so it doesn't work right.

Marak commented 2 years ago

Yes, the mappings are just proof of concept for the MIDI bridge @IceGuye

Hoping someone can come in and help push this a bit more forward.

Marak commented 2 years ago

Thank you for testing this out @IceGuye !