Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Changing to # or b for entire song #1169

Closed
beltonk opened this issue May 13, 2024 · 3 comments · Fixed by #1359
Closed

Changing to # or b for entire song #1169

beltonk opened this issue May 13, 2024 · 3 comments · Fixed by #1359
Labels

Comments

@beltonk
Copy link

beltonk commented May 13, 2024

Why not a simple way to useModifier() for ChordProParser() object directly?

@beltonk beltonk changed the title Changing # or b to entire song Changing to # or b for entire song May 13, 2024
@martijnversluis
Copy link
Owner

Great feature! Putting this on the board!

@beltonk
Copy link
Author

beltonk commented May 17, 2024

I combined ChordFiddle example into a single function, but would be great to support it natively.

The following is the member function to update modifier for this.song ChordSheetJS.Song() object.

public setFixChordModifier(modifier: Modifier): void {
  let processedSong = this.song.clone();
  processedSong.lines = processedSong.lines.map((line) => {
    const processedLine = line.clone();
    processedLine.items = line.items.map((item) => {
      if (item instanceof ChordSheetJS.ChordLyricsPair && item.chords) {
        let processedChordLyricsPair = item.clone();
        if (item.chords) {
          let parsedChord = Chord.parse(item.chords);               
          if (parsedChord) {
            processedChordLyricsPair.chords = (new Chord(parsedChord).useModifier(modifier)).toString();
            processedChordLyricsPair.chords = processedChordLyricsPair.chords.replace('B#', 'C');
            processedChordLyricsPair.chords = processedChordLyricsPair.chords.replace('Cb', 'B');
            processedChordLyricsPair.chords = processedChordLyricsPair.chords.replace('E#', 'F');
            processedChordLyricsPair.chords = processedChordLyricsPair.chords.replace('Fb', 'E');
            return processedChordLyricsPair;
          }
        } else {
          return processedChordLyricsPair;
        }
      }
      return item;
    });
    return processedLine;
  });
  this.song = processedSong;
}

martijnversluis added a commit that referenced this issue Sep 21, 2024
Allows changing the chord modifier (accidental) for all chords

Resolves #1169
@martijnversluis
Copy link
Owner

Hey @beltonk. I just published 10.3.0, which includes this feature: song.useModifier(modifier).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
Development

Successfully merging a pull request may close this issue.

2 participants