GithubHelp home page GithubHelp logo

Comments (11)

martijnversluis avatar martijnversluis commented on September 3, 2024

Hey @paulrobertpine. Could you post the song you were trying to change and the ChordSheetJS version you’re using?

from chordsheetjs.

paulrobertpine avatar paulrobertpine commented on September 3, 2024

Hi there,

"chordsheetjs": "^6.2.2"

It happen with any of the songs in my app. Code is here: https://github.com/paulrobertpine/songbook-2022

When I tested I changed the name of the local setKey function to make sure that wasn't the issue, seen here:

https://github.com/paulrobertpine/songbook-2022/blob/main/src/pages/%7BMarkdownRemark.fields__slug%7D.js

from chordsheetjs.

martijnversluis avatar martijnversluis commented on September 3, 2024

Hey @paulrobertpine. I was able to figure out what happens. setKey used to also transpose all chords. However, in your app the song key is not expressed in chordpro. This caused ChordSheetJS to try to calculate the transpose distance between null and the new key, which obviously will fail.

I published version 7.0.0 which addresses the issues:

  • Song#setKey now only sets the current song key, by updating metadata and by inserting the key directive or updating an existing one
  • Song#changeKey also transposes all chords.

In your app, you could either:

  • specify the song key in chordpro ({key: C})
  • set the song key from what is specified in the frontmatter, like this: song.setKey(frontmatterKey).changeKey(newKey)

Please let me know if this is helpful.

from chordsheetjs.

paulrobertpine avatar paulrobertpine commented on September 3, 2024

Thanks for working on this. Well this no longer causes errors, I'm not sure it's working correctly. If I call setKey('C') on a Song, it does not set the key. I can still see currentKey: null in the code. Then this causes an error when I try to cal changeKey.

Not all the songs are in chordPro format.

from chordsheetjs.

martijnversluis avatar martijnversluis commented on September 3, 2024

@paulrobertpine One important detail which might cause your issue, is that Song is immutable. You probably need to keep the song in state:

// Save the song _with_ the correct key in state
const [song, setSong] = useState(parser.parse(rawMarkdownBody).setKey(songKey));

function goDown() {
  setKey(key.transposeDown())
  setSong(song.changeKey(key));
}

function goUp() {
  setKey(key.transposeDown())
  setSong(song.changeKey(key));
}

from chordsheetjs.

martijnversluis avatar martijnversluis commented on September 3, 2024

@paulrobertpine Additionally, I took some time to implement transposing on Song. So now you can simplify to:

// Save the song _with_ the correct key in state
const [song, setSong] = useState(parser.parse(rawMarkdownBody).setKey(songKey));

function goDown() {
  setSong(song.transposeDown());
}

function goUp() {
  setSong(song.transposeDown());
}

See release 7.2.0

from chordsheetjs.

paulrobertpine avatar paulrobertpine commented on September 3, 2024

Actually my Song was already a state variable and this line:

// Save the song with the correct key in state
const [song, setSong] = useState(parser.parse(rawMarkdownBody).setKey(songKey));

Doesn't seem to fix the issue. I still have currentKey = null in the object. setKey is being fed a string.

from chordsheetjs.

paulrobertpine avatar paulrobertpine commented on September 3, 2024

Hi there,

I can see that the key is being set in the metadata. It's the fact that the Song object contains both currentKey and transposeKey properties that threw me off.

from chordsheetjs.

paulrobertpine avatar paulrobertpine commented on September 3, 2024

One thing that is new is that the chords are being "normalized" in a way that does not always work. For example this chord "Asus2" gets changed to "A2" on transpose. Most musicians would know this chord as "Asus2".

from chordsheetjs.

paulrobertpine avatar paulrobertpine commented on September 3, 2024

Another thing is the key, stored in the metadata, does not keep minor when you transpose (e.g., Am becomes Bb (major)) on transposeUp)

from chordsheetjs.

martijnversluis avatar martijnversluis commented on September 3, 2024

Thanks for reporting this! I added two issues to the board: #569 and #570

from chordsheetjs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    πŸ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. πŸ“ŠπŸ“ˆπŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❀️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.