Skip to content
Browse files

Robustness against illegal alteration.

  • Loading branch information...
1 parent 5f0cfc2 commit d10a20f087d18fdbf76997a9295d4b1ff491b491 @hanwen committed Aug 8, 2012
Showing with 7 additions and 2 deletions.
  1. +7 −2 lily/data.go
View
9 lily/data.go
@@ -86,9 +86,14 @@ func (p *Pitch) Normalize() {
func (p *Pitch) String() string {
names := []string{"c", "d", "e", "f", "g", "a", "b"}
altsuffix := []string{"eses", "es", "", "is", "isis"}
-
+ alt := p.Alteration
+ if alt < -2 || alt > 2 {
+ log.Printf("illegal alteration %d", alt)
+ alt = 0
+ }
n := names[p.Notename]
- n += altsuffix[p.Alteration+2]
+
+ n += altsuffix[alt+2]
if p.Octave < 0 {
for i := -1; i > p.Octave; i-- {
n += ","

0 comments on commit d10a20f

Please sign in to comment.
Something went wrong with that request. Please try again.