Skip to content

Commit

Permalink
Clef.
Browse files Browse the repository at this point in the history
  • Loading branch information
hanwen committed Aug 6, 2012
1 parent 4e0853b commit df8b6e6
Show file tree
Hide file tree
Showing 2 changed files with 31 additions and 1 deletion.
24 changes: 23 additions & 1 deletion convert.go
Expand Up @@ -94,6 +94,26 @@ func Convert(data *encore.Data) {
fmt.Printf(">>\n")
}

func ConvertClef(key byte) *lily.Clef {
s := ""
switch key {
case 0:
s = "G"
case 1:
s = "F"
case 2:
s = "C"
case 3:
s = "tenor"
case 4:
s = "G^8"
case 5:
s = "G_8"
}

return &lily.Clef{Name: s}
}

func ConvertKey(key byte) *lily.KeySignature {
names := []string{
"c", "f", "bes",
Expand Down Expand Up @@ -207,7 +227,9 @@ func ConvertStaff(elems []*encore.MeasElem) lily.Elem {
}
if i == 0 {
seq.Elems = append(seq.Elems,
ConvertKey(e.LineStaffData.Key))
ConvertKey(e.LineStaffData.Key),
ConvertClef(e.LineStaffData.Clef),
)
}

if i > 0 && nextTick < e.AbsTick() {
Expand Down
8 changes: 8 additions & 0 deletions lily/data.go
Expand Up @@ -195,3 +195,11 @@ type KeySignature struct {
func (k *KeySignature) String() string {
return fmt.Sprintf("\\key %s \\%s", k.Name, k.ScaleType)
}

type Clef struct {
Name string
}

func (c *Clef) String() string {
return fmt.Sprintf("\\clef \"%s\"", c.Name)
}

0 comments on commit df8b6e6

Please sign in to comment.