Skip to main content
Glama
emicklei

melrōse musical expression player

by emicklei
play_test.go1.6 kB
package midi import ( "math" "testing" "time" "github.com/emicklei/melrose/core" ) func TestDurations(t *testing.T) { for _, bpm := range []float64{60, 120, 240, 300} { t.Log("bpm", bpm) wholeNoteDuration := time.Duration(int(math.Round(4*60*1000/bpm))) * time.Millisecond t.Log("whole", wholeNoteDuration) s := core.S("1C 2C 4C 8C 16C") s.NotesDo(func(each core.Note) { actualDuration := time.Duration(float32(wholeNoteDuration) * each.DurationFactor()) t.Log(each.String(), actualDuration) }) t.Log("-----") } } func TestEventNoteOff(t *testing.T) { on := midiEvent{onoff: noteOn} off := on.asNoteoff() if got, want := on.onoff, noteOn; got != want { t.Errorf("got [%v] want [%v]", got, want) } if got, want := off.onoff, noteOff; got != want { t.Errorf("got [%v] want [%v]", got, want) } } func Test_canCombineEvent(t *testing.T) { type args struct { notes []core.Note } tests := []struct { name string args args want bool }{ {"one", args{[]core.Note{core.MustParseNote("c")}}, true}, {"cd", args{[]core.Note{core.MustParseNote("c"), core.MustParseNote("d")}}, true}, {"cd+", args{[]core.Note{core.MustParseNote("c"), core.MustParseNote("d+")}}, false}, {"cd+", args{[]core.Note{core.MustParseNote(".c"), core.MustParseNote("d")}}, false}, {"cd+", args{[]core.Note{core.MustParseNote(".c#-"), core.MustParseNote(".d-")}}, true}, } for _, tt := range tests { t.Run(tt.name, func(t *testing.T) { if got := canCombineEvent(tt.args.notes); got != tt.want { t.Errorf("canCombineEvent() = %v, want %v", got, tt.want) } }) } }

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/emicklei/melrose'

If you have feedback or need assistance with the MCP directory API, please join our Discord server