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

Slow start of playing #272

Open
batata004 opened this issue May 4, 2023 · 3 comments
Open

Slow start of playing #272

batata004 opened this issue May 4, 2023 · 3 comments

Comments

@batata004
Copy link

Hi,

This library is awesome however I am trying to live play an instrument using it and unfortunatelly there is lots of lags (almost 300ms). I connected my MIDI Controller to the computer and used this library to capture the notes being pressed and playing the sounds. I discovered the latency/delay is not related to the MIDI itself, the MIDI commands are received very very fast, what is adding lots of delay is the "play" itself of the sound. I checked the noteOn function and clearly the problem is when the note is being played, it takes some time for the sound to be played.

Isnt there any other JS method that allows a fast response from the time you execute the play and the time the sound actually is played?

@mscuthbert
Copy link
Contributor

I get about 14ms delay on my side. Can you post your code?

You might look at my music21j project -- it incorporates midicube and manages to get much better than 300ms response time for playing notes from a keyboard (Artusi's test your audio/midi feature -- post login -- has a playable MIDI-in piano that uses both music21j and midicube w/ nothing close to 300ms response).

It may be that somehow your instrument soundfont isn't being cached. 300ms sounds like the amount of time that it would take to load the soundfont before playing.

@batata004
Copy link
Author

batata004 commented May 5, 2023

@mscuthbert Hi my dear friend, I double checked and the soundfont is correctly being cached by the browser, if you want I can make a video of my playing and you will see the problem.

I managed to reduce the code to the minimum possible, you can see that the method to play sound that your library is using, is what is causing the delay/lantecy. Open the link below (which has a very small code), and you will see the delay everytime you click on the page. I am using the same type of AudioBuffer as your library (I am even using the exactly same piano sound). For some reason the function source.start(0); is not fast enought.

https://www.quemfazsite.com.br/temp/gerar_som_click.php

@mscuthbert
Copy link
Contributor

See note on Issue #273 -- resolve that first before coming back to here. You have a mix of the old pre-webpack and post webpack configuration.

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

2 participants