Skip to main content
Glama
emicklei

melrōse musical expression player

by emicklei
notes_view.go1.21 kB
package img import ( "github.com/emicklei/melrose/core" "github.com/fogleman/gg" ) type NotesView struct { Events []core.NoteEvent BPM float64 // TODO BIAB } // gc 0,0 is top-left func (v NotesView) DrawOn(gc *gg.Context) { if len(v.Events) == 0 || v.BPM == 0 { return } stats := core.NoteStatistics(v.Events) bottom := float64(gc.Height()) xscale := float64(gc.Width()) / float64(stats.End.Sub(stats.Start).Milliseconds()) yscale := float64(gc.Height()) / float64(stats.Highest-stats.Lowest+1) quarter := (core.WholeNoteDuration(v.BPM) / 4.0).Milliseconds() bar := 0 for x := 0.0; x < float64(gc.Width()); x += float64(quarter) * xscale { if bar == 4 { gc.SetRGB(200/256.0, 0.0, 0.0) // redisch bar = 0 } else { gc.SetRGB(200/256.0, 200/256.0, 200/256.0) // grayish } gc.DrawLine(x, 0, x, float64(gc.Height())) gc.Stroke() bar++ } gc.SetRGB(62/256.0, 161/256.0, 11/256.0) // greenish for _, each := range v.Events { xs := float64(each.Start.Sub(stats.Start).Milliseconds()) * xscale xe := float64(each.End.Sub(stats.Start).Milliseconds()) * xscale gc.DrawRectangle(xs, bottom-(float64(each.Number-stats.Lowest+1)*yscale), xe-xs, yscale) gc.Fill() } }

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