func TestAddToPosition(t *testing.T) { p := Position(rational.New(1, 2)) d := Duration(rational.New(1, 4)) if p.Add(d) != Position(rational.New(3, 4)) { t.Errorf("Incorrect value for Add on Position") } }
func TestAddToDuration(t *testing.T) { a := Duration(rational.New(1, 2)) b := Duration(rational.New(1, 4)) if a.Add(b) != Duration(rational.New(3, 4)) { t.Errorf("Incorrect value for Add on Duration") } }
func NewDuration(a, b int) Duration { return Duration(rational.New(a, b)) }
func (t TimeSignature) DurationOfBar() Duration { return Duration(rational.Scale(rational.New(t.upper, 1), t.lower)) }
func Signature(upper, lower int) TimeSignature { return TimeSignature{upper, rational.New(1, lower)} }
func NewPosition(a, b int) Position { return Position(rational.New(a, b)) }