52 const float pitchbendRange)
noexcept
55 wassert (std::abs (pitchbend) <= pitchbendRange);
57 return static_cast<uint16> (pitchbend > 0.0f
58 ?
jmap (pitchbend, 0.0f, pitchbendRange, 8192.0f, 16383.0f)
59 :
jmap (pitchbend, -pitchbendRange, 0.0f, 0.0f, 8192.0f));
72 if (++numBytesUsed > 6)
75 v = (
v << 7) + (
i & 0x7f);
85 wassert (firstByte >= 0x80 && firstByte != 0xf0 && firstByte != 0xf7);
87 static const char messageLengths[] =
89 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
90 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
91 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
92 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
93 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
94 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2, 2,
95 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3, 3,
96 1, 2, 3, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1
99 return messageLengths [firstByte & 0x7f];
169 double t,
bool sysexHasEmbeddedLength)
172 const uint8* src =
static_cast<const uint8*
> (srcData);
173 unsigned int byte = (
unsigned int) *src;
177 byte = (
unsigned int) (
uint8) lastStatusByte;
192 bool haveReadAllLengthBytes = ! sysexHasEmbeddedLength;
193 int numVariableLengthSysexBytes = 0;
205 if (haveReadAllLengthBytes)
208 ++numVariableLengthSysexBytes;
210 else if (! haveReadAllLengthBytes)
212 haveReadAllLengthBytes =
true;
213 ++numVariableLengthSysexBytes;
219 src += numVariableLengthSysexBytes;
223 *dest = (
uint8)
byte;
226 numBytesUsed += numVariableLengthSysexBytes;
228 else if (
byte == 0xff)
235 *dest = (
uint8)
byte;
252 numBytesUsed +=
size;
299 uint8*
d =
static_cast<uint8*
> (std::malloc ((
size_t) bytes));
311 if ((
data[0] & 0xf0) != 0xf0)
312 return (
data[0] & 0xf) + 1;
319 wassert (channel > 0 && channel <= 16);
323 return ((
data[0] & 0xf) == channel - 1)
324 && ((
data[0] & 0xf0) != 0xf0);
329 wassert (channel > 0 && channel <= 16);
335 | (
uint8)(channel - 1));
342 return ((
data[0] & 0xf0) == 0x90)
343 && (returnTrueForVelocity0 ||
data[2] != 0);
350 return ((
data[0] & 0xf0) == 0x80)
351 || (returnTrueForNoteOnVelocity0 && (
data[2] == 0) && ((
data[0] & 0xf0) == 0x90));
358 const int d =
data[0] & 0xf0;
359 return (
d == 0x90) || (
d == 0x80);
403 return (
getData()[0] & 0xf0) == 0xa0;
414 const int aftertouchValue)
noexcept
416 wassert (channel > 0 && channel <= 16);
422 aftertouchValue & 0x7f);
427 return (
getData()[0] & 0xf0) == 0xd0;
438 wassert (channel > 0 && channel <= 16);
456 return (
getData()[0] & 0xf0) == 0xc0;
467 wassert (channel > 0 && channel <= 16);
474 return (
getData()[0] & 0xf0) == 0xe0;
486 wassert (channel > 0 && channel <= 16);
490 position & 127, (position >> 7) & 127);
495 return (
getData()[0] & 0xf0) == 0xb0;
501 return (
data[0] & 0xf0) == 0xb0 &&
data[1] == controllerType;
519 wassert (channel > 0 && channel <= 16);
522 controllerType & 127,
value & 127);
527 wassert (channel > 0 && channel <= 16);
541 wassert (channel > 0 && channel <= 16);
555 wassert (channel > 0 && channel <= 16);
569 return (
data[0] & 0xf0) == 0xb0 &&
data[1] == 123;
580 return (
data[0] & 0xf0) == 0xb0 &&
data[1] == 120;
592 const uint8 buf[] = { 0xf0, 0x7f, 0x7f, 0x04, 0x01,
593 (
uint8) (vol & 0x7f),
612 memcpy (
m + 1, sysexData, (
size_t) dataSize);
613 m[dataSize + 1] = 0xf7;
635 return *
data != 0xff ? -1 :
data[1];
676 return (((
unsigned int)
d[0] << 16)
677 | ((
unsigned int)
d[1] << 8)
687 return 0.5 / timeFormat;
693 const int frameCode = (-timeFormat) >> 8;
694 double framesPerSecond;
698 case 24: framesPerSecond = 24.0;
break;
699 case 25: framesPerSecond = 25.0;
break;
700 case 29: framesPerSecond = 29.97;
break;
701 case 30: framesPerSecond = 30.0;
break;
702 default: framesPerSecond = 30.0;
break;
705 return (1.0 / framesPerSecond) / (timeFormat & 0xff);
711 const uint8 d[] = { 0xff, 81, 3,
712 (
uint8) (microsecondsPerQuarterNote >> 16),
713 (
uint8) (microsecondsPerQuarterNote >> 8),
714 (
uint8) microsecondsPerQuarterNote };
731 denominator = 1 <<
d[1];
745 while (
n < denominator)
751 const uint8 d[] = { 0xff, 0x58, 0x04, (
uint8) numerator, (
uint8) powerOfTwo, 1, 96 };
778 wassert (numberOfSharpsOrFlats >= -7 && numberOfSharpsOrFlats <= 7);
780 const uint8 d[] = { 0xff, 0x59, 0x02, (
uint8) numberOfSharpsOrFlats, isMinorKey ? (
uint8) 1 : (
uint8) 0 };
791 positionInMidiBeats & 127,
792 (positionInMidiBeats >> 7) & 127);
820 return data[0] == 0xf0
834 hours =
data[5] & 0x1f;
841 const int seconds,
const int frames,
844 const uint8 d[] = { 0xf0, 0x7f, 0x7f, 0x01, 0x01,
845 (
uint8) ((hours & 0x01f) | (timecodeType << 5)),
857 return data[0] == 0xf0
872 const uint8 d[] = { 0xf0, 0x7f, 0, 6, (
uint8) command, 0xf7 };
889 hours =
data[7] % 24;
902 const uint8 d[] = { 0xf0, 0x7f, 0, 6, 0x44, 6, 1,
915 return frequencyOfA * pow (2.0, (noteNumber - 69) / 12.0);
920 return ((1 << (noteNumber % 12)) & 0x054a) != 0;
#define CARLA_SAFE_ASSERT_RETURN(cond, ret)
Definition CarlaDefines.h:190
#define noexcept
Definition DistrhoDefines.h:72
CAdPlugDatabase::CRecord::RecordType type
Definition adplugdb.cpp:93
Definition HeapBlock.h:77
bool isNoteOnOrOff() const noexcept
Definition MidiMessage.cpp:354
bool isSongPositionPointer() const noexcept
Definition MidiMessage.cpp:785
bool isForChannel(int channelNumber) const noexcept
Definition MidiMessage.cpp:317
static double getMidiNoteInHertz(int noteNumber, double frequencyOfA=440.0) noexcept
Definition MidiMessage.cpp:913
bool isSostenutoPedalOff() const noexcept
Definition MidiMessage.cpp:448
int getKeySignatureNumberOfSharpsOrFlats() const noexcept
Definition MidiMessage.cpp:766
static MidiMessage midiMachineControlGoto(int hours, int minutes, int seconds, int frames)
Definition MidiMessage.cpp:900
bool isProgramChange() const noexcept
Definition MidiMessage.cpp:454
void getTimeSignatureInfo(int &numerator, int &denominator) const noexcept
Definition MidiMessage.cpp:725
const uint8 * getSysExData() const noexcept
Definition MidiMessage.cpp:618
static MidiMessage allControllersOff(int channel) noexcept
Definition MidiMessage.cpp:583
bool isMetaEvent() const noexcept
Definition MidiMessage.cpp:629
static MidiMessage createSysExMessage(const void *sysexData, int dataSize)
Definition MidiMessage.cpp:606
bool isAftertouch() const noexcept
Definition MidiMessage.cpp:401
bool isMidiMachineControlGoto(int &hours, int &minutes, int &seconds, int &frames) const noexcept
Definition MidiMessage.cpp:878
static MidiMessage noteOn(int channel, int noteNumber, float velocity) noexcept
Definition MidiMessage.cpp:534
static MidiMessage aftertouchChange(int channel, int noteNumber, int aftertouchAmount) noexcept
Definition MidiMessage.cpp:412
int getMidiChannelMetaEventChannel() const noexcept
Definition MidiMessage.cpp:663
bool isAllSoundOff() const noexcept
Definition MidiMessage.cpp:577
MidiMessage(int byte1, int byte2, int byte3, double timeStamp=0) noexcept
Definition MidiMessage.cpp:139
void setChannel(int newChannelNumber) noexcept
Definition MidiMessage.cpp:327
static MidiMessage midiStart() noexcept
Definition MidiMessage.cpp:796
static MidiMessage midiContinue() noexcept
Definition MidiMessage.cpp:799
bool isSostenutoPedalOn() const noexcept
Definition MidiMessage.cpp:447
bool isFullFrame() const noexcept
Definition MidiMessage.cpp:816
float getFloatVelocity() const noexcept
Definition MidiMessage.cpp:381
MidiMessage & operator=(const MidiMessage &other)
Definition MidiMessage.cpp:261
static MidiMessage noteOff(int channel, int noteNumber, float velocity) noexcept
Definition MidiMessage.cpp:548
static MidiMessage songPositionPointer(int positionInMidiBeats) noexcept
Definition MidiMessage.cpp:788
static MidiMessage allSoundOff(int channel) noexcept
Definition MidiMessage.cpp:572
static uint8 floatValueToMidiByte(float valueBetween0and1) noexcept
Definition MidiMessage.cpp:46
double timeStamp
Definition MidiMessage.h:844
static uint16 pitchbendToPitchwheelPos(float pitchbendInSemitones, float pitchbendRangeInSemitones) noexcept
Definition MidiMessage.cpp:51
MidiMachineControlCommand
Definition MidiMessage.h:743
bool isTimeSignatureMetaEvent() const noexcept
Definition MidiMessage.cpp:719
bool isActiveSense() const noexcept
Definition MidiMessage.cpp:630
bool isTempoMetaEvent() const noexcept
Definition MidiMessage.cpp:660
int getControllerNumber() const noexcept
Definition MidiMessage.cpp:504
bool isKeySignatureMajorKey() const noexcept
Definition MidiMessage.cpp:771
bool isMidiStart() const noexcept
Definition MidiMessage.cpp:795
static MidiMessage controllerEvent(int channel, int controllerType, int value) noexcept
Definition MidiMessage.cpp:516
uint8 * getData() noexcept
Definition MidiMessage.h:848
void setVelocity(float newVelocity) noexcept
Definition MidiMessage.cpp:386
void getFullFrameParameters(int &hours, int &minutes, int &seconds, int &frames, SmpteTimecodeType &timecodeType) const noexcept
Definition MidiMessage.cpp:827
bool isHeapAllocated() const noexcept
Definition MidiMessage.h:847
void setNoteNumber(int newNoteNumber) noexcept
Definition MidiMessage.cpp:367
int getSysExDataSize() const noexcept
Definition MidiMessage.cpp:623
int getMetaEventLength() const noexcept
Definition MidiMessage.cpp:638
bool isKeySignatureMetaEvent() const noexcept
Definition MidiMessage.cpp:761
int getControllerValue() const noexcept
Definition MidiMessage.cpp:510
static MidiMessage midiStop() noexcept
Definition MidiMessage.cpp:802
MidiMachineControlCommand getMidiMachineControlCommand() const noexcept
Definition MidiMessage.cpp:863
static MidiMessage channelPressureChange(int channel, int pressure) noexcept
Definition MidiMessage.cpp:436
static MidiMessage pitchWheel(int channel, int position) noexcept
Definition MidiMessage.cpp:484
uint8 * allocateSpace(int)
Definition MidiMessage.cpp:295
int getNoteNumber() const noexcept
Definition MidiMessage.cpp:362
bool isMidiChannelMetaEvent() const noexcept
Definition MidiMessage.cpp:661
SmpteTimecodeType
Definition MidiMessage.h:709
bool isMidiMachineControlMessage() const noexcept
Definition MidiMessage.cpp:854
static MidiMessage programChange(int channel, int programNumber) noexcept
Definition MidiMessage.cpp:465
static int readVariableLengthVal(const uint8 *data, int &numBytesUsed) noexcept
Definition MidiMessage.cpp:63
static MidiMessage midiChannelMetaEvent(int channel) noexcept
Definition MidiMessage.cpp:755
bool isSysEx() const noexcept
Definition MidiMessage.cpp:601
MidiMessage() noexcept
Definition MidiMessage.cpp:103
int getChannel() const noexcept
Definition MidiMessage.cpp:307
PackedData packedData
Definition MidiMessage.h:843
double getTempoMetaEventTickLength(short timeFormat) const noexcept
Definition MidiMessage.cpp:682
const uint8 * getMetaEventData() const noexcept
Definition MidiMessage.cpp:650
int getSongPositionPointerMidiBeat() const noexcept
Definition MidiMessage.cpp:786
bool isSustainPedalOn() const noexcept
Definition MidiMessage.cpp:444
static int getMessageLengthFromFirstByte(uint8 firstByte) noexcept
Definition MidiMessage.cpp:82
int getQuarterFrameSequenceNumber() const noexcept
Definition MidiMessage.cpp:808
double getTempoSecondsPerQuarterNote() const noexcept
Definition MidiMessage.cpp:669
bool isAllNotesOff() const noexcept
Definition MidiMessage.cpp:566
int getQuarterFrameValue() const noexcept
Definition MidiMessage.cpp:809
bool isSustainPedalOff() const noexcept
Definition MidiMessage.cpp:445
int size
Definition MidiMessage.h:845
bool isMidiContinue() const noexcept
Definition MidiMessage.cpp:798
static bool isMidiNoteBlack(int noteNumber) noexcept
Definition MidiMessage.cpp:918
static MidiMessage timeSignatureMetaEvent(int numerator, int denominator)
Definition MidiMessage.cpp:740
bool isChannelPressure() const noexcept
Definition MidiMessage.cpp:425
~MidiMessage() noexcept
Definition MidiMessage.cpp:289
bool isControllerOfType(int controllerType) const noexcept
Definition MidiMessage.cpp:498
static MidiMessage midiMachineControlCommand(MidiMachineControlCommand command)
Definition MidiMessage.cpp:870
static MidiMessage midiClock() noexcept
Definition MidiMessage.cpp:805
static MidiMessage allNotesOff(int channel) noexcept
Definition MidiMessage.cpp:561
bool isSoftPedalOff() const noexcept
Definition MidiMessage.cpp:451
bool isNoteOff(bool returnTrueForNoteOnVelocity0=true) const noexcept
Definition MidiMessage.cpp:346
void multiplyVelocity(float scaleFactor) noexcept
Definition MidiMessage.cpp:392
bool isMidiStop() const noexcept
Definition MidiMessage.cpp:801
static MidiMessage quarterFrame(int sequenceNumber, int value) noexcept
Definition MidiMessage.cpp:811
int getProgramChangeNumber() const noexcept
Definition MidiMessage.cpp:459
bool isNoteOn(bool returnTrueForVelocity0=false) const noexcept
Definition MidiMessage.cpp:338
static MidiMessage masterVolume(float volume)
Definition MidiMessage.cpp:588
bool isSoftPedalOn() const noexcept
Definition MidiMessage.cpp:450
static MidiMessage fullFrame(int hours, int minutes, int seconds, int frames, SmpteTimecodeType timecodeType)
Definition MidiMessage.cpp:840
bool isQuarterFrame() const noexcept
Definition MidiMessage.cpp:807
static MidiMessage keySignatureMetaEvent(int numberOfSharpsOrFlats, bool isMinorKey)
Definition MidiMessage.cpp:776
int getPitchWheelValue() const noexcept
Definition MidiMessage.cpp:477
bool isMidiClock() const noexcept
Definition MidiMessage.cpp:804
int getChannelPressureValue() const noexcept
Definition MidiMessage.cpp:430
bool isPitchWheel() const noexcept
Definition MidiMessage.cpp:472
int getMetaEventType() const noexcept
Definition MidiMessage.cpp:632
bool isController() const noexcept
Definition MidiMessage.cpp:493
int getAfterTouchValue() const noexcept
Definition MidiMessage.cpp:406
static MidiMessage tempoMetaEvent(int microsecondsPerQuarterNote) noexcept
Definition MidiMessage.cpp:709
uint8 getVelocity() const noexcept
Definition MidiMessage.cpp:373
unsigned * m
Definition inflate.c:1559
struct huft * t
Definition inflate.c:943
unsigned v[N_MAX]
Definition inflate.c:1584
unsigned d
Definition inflate.c:940
register unsigned i
Definition inflate.c:1575
static PuglViewHint int value
Definition pugl.h:1708
JSAMPIMAGE data
Definition jpeglib.h:945
#define wassert(expression)
Definition MidiMessage.cpp:33
uint8 validVelocity(const int v) noexcept
Definition MidiMessage.cpp:39
uint8 initialByte(const int type, const int channel) noexcept
Definition MidiMessage.cpp:34
Definition AudioSampleBuffer.h:33
int roundToInt(const FloatType value) noexcept
Definition MathsFunctions.h:346
Type jmin(const Type a, const Type b)
Definition MathsFunctions.h:60
bool isPositiveAndBelow(Type valueToTest, Type upperLimit) noexcept
Definition MathsFunctions.h:187
Type jmap(Type value0To1, Type targetRangeMin, Type targetRangeMax)
Definition MathsFunctions.h:74
unsigned short uint16
Definition water.h:94
unsigned char uint8
Definition water.h:90
Type jlimit(const Type lowerLimit, const Type upperLimit, const Type valueToConstrain) noexcept
Definition MathsFunctions.h:169
signed char int8
Definition water.h:88
static float volume(float level)
Definition nekobee_voice_render.c:99
uint8 * allocatedData
Definition MidiMessage.h:839
int n
Definition crypt.c:458
memcpy(hh, h, RAND_HEAD_LEN)
typedef int(UZ_EXP MsgFn)()
#define const
Definition zconf.h:137