|
|
The Destination class is a simple utility class that can be used to associate Instrument definitions with MIDI outputs (channel/port pairs).
An application can use this to remember what sort of instrument definition to use for which output; to present the correct program change information to the user, for example.
For each port, you may choose one Instrument for every channel, or may select a number of different Instrument objects for the different individual channels.
You may also leave a particular definition unspecified (as zero).
The Destination class has a secondary purpose of keeping track of all the currently used Instrument objects, keeping the list of desinations up to date if any Instrument is removed.
Since this class operates independantly of a TSE3::MidiScheduler it cannot track what port numbers are currently valid, and which are not.
See also: Instrument
Destination ()
| Destination |
Creates a Destination object.
Initially no destinations are specified.
~Destination ()
| ~Destination |
Instrument * defaultInstrument ()
| defaultInstrument |
[const]
Returns the default Instrument.
This is the instrument definition that is returned if no other mapping has been made.
By default, this is set to zero.
Returns: The default instrument definition
See also: setDefaultInstrument
void setDefaultInstrument (Instrument *instrument)
| setDefaultInstrument |
Sets the default Instrument.
Parameters:
instrument | The default definition |
See also: defaultInstrument
bool allChannels (int port)
| allChannels |
Returns whether there is one Instrument selected for every channel on this port (true) or whether each channel is been assigned separately (false).
Parameters:
port | Port number to enquire about |
Returns: Whether there is one Instrument for every channel on this port
See also: setPort, setChannel
Instrument * port (int port)
| port |
Returns the Instrument selected for this entire port. This instrument is used for every channel on this port.
If no instrument has been specified for this port
, then
port() returns the defaultInstrument.
If allChannels is false for this port
then zero
is returned (you have called this in error).
Parameters:
port | Port number to enquire about |
Returns: The Instrument selected for this port, or 0 if no Instrument is specified
See also: setPort, channel
void setPort (int port, Instrument *instrument)
| setPort |
Sets which instrument is used by this port. This will have the side effect of making allChannels return true.
You may specify an instrument
of zero to unspecify
an Instrument definition.
Parameters:
port | Port number to set Instrument for |
instrument | Instrument to specify. Whilst it's not essential that this has been added with addInstrument, it is advised to do so. |
See also: setChannel
Instrument * channel (int channel, int port)
| channel |
Returns the Instrument selected for this channel/port destination.
If no instrument has been specified for this port/channel,
then port
returns defaultInstrument.
If allChannels is true for this port
then the
channel
value is ignored.
Parameters:
port | Port number to enquire about |
channel | Channel number to enquire about |
Returns: The Instrument selected for this port, or 0 if no Instrument is specified
See also: setChannel, port
void setChannel (int channel, int port,
Instrument *instrument)
| setChannel |
Sets which instrument is used by this channel/port pair. This will have the side effect of making allChannels return false.
You may specify an instrument
of zero to unspecify
an Instrument definition.
Parameters:
port | Port number to set Instrument for |
channel | Channel number to set Instrument for |
instrument | Instrument to specify. Whilst it's not essential that this has been added with addInstrument, it is advised to do so. |
See also: setChannel
size_t numInstruments ()
| numInstruments |
[const]
Returns the number of Instrument objects currently managed by the Destination object.
Instrument * instrument (size_t index)
| instrument |
Returns the Instrument at the given index. The list of Instrument object is ordered alphabetically.
Parameters:
index | Index into Instrument list (between 0 and noInstruments()). |
Returns: Instrument object at index
See also: noInstruments
Instrument * instrument (const std::string &title)
| instrument |
Returns the Instrument with the given title, or zero if there is no such Instrument.
Parameters:
title | Instrument title to search for |
Returns: Instrument object or 0
void addInstrument (Instrument *instrument)
| addInstrument |
Adds the specified Instrument to the list of Instrument objects. You can only insert a given Instrument once. The instrument is inserted into the list in alphabetical order of title.
The Instrument object is considered to be 'owned' by the Destination class, and will be deleted when the Destination is.
Parameters:
instrument | New Instrument object to insert |
See also: removeInstrument
void removeInstrument (Instrument *instrument)
| removeInstrument |
Removed the specified Instrument from the list of
Instrument objects. If instrument
is being used
as a destination, then the destination link is removed.
Once removed it is your responsibility to delete the Instrument.
Parameters:
instrument | Instrument object to remove |
See also: addInstrument