Skip to content

Feature Request: Transpose and Enharmonics #1145

@jrgbr

Description

@jrgbr

Hello everyone,
It may sound strange, but as an alto saxophonist, I prefer to play C#-major rather than Db-major (same with A#/Bb minor). I looked at the library, but the visualTranspose always transposes to Db-major. This results from the relative transposing and the use of the static keys-map in abc_transpose.js:

var newKey = [‘C’, ‘Db’, ‘D’, ‘Eb’, ‘E’, ‘F’, ‘F#’, ‘G’, ‘Ab’, ‘A’, ‘Bb’, ‘B’];

If you change “Db” in this array to “C#,” transposing to C# works fine.

I really like your library with all it features, but it would be nice if there were a possibility to switch enharmonics dynamically. With my limited knowledge of JavaScript, I created a patch within keySignature(), using an input variable “enharmonics,” as shown below.

I looked at the other issues, but haven't found any discussion about this. If this idea is addressed elsewhere, please let me know.

Best regards,
Joerg


var newKey = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B'];
var newKeyMinor = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B'];
transpose.keySignature = function (multilineVars, keyName, root, acc, localTranspose) {
      // needed for switching back
      newKey = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B'];
      newKeyMinor = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'Bb', 'B'];

      if(multilineVars.enharmonics) {
        //console.log(multilineVars.enharmonics);
        if("#"===multilineVars.enharmonics) {
          newKey = ['C', 'C#', 'D', 'Eb', 'E', 'F', 'F#', 'G', 'Ab', 'A', 'Bb', 'B'];
          newKeyMinor = ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#', 'G', 'G#', 'A', 'A#', 'B'];
        }
        if("b"===multilineVars.enharmonics) {
          newKey = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'];
          newKeyMinor = ['C', 'Db', 'D', 'Eb', 'E', 'F', 'Gb', 'G', 'Ab', 'A', 'Bb', 'B'];
        }
      }
      ...

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions