paulrosen / abcjs

javascript for rendering abc music notation
Other
1.94k stars 285 forks source link

Bring bass note in range if transposed out-of-range #1046

Closed seisiuneer closed 2 months ago

seisiuneer commented 2 months ago

Doing a transpose, either a %%MIDI transpose or setting a visual transpose at renderABC time sometimes causes octave changes in the backup.

For example, if you take this tune and do a visual transpose of +2, the G chords that get played are still a G, but down an octave. This change checks the range of the bass after application of the transpose and brings it into the basses[] array range.

X: 1 T: The Kesh C: Traditional R: Jig M: 6/8 L: 1/8 Q: 3/8=120 K: Gmaj % % Use an Acoustic Grand Piano sound for the melody: %%MIDI program 0 % % Use an Acoustic Grand Piano for the chords: %%MIDI chordprog 0 % % Use an Synth Bass sound for the bass: %%MIDI bassprog 38 % |:"G"GAG GAB|"D"ABA ABd|"G"edd gdd|"C"edB "D"dBA| "G"GAG GAB|"D"ABA ABd|"G"edd gdB|"D"AGF "G"G3:| |:"G"BAB dBd|"C"ege "D"dBA|"G"BAB dBG|"D"ABA AGA| "G"BAB dBd|"C"ege "G"dBd|"C"gfg "D"aga|"G"bgf g3:|