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 641 forks source link

Ways to prevent the browser from deprioritizing midiJS tasks in inactive tabs #185

Open akashagrahari opened 8 years ago

akashagrahari commented 8 years ago

I have an application which plays notes in sequence taking numeric cues using the MIDI.noteOn and MIDI.noteOff methods. The frequency in which the notes are played drops drastically when I move to another tab. Is there a workaround to this?

akashagrahari commented 8 years ago

Just to clarify. I am using the setTimeout method to create delays between sounds.

hmoffatt commented 8 years ago

You can do it by using a worker thread to do the scheduling. Check out the example application at https://github.com/cwilso/metronome. I have been experimenting with this to schedule midi.js events and it's working much better.

Hamish

Sent from my android device.

-----Original Message----- From: Akash Agrahari notifications@github.com To: "mudcube/MIDI.js" MIDI.js@noreply.github.com Sent: Sun, 17 Jul 2016 14:56 Subject: Re: [mudcube/MIDI.js] Ways to prevent the browser from deprioritizing midiJS tasks in inactive tabs (#185)

Just to clarify. I am using the setTimeout method to create delays between sounds.


You are receiving this because you are subscribed to this thread. Reply to this email directly or view it on GitHub: https://github.com/mudcube/MIDI.js/issues/185#issuecomment-233165220

shivrajsa commented 7 years ago

@hmoffatt could you please post some code sample for implementation of web worker in MIDI.js

hmoffatt commented 7 years ago

I'm won't have a chance to share anything for a month at least.

I rewrote the whole scheduler. It depends on a web worker for accurate timing.

However I don't think it's compatible with the audio tag output method, which could be removed (only internet explorer needs it and I don't think it works very well anyway), or the scheduler could be moved into the output methods too.

I have no idea if it would work with webmidi. Does that output method actually work?

Sent from my android device.

-----Original Message----- From: shivrajsa notifications@github.com To: "mudcube/MIDI.js" MIDI.js@noreply.github.com Cc: hmoffatt hamish@cloud.net.au, Mention mention@noreply.github.com Sent: Mon, 04 Sep 2017 10:06 Subject: Re: [mudcube/MIDI.js] Ways to prevent the browser from deprioritizing midiJS tasks in inactive tabs (#185)

@hmoffatt could you please post some code sample for implementation of web worker in MIDI.js

-- You are receiving this because you were mentioned. Reply to this email directly or view it on GitHub: https://github.com/mudcube/MIDI.js/issues/185#issuecomment-326922901