1/* 2 3MidiDelay.cpp 4 5Copyright (c) 2002 OpenBeOS. 6 7A filter for Midi Kit 1 that sprays midi events 8when the performance time is reached. 9 10Author: 11 Michael Pfeiffer 12 13Permission is hereby granted, free of charge, to any person obtaining a copy of 14this software and associated documentation files (the "Software"), to deal in 15the Software without restriction, including without limitation the rights to 16use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies 17of the Software, and to permit persons to whom the Software is furnished to do 18so, subject to the following conditions: 19 20The above copyright notice and this permission notice shall be included in all 21copies or substantial portions of the Software. 22 23THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 24IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 25FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 26AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 27LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 28OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN 29THE SOFTWARE. 30 31*/ 32 33#include <OS.h> 34 35#include "MidiDelay.h" 36 37void MidiDelay::NoteOff(uchar channel, 38 uchar note, 39 uchar velocity, 40 uint32 time = B_NOW) { 41 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 42 SprayNoteOff(channel, note, velocity, time); 43} 44 45void MidiDelay::NoteOn(uchar channel, 46 uchar note, 47 uchar velocity, 48 uint32 time = B_NOW) { 49 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 50 SprayNoteOn(channel, note, velocity, time); 51} 52 53 54void MidiDelay::KeyPressure(uchar channel, 55 uchar note, 56 uchar pressure, 57 uint32 time = B_NOW) { 58 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 59 SprayKeyPressure(channel, note, pressure, time); 60} 61 62 63void MidiDelay::ControlChange(uchar channel, 64 uchar controlNumber, 65 uchar controlValue, 66 uint32 time = B_NOW) { 67 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 68 SprayControlChange(channel, controlNumber, controlValue, time); 69} 70 71 72void MidiDelay::ProgramChange(uchar channel, 73 uchar programNumber, 74 uint32 time = B_NOW) { 75 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 76 SprayProgramChange(channel, programNumber, time); 77} 78 79 80void MidiDelay::ChannelPressure(uchar channel, 81 uchar pressure, 82 uint32 time = B_NOW) { 83 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 84 SprayChannelPressure(channel, pressure, time); 85} 86 87 88void MidiDelay::PitchBend(uchar channel, 89 uchar lsb, 90 uchar msb, 91 uint32 time = B_NOW) { 92 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 93 SprayPitchBend(channel, lsb, msb, time); 94} 95 96 97void MidiDelay::SystemExclusive(void* data, 98 size_t dataLength, 99 uint32 time = B_NOW) { 100 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 101 SpraySystemExclusive(data, dataLength, time); 102} 103 104 105void MidiDelay::SystemCommon(uchar statusByte, 106 uchar data1, 107 uchar data2, 108 uint32 time = B_NOW) { 109 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 110 SpraySystemCommon(statusByte, data1, data2, time); 111} 112 113 114void MidiDelay::SystemRealTime(uchar statusByte, uint32 time = B_NOW) { 115 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 116 SpraySystemRealTime(statusByte, time); 117} 118 119 120void MidiDelay::TempoChange(int32 bpm, uint32 time = B_NOW) { 121 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 122 SprayTempoChange(bpm, time); 123} 124 125 126void MidiDelay::AllNotesOff(bool justChannel = true, uint32 time = B_NOW) { 127 snooze_until(ToBigtime(time), B_SYSTEM_TIMEBASE); 128 for (uchar channel = 0; channel < 16; channel ++) { 129 SprayControlChange(channel, B_ALL_NOTES_OFF, 0, time); 130 } 131} 132 133