Instrument Editor – Clefs and Notes don't match

I wasn’t too active the last weeks here, so maybe I missed it already being reported, although I did a search and didn’t see anything.

When creating custom instruments in the instrument editor, Dorico places the clef apparently always centered, but the notes do not respect the clef.
In both pictures, I have entered a G, which should be either in the first space in the 4-line staff, or bottom line on the 3-line staff.

It looks to me like the problem is just clef placement, especially because the G clef is centered on a space in the 4-line staff. I thought I saw Daniel mention something about needing work with clefs in the instrument editor, but I can’t find it either, and I don’t have D5 yet.

One of the cool things about the way Dorico is structured, is that it’s really easy to create your own clefs and add them with a doricolib file. Unfortunately, I haven’t found a way yet to create custom key signature arrangements for them yet. As long as you don’t care about key sigs and just want to use these in C or Open key, it’s pretty simple to define them however you want.

  1. Under glyphDefinitions, define the glyph you want to use for a new clef. The codePoint refers to the SMuFL character. You’re going to need to create custom IDs for everything too. If you plan on having clef changes, you’ll likely want to configure the “small” variant too.
  2. Under compositeDefinitions, you’ll define the placement and positioning of the clef. A negative yOffset value moves it up.
  3. Under clefDefinitions you’ll define the clef based on a particular note. Obviously all the IDs will need to match up.

Here’s a doricolib file that creates Treble clefs for 3 and 4-line staves in the Uncommon category. Just unzip and add it to your user DefaultLibraryAdditions folder.
Treble Clefs for 3 and 4-Line Staves.zip (1.0 KB)

clefs

Having a Treble clef define G to be a space looked weird to me, so I defined it to be the 2nd line up in a 4-line staff as it usually is in a 5-line staff. Here are the G definitions as I have them set up, but obviously you can edit the file and change that to be whatever you want:

doricolib file
<?xml version="1.0" encoding="utf-8"?>
<kScoreLibrary>
	<clefDefinitions>
		<entities array="true">
			<ClefEntityDefinition>
				<name>Treble Clef for 3-Line</name>
				<entityID>clef.treble3</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<basicClefType>kGClef</basicClefType>
				<clefTranspositionReminder>0</clefTranspositionReminder>
				<compositeID>comp.3LineGClef</compositeID>
				<clefCategory>kUncommon</clefCategory>
				<clefChangeCompositeID>comp.3LineGClefSmall</clefChangeCompositeID>
				<clefDefinition>
					<isPitched>true</isPitched>
					<requiredNumStaveLines>3</requiredNumStaveLines>
					<staveIndexFromBottomLine>0</staveIndexFromBottomLine>
					<hotSpot>
						<noteName>G</noteName>
						<octave>4</octave>
					</hotSpot>
				</clefDefinition>
			</ClefEntityDefinition>
			<ClefEntityDefinition>
				<name>Treble Clef for 4-Line</name>
				<entityID>clef.treble4</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<basicClefType>kGClef</basicClefType>
				<clefTranspositionReminder>0</clefTranspositionReminder>
				<compositeID>comp.4LineGClef</compositeID>
				<clefCategory>kUncommon</clefCategory>
				<clefChangeCompositeID>comp.4LineGClefSmall</clefChangeCompositeID>
				<clefDefinition>
					<isPitched>true</isPitched>
					<requiredNumStaveLines>4</requiredNumStaveLines>
					<staveIndexFromBottomLine>2</staveIndexFromBottomLine>
					<hotSpot>
						<noteName>G</noteName>
						<octave>4</octave>
					</hotSpot>
				</clefDefinition>
			</ClefEntityDefinition>
		</entities>	
	</clefDefinitions>
	<glyphDefinitions>
		<entities array="true">
			<GlyphPrimitiveEntityDefinition>
				<name>3LineGClef</name>
				<entityID>glyph.3LineGClef</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<codePoint>0xE050</codePoint>
				<isSmufl>true</isSmufl>
				<alternateForGlyph/>
				<fontStyle>font.defaultmusic</fontStyle>
				<pointSize>1</pointSize>
				<rotation>0</rotation>
				<colour>kDefault</colour>
			</GlyphPrimitiveEntityDefinition>
			<GlyphPrimitiveEntityDefinition>
				<name>3LineGClefSmall</name>
				<entityID>glyph.3LineGClefSmall</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<codePoint>0xF472</codePoint>
				<isSmufl>true</isSmufl>
				<alternateForGlyph/>
				<fontStyle>font.defaultmusic</fontStyle>
				<pointSize>1</pointSize>
				<rotation>0</rotation>
				<colour>kDefault</colour>
			</GlyphPrimitiveEntityDefinition>
			<GlyphPrimitiveEntityDefinition>
				<name>4LineGClef</name>
				<entityID>glyph.4LineGClef</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<codePoint>0xE050</codePoint>
				<isSmufl>true</isSmufl>
				<alternateForGlyph/>
				<fontStyle>font.defaultmusic</fontStyle>
				<pointSize>1</pointSize>
				<rotation>0</rotation>
				<colour>kDefault</colour>
			</GlyphPrimitiveEntityDefinition>
			<GlyphPrimitiveEntityDefinition>
				<name>4LineGClefSmall</name>
				<entityID>glyph.4LineGClefSmall</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<codePoint>0xF472</codePoint>
				<isSmufl>true</isSmufl>
				<alternateForGlyph/>
				<fontStyle>font.defaultmusic</fontStyle>
				<pointSize>1</pointSize>
				<rotation>0</rotation>
				<colour>kDefault</colour>
			</GlyphPrimitiveEntityDefinition>
		</entities>
	</glyphDefinitions>
	<compositeDefinitions>
		<entities array="true">
			<CompositeDefinition>
				<name>Treble Clef for 3-Line</name>
				<entityID>comp.3LineGClef</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<category>kClef</category>
				<components array="true">
					<component>
						<componentId>glyph.3LineGClef</componentId>
						<componentType>kGlyph</componentType>
						<xOffset>0</xOffset>
						<yOffset>-5</yOffset>
						<xScale>100.000000</xScale>
						<yScale>100.000000</yScale>
						<zOrder>0</zOrder>
						<maxOpticalScale>100</maxOpticalScale>
						<componentInstance>0</componentInstance>
						<colour>kDefault</colour>
					</component>
				</components>
				<relativeAttachments array="true"/>
				<scalingRules array="true"/>
			</CompositeDefinition>
			<CompositeDefinition>
				<name>Treble Clef for 3-Line (small)</name>
				<entityID>comp.3LineGClefSmall</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<category>kClef</category>
				<components array="true">
					<component>
						<componentId>glyph.3LineGClefSmall</componentId>
						<componentType>kGlyph</componentType>
						<xOffset>0</xOffset>
						<yOffset>-7.5</yOffset>
						<xScale>100.000000</xScale>
						<yScale>100.000000</yScale>
						<zOrder>0</zOrder>
						<maxOpticalScale>100</maxOpticalScale>
						<componentInstance>0</componentInstance>
						<colour>kDefault</colour>
					</component>
				</components>
				<relativeAttachments array="true"/>
				<scalingRules array="true"/>
			</CompositeDefinition>
			<CompositeDefinition>
				<name>Treble Clef for 4-Line</name>
				<entityID>comp.4LineGClef</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<category>kClef</category>
				<components array="true">
					<component>
						<componentId>glyph.4LineGClef</componentId>
						<componentType>kGlyph</componentType>
						<xOffset>0</xOffset>
						<yOffset>-2.5</yOffset>
						<xScale>100.000000</xScale>
						<yScale>100.000000</yScale>
						<zOrder>0</zOrder>
						<maxOpticalScale>100</maxOpticalScale>
						<componentInstance>0</componentInstance>
						<colour>kDefault</colour>
					</component>
				</components>
				<relativeAttachments array="true"/>
				<scalingRules array="true"/>
			</CompositeDefinition>
			<CompositeDefinition>
				<name>Treble Clef for 4-Line (small)</name>
				<entityID>comp.4LineGClefSmall</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<category>kClef</category>
				<components array="true">
					<component>
						<componentId>glyph.4LineGClefSmall</componentId>
						<componentType>kGlyph</componentType>
						<xOffset>0</xOffset>
						<yOffset>-4</yOffset>
						<xScale>100.000000</xScale>
						<yScale>100.000000</yScale>
						<zOrder>0</zOrder>
						<maxOpticalScale>100</maxOpticalScale>
						<componentInstance>0</componentInstance>
						<colour>kDefault</colour>
					</component>
				</components>
				<relativeAttachments array="true"/>
				<scalingRules array="true"/>
			</CompositeDefinition>
		</entities>
	</compositeDefinitions>
</kScoreLibrary>
2 Likes

And here‘s the point I don’t understand. I know that clefs in dorico are defined to a particular note. But in case of the violin clef, it’s quite clear that G is the reference note. Why is it off then?

I’m not really 100% sure how all this works, but I think there are 2 issues at play - how to define the staff lines and how to position the clef.

The ClefEntityDefinition defines the staff lines, so for the 3-line staff, I set the staveIndexFromBottomLine to be 0, and the hotSpot to be G4. That way the very bottom line is defined to be G4 when used with the clef.treble3 clef. The positioning is independent of that definition, so it’s not like the “bullseye” of the treble clef has to be G4, it really can be whatever you want. The yOffset in the CompositeDefinition controls the positioning up and down, but to be honest, getting this right took a bit of trial and error as it wasn’t entirely clear what I was offsetting from.

So the staff decides where the G4 sits and then there is a clef drawn independently, or with relative respect to the staff?

I think that’s basically it. I certainly could be wrong, but I think when you assign a clef to a staff, that tells Dorico how to interpret the notes of that staff with respect to where you have assigned the hotSpot note for that clef. The clef itself is simply a glyph at a position. For the 3LineGClef code I posted, it’s just the glyph that exists at codePoint E050. You can change it to any SMuFL glyph you want and it won’t change the interpretation of the staff. Likewise you can position it vertically however you want and it won’t change the interpretation of the staff. Once you’ve defined how the staff will be interpreted for that clef, the appearance of the clef itself doesn’t matter to how Dorico interprets the notes.

It obviously matters to the musicians that will have to read it though, LOL!

For example, below is the doricolib code for an “Eyeglass Clef,” that works for 3-line staves and defines the middle line in the middle of the lenses to be middle C.

Clefs define the staff interpretation and then are just glyphs at a position. There’s nothing inherently unique about the SMuFL Clefs range. The catch is D5 only knows how to correctly draw key sigs for the factory clef definitions, and if there’s a way around that, I haven’t figured it out yet. If you can figure that one out, please let me know!

Eyeglass Clef doricolib
<?xml version="1.0" encoding="utf-8"?>
<kScoreLibrary>
	<clefDefinitions>
		<entities array="true">
			<ClefEntityDefinition>
				<name>Eyeglass Clef</name>
				<entityID>clef.eyeglass</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<basicClefType>kCClef</basicClefType>
				<clefTranspositionReminder>0</clefTranspositionReminder>
				<compositeID>comp.clefEyeglass</compositeID>
				<clefCategory>kUncommon</clefCategory>
				<clefDefinition>
					<isPitched>true</isPitched>
					<requiredNumStaveLines>3</requiredNumStaveLines>
					<staveIndexFromBottomLine>2</staveIndexFromBottomLine>
					<hotSpot>
						<noteName>C</noteName>
						<octave>4</octave>
					</hotSpot>
				</clefDefinition>
			</ClefEntityDefinition>
		</entities>		
	</clefDefinitions>
	<glyphDefinitions>
		<entities array="true">
			<GlyphPrimitiveEntityDefinition>
				<name>clefEyeglass</name>
				<entityID>glyph.clefEyeglass</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<codePoint>0xEC62</codePoint>
				<isSmufl>true</isSmufl>
				<alternateForGlyph/>
				<fontStyle>font.defaultmusic</fontStyle>
				<pointSize>1</pointSize>
				<rotation>0</rotation>
				<colour>kDefault</colour>
			</GlyphPrimitiveEntityDefinition>
		</entities>
	</glyphDefinitions>
	<compositeDefinitions>
		<entities array="true">
			<CompositeDefinition>
				<name>Eyeglass Clef</name>
				<entityID>comp.clefEyeglass</entityID>
				<parentEntityID/>
				<inheritanceMask>0</inheritanceMask>
				<category>kClef</category>
				<components array="true">
					<component>
						<componentId>glyph.clefEyeglass</componentId>
						<componentType>kGlyph</componentType>
						<xOffset>0</xOffset>
						<yOffset>-1</yOffset>
						<xScale>100.000000</xScale>
						<yScale>100.000000</yScale>
						<zOrder>0</zOrder>
						<maxOpticalScale>100</maxOpticalScale>
						<componentInstance>0</componentInstance>
						<colour>kDefault</colour>
					</component>
				</components>
				<relativeAttachments array="true"/>
				<scalingRules array="true"/>
			</CompositeDefinition>
		</entities>
	</compositeDefinitions>
</kScoreLibrary>
1 Like

This issue seems to be solved:

Positioning on irregular staves. Clefs are now correctly positioned on staves with more or fewer than five staff lines. Pitched staves in Dorico are always built upwards from the bottom staff line, so if you have a pitched instrument with a 1-line staff, the single staff line that appears is the bottom line of the staff; i.e. if you have a treble G clef, the pitch of a note on that single staff line would be E4, or if you have a bass F clef, the pitch of a note on that single staff line would be G2.

1 Like