paulrosen / abcjs

javascript for rendering abc music notation
Other
1.92k stars 284 forks source link

Manic Playback on Tunefinder Tunes #693

Closed rpattcorner closed 3 years ago

rpattcorner commented 3 years ago

I'm finding an almost consistent extremely fast play on tunes from one particular (Tunefinder) site. It doesn't look like there's anything actually wrong with the tunes, see a couple examples below -- except that there is no tempo (Q) field, which doesn't seem unusual.

Anybody know how "Q" defaults? I checked the standard, but found nothing on expected behaviour when Q is absent, as it often is.

My app imports tunes, and can slow them down, but there are very many that are manic. I'm considering inserting a Q field with something reasonable on import, say Q: 120.

Does anyone more experienced see any problem with normalizing tunes in that way?

Example:

X: 1
T:Cluck Old Hen [1]
M:2/4
L:1/8
B:Kuntz - Ragged but Right
K:A
[Ae]a =g/a/g/f/|e/d/e/e/ df|[Ae]a =g/a/g/f/|e/c/B A2|
[Ae]a =g/a/g/f/|e/d/e//e/ df|[Ae]a =g/a/g/f/|e/c/B A2||
[Ae][Ae] [ce]>[ce]|[A/e/][B/e/][Ae] [=GA]>[GA]|[Ae][A/e/][B/e/] [c/e/][B/e/][c/e/]d/|
e/c/B A2|[Ae][Ae] [ce]>[ce]|[A/e/][B/e/][Ae] [=GA]>[GA]|[Ae][A/e/][B/e/] [c/e/][B/e/][c/e/]d/|e/d/B A2||

Example:

X: 1
T:Martha's Carpet
C:Joe Buchanan's Scottish Tome - Page 328.0
I:328 0
C:Donald MacFarlane
R:Pipe March
Z:Carl Allison
L:1/16
M:2/4
K:C
e>d | c>BA>c e>Ac<A | d>fa>f e>fc>e | f>Ae>A c2B>A | f<ae>c B2e>d |
c>BA>c e>Ac<A | d>fa>f e>fc<e | d>ef<a e>fB<e | c2A2 A2 :|
f>g | a2f<a e2A<c | A<Aa>e c2e2 | f>Ae>A c2>BA | f<ae>c B2f>g |
a2f<a e2A<c | A<Aa>e c2e2 | d>ef<a e>fB<e | c2A2 A2 :|
c>d | e>fe>c a>af<a | f>da>f e>fc>e | f>Ae>A c2B<A | f<ae>c B2c>d |
e>fe>c a>af<a | f>da<f e>fc>e | d>ef<a e>fB<e | c2A2 A2 :|
f>g | a2e>f a>ec<e | f2a>f e>fc<A | f>Ae>A c2B<A | f<ae>c B2f>g |
a2e>f a>ec<e | f2a>f e>fc<A | d>ef>a e>fB<e | c2A2 A2 :|
paulrosen commented 3 years ago

When creating the control for playback you can use the option defaultQpm, which is the beats per minute only if a Q: field isn't present.

For the Tunefinder site, they would have to add that to the way they are creating the synth.

The tempo was set to 180 by default, purely arbitrary. I agree that 120 would be a better default, but only for some traditional communities.

rpattcorner commented 3 years ago

Thanks! defaultQpm looks perfect.

At first I thought defaultQpm had no effect, but that's because my "faster/normal/slower" control manipulates the millisecondsPerMeasure value, which apparently overrides qpm. I've commented out the milliseconds... here:

return midiBuffer.init({
  visualObj: visualObj,
  audioContext: audioContext,
  options: {
  program: inst,
  defaultQpm:  100 
  },
// millisecondsPerMeasure: baseMsPerMeasure * speed.value

Apparently either will affect speed. Any thoughts on how they interact, and an optimal setup for a baseline default that can be sped or slowed? I suppose millisecondsPerMeasure will determine absolute tempo regardless of the presence or absence of a Q parameter.

It would be nice to set a baseline tempo default, and still have faster/normal/slower work relative to the baseline, but if millisecondsPerMeasure overrides defaultQpm it may be challenging.

paulrosen commented 3 years ago

I plan on consolidating some of these options because I agree they are hard to sort out.

There is setWarp(percent) which might be what you want for temporarily changing the tempo.

rpattcorner commented 3 years ago

Understood. I'll probably leave it at manipulating defaultQpm for now, as my current implementation uses the midiBuffer approach, and it looks like setWarp is not a midiBuffer option, but rather a property of the more complex synthControl, which I'm not using yet.

Unless I'm missing something obvious?

rpattcorner commented 3 years ago

Thanks. It would be useful to set an absolute speed in a specification that's easier to think about than milliseconds..., e.g. qpm regardless of what the ABC says.