mirror of
https://github.com/juce-framework/JUCE.git
synced 2026-01-10 23:44:24 +00:00
Added MidiMessage::textMetaEvent method.
This commit is contained in:
parent
b0933193bf
commit
7786943593
4 changed files with 46 additions and 52 deletions
|
|
@ -155,7 +155,7 @@ MidiMessage::MidiMessage (const MidiMessage& other, const double newTimeStamp)
|
|||
MidiMessage::MidiMessage (const void* srcData, int sz, int& numBytesUsed, const uint8 lastStatusByte, double t)
|
||||
: timeStamp (t)
|
||||
{
|
||||
const uint8* src = static_cast <const uint8*> (srcData);
|
||||
const uint8* src = static_cast<const uint8*> (srcData);
|
||||
unsigned int byte = (unsigned int) *src;
|
||||
|
||||
if (byte < 0x80)
|
||||
|
|
@ -658,6 +658,36 @@ String MidiMessage::getTextFromTextMetaEvent() const
|
|||
CharPointer_UTF8 (textData + getMetaEventLength()));
|
||||
}
|
||||
|
||||
MidiMessage MidiMessage::textMetaEvent (int type, const StringRef& text)
|
||||
{
|
||||
jassert (type > 0 && type < 16)
|
||||
|
||||
MidiMessage result;
|
||||
|
||||
const size_t textSize = text.text.sizeInBytes() - 1;
|
||||
|
||||
uint8 header[8];
|
||||
size_t n = sizeof (header);
|
||||
|
||||
header[--n] = (uint8) (textSize & 0x7f);
|
||||
|
||||
for (size_t i = textSize; (i >>= 7) != 0;)
|
||||
header[--n] = (uint8) ((i & 0x7f) | 0x80);
|
||||
|
||||
header[--n] = (uint8) type;
|
||||
header[--n] = 0xff;
|
||||
|
||||
const size_t headerLen = sizeof (header) - n;
|
||||
|
||||
uint8* const dest = result.allocateSpace (headerLen + textSize);
|
||||
result.size = headerLen + textSize;
|
||||
|
||||
memcpy (dest, header + n, headerLen);
|
||||
memcpy (dest + headerLen, text.text.getAddress(), textSize);
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
bool MidiMessage::isTrackNameEvent() const noexcept { const uint8* data = getRawData(); return (data[1] == 3) && (*data == 0xff); }
|
||||
bool MidiMessage::isTempoMetaEvent() const noexcept { const uint8* data = getRawData(); return (data[1] == 81) && (*data == 0xff); }
|
||||
bool MidiMessage::isMidiChannelMetaEvent() const noexcept { const uint8* data = getRawData(); return (data[1] == 0x20) && (*data == 0xff) && (data[2] == 1); }
|
||||
|
|
|
|||
|
|
@ -168,9 +168,7 @@ public:
|
|||
bool isForChannel (int channelNumber) const noexcept;
|
||||
|
||||
/** Changes the message's midi channel.
|
||||
|
||||
This won't do anything for non-channel messages like sysexes.
|
||||
|
||||
@param newChannelNumber the channel number to change it to, in the range 1 to 16
|
||||
*/
|
||||
void setChannel (int newChannelNumber) noexcept;
|
||||
|
|
@ -181,17 +179,13 @@ public:
|
|||
bool isSysEx() const noexcept;
|
||||
|
||||
/** Returns a pointer to the sysex data inside the message.
|
||||
|
||||
If this event isn't a sysex event, it'll return 0.
|
||||
|
||||
@see getSysExDataSize
|
||||
*/
|
||||
const uint8* getSysExData() const noexcept;
|
||||
|
||||
/** Returns the size of the sysex data.
|
||||
|
||||
This value excludes the 0xf0 header byte and the 0xf7 at the end.
|
||||
|
||||
@see getSysExData
|
||||
*/
|
||||
int getSysExDataSize() const noexcept;
|
||||
|
|
@ -252,15 +246,12 @@ public:
|
|||
bool isNoteOnOrOff() const noexcept;
|
||||
|
||||
/** Returns the midi note number for note-on and note-off messages.
|
||||
|
||||
If the message isn't a note-on or off, the value returned is undefined.
|
||||
|
||||
@see isNoteOff, getMidiNoteName, getMidiNoteInHertz, setNoteNumber
|
||||
*/
|
||||
int getNoteNumber() const noexcept;
|
||||
|
||||
/** Changes the midi note number of a note-on or note-off message.
|
||||
|
||||
If the message isn't a note on or off, this will do nothing.
|
||||
*/
|
||||
void setNoteNumber (int newNoteNumber) noexcept;
|
||||
|
|
@ -320,16 +311,12 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Returns true if the message is a program (patch) change message.
|
||||
|
||||
@see getProgramChangeNumber, getGMInstrumentName
|
||||
*/
|
||||
bool isProgramChange() const noexcept;
|
||||
|
||||
/** Returns the new program number of a program change message.
|
||||
|
||||
If the message isn't a program change, the value returned will be
|
||||
nonsense.
|
||||
|
||||
If the message isn't a program change, the value returned is undefined.
|
||||
@see isProgramChange, getGMInstrumentName
|
||||
*/
|
||||
int getProgramChangeNumber() const noexcept;
|
||||
|
|
@ -344,7 +331,6 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Returns true if the message is a pitch-wheel move.
|
||||
|
||||
@see getPitchWheelValue, pitchWheel
|
||||
*/
|
||||
bool isPitchWheel() const noexcept;
|
||||
|
|
@ -433,7 +419,6 @@ public:
|
|||
/** Returns the controller number of a controller message.
|
||||
|
||||
The name of the controller can be looked up using the getControllerName() method.
|
||||
|
||||
Note that the value returned is invalid for messages that aren't controller changes.
|
||||
|
||||
@see isController, getControllerName, getControllerValue
|
||||
|
|
@ -443,7 +428,6 @@ public:
|
|||
/** Returns the controller value from a controller message.
|
||||
|
||||
A value 0 to 127 is returned to indicate the new controller position.
|
||||
|
||||
Note that the value returned is invalid for messages that aren't controller changes.
|
||||
|
||||
@see isController, getControllerNumber
|
||||
|
|
@ -467,13 +451,11 @@ public:
|
|||
int value) noexcept;
|
||||
|
||||
/** Checks whether this message is an all-notes-off message.
|
||||
|
||||
@see allNotesOff
|
||||
*/
|
||||
bool isAllNotesOff() const noexcept;
|
||||
|
||||
/** Checks whether this message is an all-sound-off message.
|
||||
|
||||
@see allSoundOff
|
||||
*/
|
||||
bool isAllSoundOff() const noexcept;
|
||||
|
|
@ -520,13 +502,11 @@ public:
|
|||
int getMetaEventType() const noexcept;
|
||||
|
||||
/** Returns a pointer to the data in a meta-event.
|
||||
|
||||
@see isMetaEvent, getMetaEventLength
|
||||
*/
|
||||
const uint8* getMetaEventData() const noexcept;
|
||||
|
||||
/** Returns the length of the data for a meta-event.
|
||||
|
||||
@see isMetaEvent, getMetaEventData
|
||||
*/
|
||||
int getMetaEventLength() const noexcept;
|
||||
|
|
@ -539,29 +519,28 @@ public:
|
|||
bool isEndOfTrackMetaEvent() const noexcept;
|
||||
|
||||
/** Creates an end-of-track meta-event.
|
||||
|
||||
@see isEndOfTrackMetaEvent
|
||||
*/
|
||||
static MidiMessage endOfTrack() noexcept;
|
||||
|
||||
/** Returns true if this is an 'track name' meta-event.
|
||||
|
||||
You can use the getTextFromTextMetaEvent() method to get the track's name.
|
||||
*/
|
||||
bool isTrackNameEvent() const noexcept;
|
||||
|
||||
/** Returns true if this is a 'text' meta-event.
|
||||
|
||||
@see getTextFromTextMetaEvent
|
||||
*/
|
||||
bool isTextMetaEvent() const noexcept;
|
||||
|
||||
/** Returns the text from a text meta-event.
|
||||
|
||||
@see isTextMetaEvent
|
||||
*/
|
||||
String getTextFromTextMetaEvent() const;
|
||||
|
||||
/** Creates a text meta-event. */
|
||||
static MidiMessage textMetaEvent (int type, const StringRef& text);
|
||||
|
||||
//==============================================================================
|
||||
/** Returns true if this is a 'tempo' meta-event.
|
||||
@see getTempoMetaEventTickLength, getTempoSecondsPerQuarterNote
|
||||
|
|
@ -660,7 +639,6 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Returns true if this is a midi start event.
|
||||
|
||||
@see midiStart
|
||||
*/
|
||||
bool isMidiStart() const noexcept;
|
||||
|
|
@ -669,7 +647,6 @@ public:
|
|||
static MidiMessage midiStart() noexcept;
|
||||
|
||||
/** Returns true if this is a midi continue event.
|
||||
|
||||
@see midiContinue
|
||||
*/
|
||||
bool isMidiContinue() const noexcept;
|
||||
|
|
@ -678,7 +655,6 @@ public:
|
|||
static MidiMessage midiContinue() noexcept;
|
||||
|
||||
/** Returns true if this is a midi stop event.
|
||||
|
||||
@see midiStop
|
||||
*/
|
||||
bool isMidiStop() const noexcept;
|
||||
|
|
@ -687,7 +663,6 @@ public:
|
|||
static MidiMessage midiStop() noexcept;
|
||||
|
||||
/** Returns true if this is a midi clock event.
|
||||
|
||||
@see midiClock, songPositionPointer
|
||||
*/
|
||||
bool isMidiClock() const noexcept;
|
||||
|
|
@ -696,13 +671,11 @@ public:
|
|||
static MidiMessage midiClock() noexcept;
|
||||
|
||||
/** Returns true if this is a song-position-pointer message.
|
||||
|
||||
@see getSongPositionPointerMidiBeat, songPositionPointer
|
||||
*/
|
||||
bool isSongPositionPointer() const noexcept;
|
||||
|
||||
/** Returns the midi beat-number of a song-position-pointer message.
|
||||
|
||||
@see isSongPositionPointer, songPositionPointer
|
||||
*/
|
||||
int getSongPositionPointerMidiBeat() const noexcept;
|
||||
|
|
@ -719,23 +692,18 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Returns true if this is a quarter-frame midi timecode message.
|
||||
|
||||
@see quarterFrame, getQuarterFrameSequenceNumber, getQuarterFrameValue
|
||||
*/
|
||||
bool isQuarterFrame() const noexcept;
|
||||
|
||||
/** Returns the sequence number of a quarter-frame midi timecode message.
|
||||
|
||||
This will be a value between 0 and 7.
|
||||
|
||||
@see isQuarterFrame, getQuarterFrameValue, quarterFrame
|
||||
*/
|
||||
int getQuarterFrameSequenceNumber() const noexcept;
|
||||
|
||||
/** Returns the value from a quarter-frame message.
|
||||
|
||||
This will be the lower nybble of the message's data-byte, a value
|
||||
between 0 and 15
|
||||
This will be the lower nybble of the message's data-byte, a value between 0 and 15
|
||||
*/
|
||||
int getQuarterFrameValue() const noexcept;
|
||||
|
||||
|
|
@ -747,7 +715,6 @@ public:
|
|||
static MidiMessage quarterFrame (int sequenceNumber, int value) noexcept;
|
||||
|
||||
/** SMPTE timecode types.
|
||||
|
||||
Used by the getFullFrameParameters() and fullFrame() methods.
|
||||
*/
|
||||
enum SmpteTimecodeType
|
||||
|
|
@ -758,8 +725,7 @@ public:
|
|||
fps30 = 3
|
||||
};
|
||||
|
||||
/** Returns true if this is a full-frame midi timecode message.
|
||||
*/
|
||||
/** Returns true if this is a full-frame midi timecode message. */
|
||||
bool isFullFrame() const noexcept;
|
||||
|
||||
/** Extracts the timecode information from a full-frame midi timecode message.
|
||||
|
|
@ -773,8 +739,7 @@ public:
|
|||
int& frames,
|
||||
SmpteTimecodeType& timecodeType) const noexcept;
|
||||
|
||||
/** Creates a full-frame MTC message.
|
||||
*/
|
||||
/** Creates a full-frame MTC message. */
|
||||
static MidiMessage fullFrame (int hours,
|
||||
int minutes,
|
||||
int seconds,
|
||||
|
|
@ -799,7 +764,6 @@ public:
|
|||
};
|
||||
|
||||
/** Checks whether this is an MMC message.
|
||||
|
||||
If it is, you can use the getMidiMachineControlCommand() to find out its type.
|
||||
*/
|
||||
bool isMidiMachineControlMessage() const noexcept;
|
||||
|
|
|
|||
|
|
@ -170,8 +170,8 @@ public:
|
|||
*/
|
||||
Point<FloatType> getPointOnCircumference (float radius, float angle) const noexcept
|
||||
{
|
||||
return Point<FloatType> (static_cast <FloatType> (x + radius * std::sin (angle)),
|
||||
static_cast <FloatType> (y - radius * std::cos (angle)));
|
||||
return Point<FloatType> (static_cast<FloatType> (x + radius * std::sin (angle)),
|
||||
static_cast<FloatType> (y - radius * std::cos (angle)));
|
||||
}
|
||||
|
||||
/** Taking this point to be the centre of an ellipse, this returns a point on its circumference.
|
||||
|
|
@ -181,8 +181,8 @@ public:
|
|||
*/
|
||||
Point<FloatType> getPointOnCircumference (float radiusX, float radiusY, float angle) const noexcept
|
||||
{
|
||||
return Point<FloatType> (static_cast <FloatType> (x + radiusX * std::sin (angle)),
|
||||
static_cast <FloatType> (y - radiusY * std::cos (angle)));
|
||||
return Point<FloatType> (static_cast<FloatType> (x + radiusX * std::sin (angle)),
|
||||
static_cast<FloatType> (y - radiusY * std::cos (angle)));
|
||||
}
|
||||
|
||||
/** Returns the dot-product of two points (x1 * x2 + y1 * y2). */
|
||||
|
|
@ -205,13 +205,13 @@ public:
|
|||
|
||||
//==============================================================================
|
||||
/** Casts this point to a Point<int> object. */
|
||||
Point<int> toInt() const noexcept { return Point<int> (static_cast <int> (x), static_cast<int> (y)); }
|
||||
Point<int> toInt() const noexcept { return Point<int> (static_cast<int> (x), static_cast<int> (y)); }
|
||||
|
||||
/** Casts this point to a Point<float> object. */
|
||||
Point<float> toFloat() const noexcept { return Point<float> (static_cast <float> (x), static_cast<float> (y)); }
|
||||
Point<float> toFloat() const noexcept { return Point<float> (static_cast<float> (x), static_cast<float> (y)); }
|
||||
|
||||
/** Casts this point to a Point<double> object. */
|
||||
Point<double> toDouble() const noexcept { return Point<double> (static_cast <double> (x), static_cast<double> (y)); }
|
||||
Point<double> toDouble() const noexcept { return Point<double> (static_cast<double> (x), static_cast<double> (y)); }
|
||||
|
||||
/** Returns the point as a string in the form "x, y". */
|
||||
String toString() const { return String (x) + ", " + String (y); }
|
||||
|
|
|
|||
|
|
@ -28,7 +28,7 @@ ThreadWithProgressWindow::ThreadWithProgressWindow (const String& title,
|
|||
const int cancellingTimeOutMs,
|
||||
const String& cancelButtonText,
|
||||
Component* componentToCentreAround)
|
||||
: Thread ("Juce Progress Window"),
|
||||
: Thread ("ThreadWithProgressWindow"),
|
||||
progress (0.0),
|
||||
timeOutMsWhenCancelling (cancellingTimeOutMs),
|
||||
wasCancelledByUser (false)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue