Browse Source

Minor documentation updates. Added MidiMessageSequence::sort() method.

tags/2021-05-28
jules 13 years ago
parent
commit
fae88c8b88
5 changed files with 42 additions and 31 deletions
  1. +1
    -1
      extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.h
  2. +28
    -22
      modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp
  3. +5
    -0
      modules/juce_audio_basics/midi/juce_MidiMessageSequence.h
  4. +2
    -2
      modules/juce_core/files/juce_File.h
  5. +6
    -6
      modules/juce_core/streams/juce_InputStream.h

+ 1
- 1
extras/Introjucer/Source/Code Editor/jucer_SourceCodeEditor.h View File

@@ -38,7 +38,7 @@ public:
bool loadedOk() const { return true; }
bool isForFile (const File& file) const { return getFile() == file; }
bool isForNode (const ValueTree& node) const { return false; }
bool isForNode (const ValueTree&) const { return false; }
bool refersToProject (Project& p) const { return project == &p; }
Project* getProject() const { return project; }
String getName() const { return getFile().getFileName(); }


+ 28
- 22
modules/juce_audio_basics/midi/juce_MidiMessageSequence.cpp View File

@@ -68,19 +68,19 @@ MidiMessageSequence::MidiEventHolder* MidiMessageSequence::getEventPointer (cons
double MidiMessageSequence::getTimeOfMatchingKeyUp (const int index) const
{
const MidiEventHolder* const meh = list [index];
if (const MidiEventHolder* const meh = list [index])
if (meh->noteOffObject != nullptr)
return meh->noteOffObject->message.getTimeStamp();
if (meh != nullptr && meh->noteOffObject != nullptr)
return meh->noteOffObject->message.getTimeStamp();
else
return 0.0;
return 0.0;
}
int MidiMessageSequence::getIndexOfMatchingKeyUp (const int index) const
{
const MidiEventHolder* const meh = list [index];
if (const MidiEventHolder* const meh = list [index])
return list.indexOf (meh->noteOffObject);
return meh != nullptr ? list.indexOf (meh->noteOffObject) : -1;
return -1;
}
int MidiMessageSequence::getIndexOf (MidiEventHolder* const event) const
@@ -113,8 +113,10 @@ double MidiMessageSequence::getEndTime() const
double MidiMessageSequence::getEventTime (const int index) const
{
const MidiEventHolder* const e = list [index];
return e != nullptr ? e->message.getTimeStamp() : 0.0;
if (const MidiEventHolder* const meh = list [index])
return meh->message.getTimeStamp();
return 0.0;
}
//==============================================================================
@@ -179,20 +181,26 @@ void MidiMessageSequence::addSequence (const MidiMessageSequence& other,
}
}
sort();
}
//==============================================================================
void MidiMessageSequence::sort()
{
MidiMessageSequenceSorter sorter;
list.sort (sorter, true);
}
//==============================================================================
void MidiMessageSequence::updateMatchedPairs()
{
for (int i = 0; i < list.size(); ++i)
{
const MidiMessage& m1 = list.getUnchecked(i)->message;
MidiEventHolder* const meh = list.getUnchecked(i);
const MidiMessage& m1 = meh->message;
if (m1.isNoteOn())
{
list.getUnchecked(i)->noteOffObject = nullptr;
meh->noteOffObject = nullptr;
const int note = m1.getNoteNumber();
const int chan = m1.getChannel();
const int len = list.size();
@@ -205,14 +213,14 @@ void MidiMessageSequence::updateMatchedPairs()
{
if (m.isNoteOff())
{
list.getUnchecked(i)->noteOffObject = list[j];
meh->noteOffObject = list[j];
break;
}
else if (m.isNoteOn())
{
list.insert (j, new MidiEventHolder (MidiMessage::noteOff (chan, note)));
list.getUnchecked(j)->message.setTimeStamp (m.getTimeStamp());
list.getUnchecked(i)->noteOffObject = list[j];
meh->noteOffObject = list[j];
break;
}
}
@@ -224,8 +232,10 @@ void MidiMessageSequence::updateMatchedPairs()
void MidiMessageSequence::addTimeToMessages (const double delta)
{
for (int i = list.size(); --i >= 0;)
list.getUnchecked (i)->message.setTimeStamp (list.getUnchecked (i)->message.getTimeStamp()
+ delta);
{
MidiMessage& mm = list.getUnchecked(i)->message;
mm.setTimeStamp (m.getTimeStamp() + delta);
}
}
//==============================================================================
@@ -237,11 +247,8 @@ void MidiMessageSequence::extractMidiChannelMessages (const int channelNumberToE
{
const MidiMessage& mm = list.getUnchecked(i)->message;
if (mm.isForChannel (channelNumberToExtract)
|| (alsoIncludeMetaEvents && mm.isMetaEvent()))
{
if (mm.isForChannel (channelNumberToExtract) || (alsoIncludeMetaEvents && mm.isMetaEvent()))
destSequence.addEvent (mm);
}
}
}
@@ -284,8 +291,7 @@ void MidiMessageSequence::createControllerUpdatesForTime (const int channelNumbe
{
const MidiMessage& mm = list.getUnchecked(i)->message;
if (mm.isForChannel (channelNumber)
&& mm.getTimeStamp() <= time)
if (mm.isForChannel (channelNumber) && mm.getTimeStamp() <= time)
{
if (mm.isProgramChange())
{


+ 5
- 0
modules/juce_audio_basics/midi/juce_MidiMessageSequence.h View File

@@ -199,6 +199,11 @@ public:
*/
void updateMatchedPairs();
/** Forces a sort of the sequence.
You may need to call this if you've manually modified the timestamps of some
events such that the overall order now needs updating.
*/
void sort();
//==============================================================================
/** Copies all the messages for a particular midi channel to another sequence.


+ 2
- 2
modules/juce_core/files/juce_File.h View File

@@ -605,8 +605,8 @@ public:
Attempts to load the entire file as a zero-terminated string.
This makes use of InputStream::readEntireStreamAsString, which should
automatically cope with unicode/acsii file formats.
This makes use of InputStream::readEntireStreamAsString, which can
read either UTF-16 or UTF-8 file formats.
*/
String loadFileAsString() const;


+ 6
- 6
modules/juce_core/streams/juce_InputStream.h View File

@@ -217,7 +217,7 @@ public:
virtual int readCompressedInt();
//==============================================================================
/** Reads a UTF8 string from the stream, up to the next linefeed or carriage return.
/** Reads a UTF-8 string from the stream, up to the next linefeed or carriage return.
This will read up to the next "\n" or "\r\n" or end-of-stream.
@@ -227,10 +227,10 @@ public:
*/
virtual String readNextLine();
/** Reads a zero-terminated UTF8 string from the stream.
/** Reads a zero-terminated UTF-8 string from the stream.
This will read characters from the stream until it hits a zero character or
end-of-stream.
This will read characters from the stream until it hits a null character
or end-of-stream.
@see OutputStream::writeString, readEntireStreamAsString
*/
@@ -238,8 +238,8 @@ public:
/** Tries to read the whole stream and turn it into a string.
This will read from the stream's current position until the end-of-stream, and
will try to make an educated guess about whether it's unicode or an 8-bit encoding.
This will read from the stream's current position until the end-of-stream.
It can read from either UTF-16 or UTF-8 formats.
*/
virtual String readEntireStreamAsString();


Loading…
Cancel
Save