Permalink
Browse files

Output all voices.

  • Loading branch information...
hanwen committed Aug 8, 2012
1 parent 21f5fa6 commit 47f756bdaed547126b8de074f4c4100b3d9731a9
Showing with 21 additions and 8 deletions.
  1. +18 −4 convert.go
  2. +3 −4 encore/data.go
View
@@ -86,7 +86,7 @@ func Convert(data *encore.Data) {
for _, m := range data.Measures {
for _, e := range m.Elems {
key := idKey{
- staff: e.GetStaff(),
+ staff: int(e.StaffIdx),
voice: e.Voice(),
}
staves[key] = append(staves[key], e)
@@ -97,7 +97,7 @@ func Convert(data *encore.Data) {
sortedKeys = append(sortedKeys, k)
}
sort.Sort(sortedKeys)
- staffVoiceMap := make([][]idKey, len(data.Staff))
+ staffVoiceMap := make(map[int][]idKey, len(data.Staff))
for _, k := range sortedKeys {
elems := staves[k]
sort.Sort(elemSequence(elems))
@@ -106,8 +106,14 @@ func Convert(data *encore.Data) {
staffVoiceMap[k.staff] = append(staffVoiceMap[k.staff], k)
}
+ sortedStaves := []int{}
+ for k := range staffVoiceMap {
+ sortedStaves = append(sortedStaves, k)
+ }
+ sort.Ints(sortedStaves)
fmt.Printf("<<\n")
- for _, voices := range staffVoiceMap {
+ for _, k := range sortedStaves {
+ voices := staffVoiceMap[k]
fmt.Printf(" \\new Staff << \n")
for _, voice := range voices {
fmt.Printf(" \\new Voice \\%s\n", voice.String())
@@ -182,7 +188,15 @@ func convertRest(n *encore.Rest) (dur lily.Duration) {
}
func Int2Letter(a int) string {
- return string(byte(a) + 'A')
+ k := ""
+ for a != 0 {
+ k = k + string(byte(a&0xf) + 'A')
+ a >>= 4
+ }
+ if k == "" {
+ k = "A"
+ }
+ return k
}
func convertNote(n *encore.Note, baseStep lily.Pitch) (pit lily.Pitch, dur lily.Duration) {
View
@@ -105,11 +105,10 @@ type Staff struct {
// 6=F_8
Clef byte `offset:"172"`
- // 181 = 1 for piano staff. ?
+ // Other candidates: 169, 170, 177
+ PianoStaff byte `offset:"181"`
- // 180 - 187: MIDI channel (repeated?)
- // 188 - 195: MIDI program (repeated?)
- // 196 - 203: MIDI volume (repeated?)
+ // 188 - 212: MIDI channel (repeated?), MIDI program (repeated?), MIDI volume (repeated?)
// 164 ?

0 comments on commit 47f756b

Please sign in to comment.