abcjs icon indicating copy to clipboard operation
abcjs copied to clipboard

Clef Transposing

Open caseywatts opened this issue 6 years ago • 5 comments

This tool I made can transpose to different instruments' keys now, but only for those that are Treble clef. I understand ABC enough that I could manually edit the abc notation to get the clef I want in there, but most users of this tool wouldn't - they'd rather have it in a drop-down.

I imagine we could have a clefTranspose option something similar to the visualTranspose one already implemented: https://github.com/paulrosen/abcjs/blob/master/src/parse/abc_parse.js#L1623

For an example scenario: I'm playing trombone and I want to play the melody in bass clef, so I toggle the UI to be octave=-2 here. If I could also toggle clef from treble to bass, it would be exactly what I wanted: https://folktunetransposer.com/

caseywatts avatar Oct 25 '19 23:10 caseywatts

Interesting. I don't think this would be too hard, except for dealing with explicit clefs. What if the abc string contained:

K:G clef=alto

Would this supercede it?

What if there were multiple voices, like:

V:T1           clef=treble-8  name="Tenore I"   snm="T.I"
V:T2           clef=treble-8  name="Tenore II"  snm="T.II"
V:B1  middle=d clef=bass      name="Basso I"    snm="B.I"
V:B2  middle=d clef=bass      name="Basso II"   snm="B.II"

I can see the use for it, and if it only worked correctly for single voice music, I guess it might still be ok.

paulrosen avatar Nov 03 '19 21:11 paulrosen

visualTranspose supercedes the written octave too, I think it would make sense for a clef version to supercede how it's written. I can't think of any case where the written explicit clef should supercede, if somebody is actively overriding it.

For the folk tunes I've played from folktunefinder.com I haven't seen any with multiple clefs yet. For these most common use cases, this feature could modify just the first clef, or all clefs, or only single-voice tracks. I think editing all voices might be the least surprising of the options.

I thought about another approach that would also cover the Trombone goal: editing of the clef in the abc notation itself. It's a different feature in some ways. If we could hook into abcParser (or wherever makes sense) such that a user could change the clef via a dropdown and have it appropriately updated in the abc notation. This would totally the superceding issue, although I suppose we'd also have to account for multiple voices in this approach as well.

caseywatts avatar Nov 07 '19 00:11 caseywatts

I should have hooks at various parts of the process. I just put one in when creating audio and it was surprisingly useful to do a unique one-off feature. It might be complicated for the caller to weed through the object, though, and that would lock the form of the object as a public interface - I want to keep it flexible so I can change it.

But clefTranspose=treble|tenor|alto|bass that forces all clefs to be the transposed clef would be doable and probably useful.

paulrosen avatar Nov 07 '19 03:11 paulrosen