MCPcopy Create free account
hub / github.com/bspaans/python-mingus / sendNote

Method sendNote

mingus/midi/win32midi.py:69–91  ·  view source on GitHub ↗
(
        self, pitch, duration=1.0, channel=1, volume=60
    )

Source from the content-addressed store, hash-verified

67 raise Win32MidiException("Error closing device")
68
69 def sendNote(
70 self, pitch, duration=1.0, channel=1, volume=60
71 ): # duration in seconds
72 midimsg = 0x90 + ((pitch) * 0x100) + (volume * 0x10000) + channel
73 mm = c_int(midimsg)
74 rc = self.winmm.midiOutShortMsg(self.hmidi, mm)
75 if rc != 0:
76 raise Win32MidiException(
77 "Error opening device, "
78 + self.midiOutShortErrorCodes.get(rc, "Unknown error.")
79 )
80
81 time.sleep(duration)
82
83 # turn it off
84 midimsg = 0x80 + ((pitch) * 0x100) + channel
85 mm = c_int(midimsg)
86 rc = self.winmm.midiOutShortMsg(self.hmidi, mm)
87 if rc != 0:
88 raise Win32MidiException(
89 "Error sending event, "
90 + self.midiOutShortErrorCodes.get(rc, "Unknown error.")
91 )
92
93 def rawNoteOn(self, pitch, channel=1, v=60):
94 midimsg = 0x90 + ((pitch) * 0x100) + (v * 0x10000) + channel

Callers

nothing calls this directly

Calls 2

Win32MidiExceptionClass · 0.85
sleepMethod · 0.45

Tested by

no test coverage detected