class Instrument

MIDI Instrument definition. More...

Full nameTSE3::Ins::Instrument
Definition#include <Instrument.h>
List of all Methods
Annotated List
Files
Globals
Hierarchy
Index

Public Types

Public Methods


Detailed Description

The Instrument class holds information about a specific MIDI instrument. This includes the voices it provides, control commands it understands, drum note names and so on.

The Instrument class is based on the instrument definitions supplied in Cakewalk .ins instrument definition files.

 Instrument (const std::string &title, const std::string &filename, TSE3::Progress *progess = 0)

Instrument

Creates an instrument with the given name from information contained in the given file. This file will be a Cakewalk .ins file.

Whilst the file is being loaded, the progess can be reported via the TSE3::Progess interface.

Parameters:
titleThe title of this instrument
fileThe file to take input from
progessTSE3::Progress callback, or zero for no callback

const std::string & title ()

title

[const]

Returns the title of this instrument.

Returns: Title of this instrument

const std::string & filename ()

filename

[const]

Returns the filename of the source of the instrument definition.

Returns: Filename of this instrument's definition

void  setTitle (const std::string &title)

setTitle

Sets the title.

Parameters:
titleNew instrument title

int  bankSelMethod ()

bankSelMethod

[const]

Returns the BankSelMethod, the values for this are defined as the BankSelMethod_XXX constants.

Returns: Bank select method

void  setBankSelMethod (int b)

setBankSelMethod

Sets the BankSelMethod.

Parameters:
bNew bank select method

enum BankSelMethod { BankSelMethod_Normal = 0, BankSelMethod_MSB = 1, BankSelMethod_LSB = 2, BankSelMethod_Patch = 3 }

BankSelMethod

An enum type defining the Instrument's bank select method. It has the following values

bool  useNotesAsController ()

useNotesAsController

[const]

Returns the UseNotesAsControllers value.

Returns: Whenther to use notes as controllers

void  setUseNotesAsControllers (bool u)

setUseNotesAsControllers

Sets the UseNotesAsControllers value.

Parameters:
uNew use notes as controllers value

size_t  numBanks ()

numBanks

[const]

Returns the number of banks of patch data defined by this instrument.

Returns: Number of banks of patches

int  bank (int index)

bank

[const]

Returns the bank number in the form:


      bankLSB + (bankMSB<<7)

for the bank with index index.

If you call this method with an invalid parameter, the result is undefined.

Returns: Bank change values for bank with given index

int  bank (const Voice &voice)

bank

[const]

Returns the bank number in the form:


      bankLSB + (bankMSB<<7)

for the bank for Voice voice. If there is no such Voice defined, then -2 will be returned.

Returns: Bank change values for bank with given index

int  bankLSB (int index)

bankLSB

[const]

Returns the bank LSB for the set of patches with index index.

If you call this method with an invalid parameter, the result is undefined.

Returns: Bank LSB value for bank with given index

See also: bankMSB

int  bankMSB (int index)

bankMSB

[const]

Returns the bank MSB for the set of patches with index index.

If you call this method with an invalid parameter, the result is undefined.

Returns: Bank MSB value for bank with given index

See also: bankLSB

PatchData * patch (int index)

patch

[const]

Returns the PatchData object for the given bank.

Parameters:
indexBank index

Returns: Pointer to PatchData for bank, or 0

PatchData * patchForBank (int bank)

patchForBank

[const]

Returns the PatchData object for the given bank, or 0 if there is none.

Note that this function takes the bank change number (as read from bank()), not the bank index.

If there is no PatchData for this bank, then zero is returned.

You can specify bank as -1 to find the 'catch all' bank, and if your bank number is undefined, but there is a ctach all patch set, that will be returned.

Parameters:
bankBank number

Returns: Pointer to PatchData for bank, or 0

PatchData * patchForBank (int bankLSB, int bankMSB)

patchForBank

[const]

Like the patchForBank(int) above, but takes the LSB and MSB parameters separately. This function actually fowards responsibility onto the other version. It is provided as a convenience.

If either of the LSB or MSB parameters are -1, then the overal bank value passed on is -1.

Parameters:
bankLSBBank number LSB
bankMSBBank number MSB

Returns: Pointer to PatchData for bank, or 0

size_t  numKeys ()

numKeys

[const]

Returns the number of sets of NoteData defined by this instrument.

Returns: Number of patches NoteData objects

NoteData * key (size_t index)

key

[const]

Returns the NoteData with the given index.

If you call this method with an invalid parameter, the result is undefined.

Returns: NoteData for index

NoteData * keyForVoice (const Voice &voice)

keyForVoice

[const]

Returns the NoteData for the given Voice.

If there is no such Voice, then zero is returned.

Returns: NoteData for index

size_t  numDrums ()

numDrums

[const]

Returns the number of drum statuses defined by this instrument.

Returns: Number of drum statuses

Voice  drum (size_t index)

drum

[const]

Returns the drum Voice with the given index.

If you call this method with an invalid parameter, the result is undefined.

Returns: Voice for index

bool  isDrum (const Voice &voice)

isDrum

[const]

Returns whether the specified voice is defined to be a drum sound or not (this implies that note data should be opened in a "drum" editor).

Returns: Whether voice is a drum sound

ControlData * control ()

control

[const]

Returns the ControlData for this Instrument, if there is any defined, or zero if there is none.

Returns: ControlData for this instrument

RpnData * rpn ()

rpn

[const]

Returns the RpnData for this Instrument, if there is any defined, or zero if there is none.

Returns: RpnData for this instrument

NrpnData * nrpn ()

nrpn

[const]

Returns the NrpnData for this Instrument, if there is any defined, or zero if there is none.

Returns: NrpnData for this instrument

void  write (std::ostream &out)

write

Write the minimal .ins file for this instrument.

Parameters:
outostream to write output to