MCPcopy Create free account
hub / github.com/OpenTTD/OpenTTD / TransmitNotesOff

Function TransmitNotesOff

src/music/dmusic.cpp:555–574  ·  view source on GitHub ↗

Transmit 'Note off' messages to all MIDI channels. */

Source from the content-addressed store, hash-verified

553
554/** Transmit 'Note off' messages to all MIDI channels. */
555static void TransmitNotesOff(IDirectMusicBuffer *buffer, REFERENCE_TIME block_time, REFERENCE_TIME cur_time)
556{
557 for (int ch = 0; ch < 16; ch++) {
558 TransmitChannelMsg(buffer, block_time + 10, MIDIST_CONTROLLER | ch, MIDICT_MODE_ALLNOTESOFF, 0);
559 TransmitChannelMsg(buffer, block_time + 10, MIDIST_CONTROLLER | ch, MIDICT_SUSTAINSW, 0);
560 TransmitChannelMsg(buffer, block_time + 10, MIDIST_CONTROLLER | ch, MIDICT_MODE_RESETALLCTRL, 0);
561 }
562
563 /* Performing a GM reset stops all sound and resets all parameters. */
564 TransmitStandardSysex(buffer, block_time + 20, MidiSysexMessage::ResetGM);
565 TransmitStandardSysex(buffer, block_time + 30, MidiSysexMessage::RolandSetReverb);
566
567 /* Explicitly flush buffer to make sure the messages are processed,
568 * as we want sound to stop immediately. */
569 _port->PlayBuffer(buffer);
570 buffer->Flush();
571
572 /* Wait until message time has passed. */
573 Sleep(Clamp((block_time - cur_time) / MS_TO_REFTIME, 5, 1000));
574}
575
576static void MidiThreadProc()
577{

Callers 1

MidiThreadProcFunction · 0.85

Calls 4

ClampFunction · 0.85
TransmitChannelMsgFunction · 0.70
TransmitStandardSysexFunction · 0.70
FlushMethod · 0.45

Tested by

no test coverage detected