Skip to content

Conversation

@rettinghaus
Copy link
Contributor

This fixes the export of clefs:

  • remove the incorrect clef-octave-change (adding missing transpose information instead)
  • add after-barline attribute
  • use correct sign for c clefs

Other changes just small formatting improvements.

else if(clef == TGMeasure.CLEF_TREBLE){
this.addNode(node, "sign", "G");
this.addNode(node, "line", "2");
this.addNode(node, "clef-octave-change", String.valueOf(-1));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the original implementation is correct.
TuxGuitar is dedicated to guitar, and guitar is a transposing instrument, using a key 1 octave below the standard one (same for bass guitar).
Where TuxGuitar is wrong: it uses this convention silently, and doesn't display an explicit "8" below the clefs (as musescore does: just create an empty guitar track, the "8" is correctly shown)
If I'm not wrong, Musescore 4.5.1 uses the same "clef-octave-change" musicxml node.

See screenshots.
left : TuxGuitar
right: exported by TG1.6.6 in musicxml, and imported by musescore 4.5.1 (correct)

f_tg f_tg166_mu

After applying your PR, and exporting to musicxml, this is how it appears in musescore (incorrect):

f_mu

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We cannot use ottava clefs in export, because a) these are not the clefs TuxGuitar is using, and b) that wouldn't work with the c clefs (wich are not exported correctly currently).

grafik

Correct, guitar is a transposing instrument, but that wasn't shown in the export. The shown pitch is for both clefs the same, even if the old implementation showed the note on the "correct line".
The transposition information in this PR is now correct, but I need to adjust the pitch for the score staff.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK. Thanks for your contributions, I must admit I don't have a good knowledge of musicXML data structure.

@guiv42
Copy link
Collaborator

guiv42 commented Apr 10, 2025

I'm sorry but I think I still need some explanations.
See the screenshot below, done after your last commit (317973b). It's the same test as above, just a F on 1st fret, 1st string. Exported by TuxGuitar in musicXML, then imported by MuseScore 4.5.1:
20250410_222335

The note appears on the correct line in the score, however the representation of the clef omits the explicit "8" below the clef (it appears correctly before the PR). Why remove the "clef-octave-change" musicxml node?
And the tablature part is incorrect (not the right string nor fret)

@guiv42
Copy link
Collaborator

guiv42 commented Apr 11, 2025

It looks like a conflict of octave numbering convention. TuxGuitar uses midi convention, so A4=440Hz.
And 440Hz = 1st string 5th fret in standard tuning. See #37. It looks like Musescore uses the same convention for musicXML

@rettinghaus
Copy link
Contributor Author

The MuseScore import is not correct, it cannot handle different transpositions in one part (yet).

A violin clef marks the G4 on the second line, the 8 below the clef changes the written octave, so then it marks the G3. https://www.dacapoalcoda.com/octaves-clefs. The guitar is a transposing instrument sounding one ocatve lower than written, i.e. this would the sound like G2. MIDI does not know about about transposing instruments, but refelcts the sounding pitch.

@guiv42
Copy link
Collaborator

guiv42 commented Apr 11, 2025

Let me take one step back (I'm trying to understand).
Say I want to play one A 440Hz on a standard tuned guitar. What should it look like in musicXML, I don't know!
So, I tried an empiric approach: I exported this test song with TuxGuitar 1.6.6 and latest commit of this PR, then I opened the produced musicxml files with available viewers:

Viewer TuxGuitar 1.6.6 commit 181530b
MuseScore 4.5.1 musescore451 musescore451
soundslice.com soundslice soundslice
opensheetmusicdisplay.org opensheetmusicdisplay opensheetmusicdisplay

My conclusions:

  • I'm still confused!
  • the only 100% correct configuration is TG1.6.6 + MuseScore 4.5.1
  • on the 2 web viewers it clearly looks better after commit 181530b, only the "8" is missing

@rettinghaus, two questions:

  1. if MuseScore is incorrect, could you eventually create an issue in MuseScore's repo?
  2. why not add the <clef-octave-change> musicxml node? The handcrafted musicxml file attached below is displayed correctly by the 2 websites and MuseScore:
    A440_test.musicxml.zip
    musixml file exported by current master branch (e8fd592) is also displayed correctly.

I may be wrong, but I have the impression that the only problem is the way TuxGuitar draws the clefs, omitting the -1 octave indication (applied implicitly)

@rettinghaus
Copy link
Contributor Author

As said before, clef-octave-change changes the octave of the written notes, not their resulting sounding pitch. It's something different than transposition.

But this needs some more work. I'll open an issue on MuseScore side.

@rettinghaus rettinghaus marked this pull request as draft April 17, 2025 10:46
@guiv42
Copy link
Collaborator

guiv42 commented Apr 17, 2025

Sorry but I still don't understand. Naively I would assume that the pitch is independent from the content of <clef> node, and only defined by:

                <pitch>
                    <step>A</step>
                    <octave>5</octave>
                </pitch>

@rettinghaus
Copy link
Contributor Author

The pitch node gives the notated pitch, the sounding pitch is dependent on the information given in the transposition node (if existend).

The display of the written pitch is then calculated for the given clef, which depends on it's form, the line it sits on and the given clef-octave-change.

@guiv42
Copy link
Collaborator

guiv42 commented Apr 19, 2025

OK, that's more clear!
Up to now, I first focused on the basic musicXML syntax, then on the graphical rendering. But I never thought about the audio it would produce.
Thanks for the clarification.

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

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants