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.81k stars 640 forks source link

Safari on iPad fails to play multiple tracks #64

Open kusog opened 10 years ago

kusog commented 10 years ago

I'm unable to here sound when playing the latest version of your code on the iPad. However, the demo site version works.

I've also noticed that the demo site code base works on the iPad, but won't play multi-track midi files properly. No sound is played, even though on my demo site http://kusogmusic.azurewebsites.net/home/contact the notes fall for both tracks. It seems that it is trying to play. If you want to see that, pick the Cyrstallize Duet. The duet song is the same instrument for both tracks, so I wonder if it is not the same issue as you outlined with multiple instruments in another issue.

On my windows 8.1 desktop, it works fine with IE11, Chrome, Opera, and FireFox.

kusog commented 10 years ago

I believe this is due to CPU overload. When used on lower end PCs I get odd problems. When used on the Mac with Safari or Chrome, the CPU is hit and the more sounds playing at once the more the sound quality is impacted. Removed the gain node helps significantly. I believe that when using web audio api, anything that requires sound processing like the gain will eat CPU. Works fantastic on Chrome for my quad core i7, but not so good on Chrome on my Acer Iconia W500 with the C50 atom cpu.

kusog commented 10 years ago

In some ways, using

mudcube commented 10 years ago

Hi @kusog, Good point, there should be an option to turn on/off any special WebAudioAPI features, like gain support (and future effects) to support Mobile browsers more effectively. I'll take a look into this and add to the list for next release. Also, browser support for MIDI.js listed on the project page would be a boon.

mudcube commented 10 years ago

In the meantime, it'd be easy for you to detect iOS, and then have a conditional in the plugin.js that prevents linearRampToValueAtTime, and the createGain function from being run in the WebAudioAPI portion of the script.

kusog commented 10 years ago

I discovered that the version of MIDI-js I am running will set gain volume above 1, yet the docs say the value should be between 0 and 1 as a decimal. When I did some tests and just hard coded the volume to 50, I get the bad scratchy sound on Safari. A test I made just working with web audio API works great on safari >6.0 with many sounds playing even with gain and no problems.

From: Michael Deal [mailto:notifications@github.com] Sent: Tuesday, February 18, 2014 12:47 AM To: mudcube/MIDI.js Cc: kusog Subject: Re: [MIDI.js] Safari on iPad fails to play multiple tracks (#64)

Hi @kusog https://github.com/kusog , Good point, there should be an option to turn on/off any special WebAudioAPI features, like gain support (and future effects) to support Mobile browsers more effectively. I'll take a look into this and add to the list for next release. Also, browser support for MIDI.js listed on the project page would be a boon.

— Reply to this email directly or view it on GitHub https://github.com/mudcube/MIDI.js/issues/64#issuecomment-35354783 . https://github.com/notifications/beacon/1085858__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcwODIzNTIzMCwiZGF0YSI6eyJpZCI6MjU3NjIyMTd9fQ==--1584e23d93d3f2d74eb6cb40bad77f6514a084c4.gif

mudcube commented 10 years ago

@kusog I noticed in the docs it says between 0-1 also but for some reason it requires -1 in order to turn the volume completely off... so I mapped from -1.0 to 1.0 for the MIDIPlayer demo. I've added an upwards constraint for values more than 1.0 in the latest push to prevent accidentally going out of range.

montulli commented 9 years ago

The iPad is still a problem. I was using an older version of your library from Feb and your library worked reasonably well on the iPad in both safari and chrome. I just upgraded to the latest version and there are significant performance issues on Safari.

Let me know if I can help in any way. Unfortunately I don't have a Mac, so I can't debug anything on an Ipad. (Silly platform)