Skip to main content
Glama
emicklei

melrōse musical expression player

by emicklei
beatschedule.go1.1 kB
package core import ( "sync" "time" ) // BeatSchedule holds mapping between beat counts and an action (function). type BeatSchedule struct { mutex *sync.RWMutex entries map[int64][]BeatAction } type BeatAction func(when time.Time) func NewBeatSchedule() *BeatSchedule { return &BeatSchedule{ mutex: new(sync.RWMutex), entries: map[int64][]BeatAction{}, } } func (s *BeatSchedule) IsEmpty() bool { s.mutex.RLock() defer s.mutex.RUnlock() return len(s.entries) == 0 } func (s *BeatSchedule) Reset() { s.mutex.Lock() defer s.mutex.Unlock() s.entries = map[int64][]BeatAction{} } func (s *BeatSchedule) Schedule(beat int64, action BeatAction) { s.mutex.Lock() defer s.mutex.Unlock() actions, ok := s.entries[beat] if ok { actions = append(actions, action) } else { actions = []BeatAction{action} } s.entries[beat] = actions } var noActions = []BeatAction{} func (s *BeatSchedule) Unschedule(beat int64) []BeatAction { s.mutex.Lock() defer s.mutex.Unlock() actions, ok := s.entries[beat] if !ok { return noActions } delete(s.entries, beat) return actions }

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