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

mm.Player.tone.Transport.loop settings not always honored during playback #627

Open
swampthang opened this issue May 21, 2022 · 2 comments

Comments

@swampthang
Copy link

swampthang commented May 21, 2022

First, what an awesome set of libraries! Thanks so much!!

I'm building a simple midi player class with a looping feature as well as a tempo setting. The codepen is here...

https://codepen.io/swampthang/pen/vYdJYZy?editors=1010

In the pen, after the user makes a selection of a group of rect elements in the PianoRollSvgVisualizer, I call a setLoopParams function that sets these parameters:

mm.Player.tone.Transport.loop = true
mm.Player.tone.Transport.loopStart = <number in seconds>
mm.Player.tone.Transport.loopEnd = <number in seconds>

I added a set of span elements to show what these settings are that gets updated in the player callbackObject...
Screen Shot 2022-05-21 at 2 30 24 PM

First, if after loading the midi file you don't initially play and stop the midi file, selecting a group of notes DOES set the loop parameters but it doesn't honor them.

Next, if you have initially played the file, it will work, but pausing and playing and changing the selection ultimately causes the loop to no longer work even though you can see that those params are set. By the way, I didn't see any other way to set a loop other than using the mm.Player.Tone.Transport loop settings. If there is another more reliable way to do this, I'd love to know.

Thanks again for this awesome library. I have plans to leverage the power of all the other cool stuff like generating improve, etc.

@swampthang
Copy link
Author

swampthang commented May 21, 2022

I just noticed that the magenta player has a currentPart object with the same loop, loopStart and loopEnd properties. I noticed that, the first time a loop is set using mm.Player.tone.Transport.loop the currentPart loop object is undefined. After that, it is set with the loop, loopStart and loopEnd properties but the loop property is set to false even though the loopStart and loopEnd properties are set correctly according to mm.Player.tone.Transport.loopStart and mm.Player.tone.Transport.loopEnd.

I added the following to my setLoopParams function but it didn't seem to make any difference...

if( this.player.currentPart ) {
  this.player.currentPart.loop = true
  this.player.currentPart.loopStart = sx
  this.player.currentPart.loopEnd = ex
}

I've determined that if I initially, start and stop the midi and then initially set the first loop to start at 0, subsequent loops work. I did notice that the this.player.currentPart.loop keeps getting set back to false on its own in some cases.

@swampthang
Copy link
Author

Did I post this in the wrong place or is this just not as much of an issue as I perceive it to be? Please let me know if there might be another place that would be more appropriate to post this. There's so little in stackoverflow, etc.

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

1 participant