#include <PhraseEdit.h>
Inheritance diagram for TSE3::PhraseEdit:
Public Member Functions | |
PhraseEdit (int noEvents=defaultSize) | |
virtual | ~PhraseEdit () |
void | reset (const MidiData *source=0) |
void | tidy (Clock stopTime=-1) |
void | timeShift (Clock delta) |
Phrase * | createPhrase (PhraseList *pl, const std::string &title="") const |
MidiEvent & | operator[] (size_t n) |
void | insert (MidiEvent event) |
void | erase (size_t n) |
void | erase (MidiEvent event) |
void | select (size_t index) |
void | selectRange (size_t from, size_t to) |
void | deselect (size_t index) |
void | clearSelection () |
void | invertSelection () |
bool | selection () const |
size_t | firstSelectionIndex () const |
size_t | lastSelectionIndex () const |
void | eraseSelection () |
bool | modified () const |
void | setModified (bool m) |
Static Public Attributes | |
const int | defaultSize = 1024 |
const int | tollerance = Clock::PPQN/2 |
This class provides an editable MidiData area. It is the mechanism used to generate Phrase objects.
The PhraseEdit object can be used as an area into which MidiEvent data is recorded in real time (it is used by the Transport class), or as the basic data structure for a GUI Phrase editor, for example.
For this latter mode of usage, the PhraseEdit class provides a number of callbacks (see PhraseEditListener) that can be used to keep the display updated.
When the PhraseEdit is tidy, the safest way of modifying a MidiEvent is to remove it and the reinsert the modified MidiEvent.
Selections are denoted by the selected
bit in the MidiCommand data type. You can use select() and deselect() to alter selection states.
For convenience the PhraseEdit class remembers the index of the first and last selected MidiEvent.
Working with selections only really makes sense when the data area is tidy. You can still use the selection facilities with an untidy data area, however.
Changing the selection does not affect the modified status.
|
Create a PhraseEdit with the given number of events space reserved. It is not really necessary to specify this size unless you know at least how many events will be inserted and reserving them will result in a worthwhile performance increase. The PhaseEdit is initially created in an unmodified state (see modified()).
|
|
|
|
Resets the PhraseEdit area to be a copy of the given MidiData. If the The modified status value will be cleared (see modified()) which may result in the modified event being raised.
|
|
Tidies the MidiData (usually used after recording has stopped) This does a number of things, including adding any missing MidiCommand_NoteOffs and the conversion of sustain pedal usage into elongated notes. It removes all events before time zero (with a small tollerance) The data in the PhraseEdit at this point could be in any state. MidiCommand_NoteOffs may be collated into the correct MidiEvent, or they may be in their own event (which they will be when just recorded). Events may be in time order, or in some completely random order. It also collates all MidiCommand_NoteOffs into the appropriate MidiCommand_NoteOns so that the PhraseEdit area will contain valid data that can be streamed out through a Playable interface. Prior to using tidy, you may need to apply timeShift(). This may cause the modified event to be raised.
|
|
Shift the time of every event in the PhraseEdit by This operation can be applied to tidy() or untidy PhraseEdit data. You might want to use this method when recording MidiEvent data from an external source (using the Transport class) and you haven't started recording at the time zero. Once recording has finished you can "normalise" the recorded data to a reference start time of zero by calling
|
|
Creates a Phrase from this MidiData and inserts it into the specified PhraseList. Make sure that you have done a tidy() first. If you don't specify a title for the new Phrase then it will automatically be given a name that is guaranteed not to be used by any other Phrase in the PhraseList (you can find out what it is with Phrase::title()).
If a Phrase with the supplied
|
|
Returns the nth MidiEvent in this MidiData object. Note that, unlike the base MidiData class, this object is modifiable. The value returned for an index that is out of range is undefined. The size() method describes the valid values. If you set the event directly using this method you run the risk of leaving the PhraseEdit object 'untidy'. Any data manipulation performed via this operator will not affect the modified status, and so no modified event will be raised. In simple terms, use this method at your own risk!
|
|
Insert a MidiEvent into the MidiData in time order.
If it does then you can be assured that adding the MidiEvent to a 'tidied' PhraseEdit object will leave the object still 'tidy'. If you only add a MidiCommand_NoteOn/ MidiCommand_NoteOff without the ballancing MIDI command then the PhraseEdit is left 'untidy' and any use of it to create a Phrase and/or have it's data streamed out of a Playable interface is invalid. This restriction is important in the use of the TSE3 library, if you don't use 'tidy' MidiData then playback will produce 'undefined' (very probably wrong) output. This may cause the modified event to be raised.
|
|
Remove a MidiEvent from the MidiData. The result is undefined if the index This may cause the modified event to be raised.
|
|
Remove a MidiEvent from the MidiData. If there isn't a MidiEvent * matching this one then no change occurs. This may cause the modified event to be raised.
|
|
Selects the MidiEvent at the specified index.
|
|
Selects every MidiEvent between the specified indexes.
|
|
Deselects the MidiEvent at the specified index.
|
|
Clears any selection. |
|
Inverts the selection status of every MidiEvent. |
|
Returns true if any MidiEvent is selected.
|
|
Returns the index of the first selected MidiEvent. If no MidiEvent has been selected, returns the value of size().
|
|
Returns the index of the last selected MidiEvent. If no MidiEvent has been selected, returns the value of size().
|
|
Erases any MidiEvent that has been selected. This may cause the modified event to be raised. |
|
Returns true if the PhraseEdit has been modified since creation or the last reset().
|
|
Allows you to manually set the modified status. This may cause the modified event to be raised.
|
|
The default maximum no events in Phrase editor. These days the editor automatically grows so this is fairly redundant. |
|
The time allowance given for notes to be before start time when tidying.
|