コード例 #1
0
ファイル: midi_cgo.go プロジェクト: lamproae/sigourney
func midiLoop(s *portmidi.Stream) {
	noteOn := make([]int64, 0, 128)
	for e := range s.Listen() {
		switch e.Status {
		case 144: // note on
			on := false
			for _, n := range noteOn {
				if n == e.Data1 {
					on = true
				}
			}
			if !on {
				noteOn = append(noteOn, e.Data1)
			}
			atomic.StoreInt64(&midiNote, e.Data1)
			atomic.StoreInt64(&midiGate, 1)
		case 128: // note off
			for i, n := range noteOn {
				if n == e.Data1 {
					copy(noteOn[i:], noteOn[i+1:])
					noteOn = noteOn[:len(noteOn)-1]
				}
			}
			if len(noteOn) > 0 {
				n := noteOn[len(noteOn)-1]
				atomic.StoreInt64(&midiNote, n)
			} else {
				atomic.StoreInt64(&midiGate, 0)
			}
		}
	}
}
コード例 #2
0
ファイル: midi.go プロジェクト: rakyll/sigourney
func midiLoop(s *portmidi.Stream) {
	var n int64
	for e := range s.Listen() {
		switch e.Status {
		case 144: // note on
			n = e.Data1
			atomic.StoreInt64(&midiNote, n)
			atomic.StoreInt64(&midiGate, 1)
		case 128: // note off
			if e.Data1 == n {
				atomic.StoreInt64(&midiGate, 0)
			}
		}
	}
}
コード例 #3
0
ファイル: gotar-hero.go プロジェクト: rbino/gotar-hero
func AllNotesOff(stream *portmidi.Stream) {
	stream.WriteShort(0xB0|(midiChan-1), 0x7B, 0x00)
	playing = -1
}
コード例 #4
0
ファイル: gotar-hero.go プロジェクト: rbino/gotar-hero
func NoteOff(stream *portmidi.Stream, note int64, velocity int64) {
	stream.WriteShort(0x80|(midiChan-1), note, velocity)
	playing = -1
}
コード例 #5
0
ファイル: gotar-hero.go プロジェクト: rbino/gotar-hero
func NoteOn(stream *portmidi.Stream, note int64, velocity int64) {
	playing = note
	stream.WriteShort(0x90|(midiChan-1), note, velocity)
}