func (l *mListener) safeRemove(lis core.NoteListener) {
	without := []core.NoteListener{}
	for _, each := range l.noteListeners {
		if each != lis {
			without = append(without, each)
		}
	}
	l.noteListeners = without
}
safeRemove require acquired lock
package transport
import (
	"sync"
	"time"
	"github.com/emicklei/melrose/core"
)
type mNoteEvent struct {
	note core.Note
	when time.Time
}
type mListener struct {
	mutex *sync.RWMutex
	listening     bool
	noteOn        map[int]mNoteEvent
	noteListeners []core.NoteListener
	keyListeners  map[int]core.NoteListener
}
func newMListener() *mListener {
	return &mListener{
		mutex:         new(sync.RWMutex),
		listening:     false,
		noteOn:        map[int]mNoteEvent{},
		noteListeners: []core.NoteListener{},
		keyListeners:  map[int]core.NoteListener{},
	}
}
func (l *mListener) Add(lis core.NoteListener) {
	l.mutex.Lock()
	defer l.mutex.Unlock()
	l.noteListeners = append(l.noteListeners, lis)
}
func (l *mListener) Remove(lis core.NoteListener) {
	l.mutex.Lock()
	defer l.mutex.Unlock()
	l.safeRemove(lis)
}