Comments (11)
Hey @paulrobertpine. Could you post the song you were trying to change and the ChordSheetJS version youβre using?
from chordsheetjs.
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:
from chordsheetjs.
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 updatingmetadata
and by inserting the key directive or updating an existing oneSong#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.
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.
@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.
@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.
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.
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.
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.
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.
Thanks for reporting this! I added two issues to the board: #569 and #570
from chordsheetjs.
Related Issues (20)
- Support for browser without regex lookbehind HOT 2
- SetCapo doesn't render chords properly HOT 2
- song.transpose not allowing to transpose to different keys with same distance HOT 2
- How to detect the current key? HOT 4
- ChordSheetJS with ChordProject HOT 3
- Contributing: error with yarn test (Windows) HOT 2
- Is it wrong to use Transpose in a song that modulates within a song? HOT 1
- Verse and Chorus (only) section labels incorrectly omitted if lower case (UG parser only) HOT 10
- Angular : error build HOT 3
- Add support for parsing minus sign (-) HOT 2
- Font handling : Add support for Non-Monospace fonts for converting to ChordPro HOT 10
- support of chordpro v6? HOT 4
- [Duplicate #955] Non-Monospace fonts support HOT 2
- Support for markup (Pango Markup Language)
- Support for annotations
- Support for delegates
- Add missing meta tags
- Support for conditional directives
- Usage in Angular 16 app results in: Cannot find module 'chord_sheet/item' or its corresponding type declarations. HOT 3
- UltimateGuitarParser to ChordProFormatter generates wrong output HOT 3
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
π Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google β€οΈ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from chordsheetjs.