mudcube / MIDI.js

:musical_keyboard: Making life easy to create a MIDI-app on the web. Includes a library to program synesthesia into your app for memory recognition or for creating trippy effects. Convert soundfonts for Guitar, Bass, Drums, ect. into code that can be read by the browser. Supports multiple simultaneous instruments and perfect timing.
http://mudcu.be/midi-js/
MIT License
3.8k stars 640 forks source link

Dev branch program changes #71

Open kusog opened 10 years ago

kusog commented 10 years ago

The way the code is written, noteOn looks for the channel instrument the moment it is called and uses the delay in the audio context source noteOn/start. The code now uses program changes in the song with delay so that a channel's instrument is not set until the moment the program change is supposed to happen.

All the notes are scheduled at the beginning before any channel instrument has been assigned from a program change, such that no instrument has been assigned yet. I think you must use a setTimeout for the audio context noteOn rather than let the delay go into the source.noteOn so that by the time the timeout calls the function, the channel's instrument has been assigned.

adamrabung commented 10 years ago

I think that's the behavior I'm seeing here..right? https://gist.github.com/adamrabung/10145713 Clicking back and forth between "piano" and "flute", the program will often "bleed" into the next piece.

kusog commented 10 years ago

I have seen that issue too, but is only slightly related to the original issue discussed. The stop method doesn’t properly stop all notes. I have fixed this but have not pushed it up to github for a pull request.

From: adamrabung [mailto:notifications@github.com] Sent: Tuesday, April 8, 2014 11:47 AM To: mudcube/MIDI.js Cc: kusog Subject: Re: [MIDI.js] Dev branch program changes (#71)

I think that's the behavior I'm seeing here..right? https://gist.github.com/adamrabung/10145713 Clicking back and forth between "piano" and "flute", the program will often "bleed" into the next piece.

— Reply to this email directly or view it on GitHub https://github.com/mudcube/MIDI.js/issues/71#issuecomment-39864736 .Image removed by sender.