Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Notes only play a maximum of 2 seconds or so #73

Open
kusog opened this issue Mar 24, 2014 · 12 comments
Open

Notes only play a maximum of 2 seconds or so #73

kusog opened this issue Mar 24, 2014 · 12 comments

Comments

@kusog
Copy link
Contributor

kusog commented Mar 24, 2014

The way audio and audiocontext are setup, they only play through the given mp3/ogg note once. If the music has a note that lasts longer than that it wont play. I have fixed this in my branch by adding loop=true to both the audio tag and web audio api plugins.

I use this for violin drone practices: http://kusogmusic.com/violin/drones

I have fixed a bunch of similar types of issues that have kept tools like that from working.

@mudcube
Copy link
Owner

mudcube commented Mar 25, 2014

You're right it's definitely an issue w/ Violin, Organ and similar instruments.

If we want to handle this properly, the repeat should be setup to be able to take a portion of the audio and repeat from there (not necessarily the entire thing). Here's an example, this one has the attack (at the beginning) then the later half repeats over and over until the noteOff happens:

screen shot 2014-03-24 at 7 56 05 pm

@kusog
Copy link
Contributor Author

kusog commented Mar 25, 2014

I’ve come to the same conclusion. In fact that could be the solution to getting attack/decay with normal note playback. I know it can be done with web audio api, and with audio we can jump the current position as needed.

From: Michael Deal [mailto:notifications@github.com]
Sent: Monday, March 24, 2014 10:58 PM
To: mudcube/MIDI.js
Cc: kusog
Subject: Re: [MIDI.js] Notes only play a maximum of 2 seconds or so (#73)

You're right it's definitely an issue w/ Violin, Organ and similar instruments.

If we want to handle this properly, the repeat should be setup to be able to take a portion of the audio and repeat from there (not necessarily the entire thing). Here's an example, this one has the attack (at the beginning) then the later half repeats over and over until the noteOff happens:

https://f.cloud.github.com/assets/101564/2507920/06503990-b3c9-11e3-8428-b6e83e42b035.png screen shot 2014-03-24 at 7 56 05 pm


Reply to this email directly or view it on GitHub #73 (comment) . https://github.com/notifications/beacon/1085858__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxMTMzNTQ5MCwiZGF0YSI6eyJpZCI6Mjg0MjczNzl9fQ==--29f46c98b3194e082e3cfc27e23885a3befbeed5.gif

@mudcube
Copy link
Owner

mudcube commented Mar 25, 2014

Wow, in WebAudioAPI it actually looks really easy:

// here are our starting and stopping points
// for this file's internal loop
var wpn_machinegun_fire_loop_start = 0;
var wpn_machinegun_fire_loop_end = 0.5782708333;

// let's play a sound
myContext = soundWpnMachineGunFire01.play();
// gotta set the loop points
myContext.loopStart = wpn_machinegun_fire_loop_start;
myContext.loopEnd = wpn_machinegun_fire_loop_end;

via http://www.html5audio.org/2013/03/new-looping-functionality-in-web-audio-api.html

@kusog
Copy link
Contributor Author

kusog commented Mar 25, 2014

I have experimented with the loop start/end on the source node and it works, but there is still a very obvious sound when it loops around which I do not think is simply a part of the audio file. It is something like a click. Perhaps it is due to the instrument file having a variance in the sound due to vibrato, but it sounds to be more than that, similar to the sound you can hear on http://kusogmusic.com/violin/drones

From: Michael Deal [mailto:notifications@github.com]
Sent: Tuesday, March 25, 2014 5:17 AM
To: mudcube/MIDI.js
Cc: kusog
Subject: Re: [MIDI.js] Notes only play a maximum of 2 seconds or so (#73)

Wow, in WebAudioAPI it actually looks really easy:

// here are our starting and stopping points
// for this file's internal loop
var wpn_machinegun_fire_loop_start = 0;
var wpn_machinegun_fire_loop_end = 0.5782708333;

// let's play a sound
myContext = soundWpnMachineGunFire01.play();
// gotta set the loop points
myContext.loopStart = wpn_machinegun_fire_loop_start;
myContext.loopEnd = wpn_machinegun_fire_loop_end;

via http://www.html5audio.org/2013/03/new-looping-functionality-in-web-audio-api.html


Reply to this email directly or view it on GitHub #73 (comment) . https://github.com/notifications/beacon/1085858__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxMTM1ODI0NiwiZGF0YSI6eyJpZCI6Mjg0MjczNzl9fQ==--d8170a720a88eac69010ef5d8b27d69afacd93d2.gif

@kusog
Copy link
Contributor Author

kusog commented Mar 25, 2014

I noticed the machine gun demo site, and it is very convenient that they use a sound that naturally has a burst rather than continuous sound like the instrument sounds. So I am curious to know if a pure tone sound file would work to where the user cannot tell there is a loop and it just sounds like one continuous long sound, like a violin note that never ends.

From: Michael Deal [mailto:notifications@github.com]
Sent: Tuesday, March 25, 2014 5:17 AM
To: mudcube/MIDI.js
Cc: kusog
Subject: Re: [MIDI.js] Notes only play a maximum of 2 seconds or so (#73)

Wow, in WebAudioAPI it actually looks really easy:

// here are our starting and stopping points
// for this file's internal loop
var wpn_machinegun_fire_loop_start = 0;
var wpn_machinegun_fire_loop_end = 0.5782708333;

// let's play a sound
myContext = soundWpnMachineGunFire01.play();
// gotta set the loop points
myContext.loopStart = wpn_machinegun_fire_loop_start;
myContext.loopEnd = wpn_machinegun_fire_loop_end;

via http://www.html5audio.org/2013/03/new-looping-functionality-in-web-audio-api.html


Reply to this email directly or view it on GitHub #73 (comment) . https://github.com/notifications/beacon/1085858__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxMTM1ODI0NiwiZGF0YSI6eyJpZCI6Mjg0MjczNzl9fQ==--d8170a720a88eac69010ef5d8b27d69afacd93d2.gif

@mudcube
Copy link
Owner

mudcube commented Mar 26, 2014

With soundfont files, the repeat is programmed at a specific time so the loop feels continuous even with violins. There's an app called Polyphone on OSX where you can analyze the soundfont and see these repeat patterns (which makes soundfonts make a lot more sense).

http://sourceforge.net/projects/polyphone/

@mudcube
Copy link
Owner

mudcube commented Mar 31, 2014

@kusog Hey, I lost your email, could you send me a message? I have another job that might be worthwhile looking into.

@kusog
Copy link
Contributor Author

kusog commented Apr 1, 2014

Did you really mean to talk to me? I sent a message through http://mudcu.be/contact/

From: Michael Deal [mailto:notifications@github.com]
Sent: Monday, March 31, 2014 5:05 PM
To: mudcube/MIDI.js
Cc: kusog
Subject: Re: [MIDI.js] Notes only play a maximum of 2 seconds or so (#73)

@kusog https://github.com/kusog Hey, I lost your email, could you send me a message? I have another job that might be worthwhile looking into.


Reply to this email directly or view it on GitHub #73 (comment) . https://github.com/notifications/beacon/1085858__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcxMTkxOTEyOCwiZGF0YSI6eyJpZCI6Mjg0MjczNzl9fQ==--91feadd6a28271b1282027259fff6156d83a4a66.gif

@mudcube
Copy link
Owner

mudcube commented Apr 1, 2014

@kusog Yup, sorry, just stepped out for a few hours. I'm going to forward you a job that might be fun in a bit here.

@charlieroberts
Copy link

Hello,

Just curious if anymore work had been done along these lines. Thanks! - Charlie

@kusog
Copy link
Contributor Author

kusog commented Sep 12, 2014

I have code in place in my version that does the looping, but it still doesn’t sound right because you have to know exactly what points to loop with to sound like a continuous sound. I don’t have that info and thus the solution doesn’t help.

From: charlie roberts [mailto:notifications@github.com]
Sent: Friday, September 12, 2014 3:40 PM
To: mudcube/MIDI.js
Cc: kusog
Subject: Re: [MIDI.js] Notes only play a maximum of 2 seconds or so (#73)

Hello,

Just curious if anymore work had been done along these lines. Thanks! - Charlie


Reply to this email directly or view it on GitHub #73 (comment) . https://github.com/notifications/beacon/1085858__eyJzY29wZSI6Ik5ld3NpZXM6QmVhY29uIiwiZXhwaXJlcyI6MTcyNjE2OTk4MywiZGF0YSI6eyJpZCI6Mjg0MjczNzl9fQ==--8461149ea545aed4118d5a979d2d731c483e71ca.gif

@charlieroberts
Copy link

Well, we need more information from the soundfont converter. The spec says that loop points can be provided (section 6.3):

http://www.synthfont.com/sfspec24.pdf

So I guess the next step will be working on that. I might take that on if I find the time, as I like the idea of being able to use soundfonts, but require the looping.

afoda added a commit to afoda/fet that referenced this issue Apr 3, 2016
Prevents the development of a reliance on silence to identify the tone.

The piano voice in MIDI.js plays an ogg, therefore the note cannot be
sustained indefinitely. This problem is discussed at
mudcube/MIDI.js#73 .
Consider switching to different voice or different MIDI library.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants