Planeshift
|
This class represent a musical instrument. More...
#include <instrument.h>
Public Member Functions | |
bool | AddNote (const char *fileName, char note, int alter, uint octave) |
Add the given note to the sounds that this instruments can play. | |
void | AddNoteToChord (char note, int alter, uint octave, float duration, uint noteNumber, char *buffer, size_t &bufferLength) |
Add a note to an already existing buffer. | |
const csSndSysSoundFormat * | GetFormat () const |
Gets the csSndSysSoundFormat of the notes of this instrument. | |
size_t | GetLongestNoteSize () const |
Gets the size of the note with the longest buffer. | |
size_t | GetNoteBuffer (char note, int alter, uint octave, float duration, char *&buffer, size_t &length) |
Provide a buffer containing the decoded data for the given note of this instrument. | |
uint | GetPolyphony () const |
Gets the number of notes that this instrument can play at the same time. | |
Instrument (uint polyphony) | |
Constructor. | |
bool | IsDefined () |
Checks if the instrument has a format and a set of defined notes. | |
~Instrument () | |
Destructor. | |
Public Attributes | |
float | maxDist |
float | minDist |
float | volume |
This class represent a musical instrument.
Definition at line 68 of file instrument.h.
Instrument::Instrument | ( | uint | polyphony | ) |
Constructor.
It sets the polyphony capabilities of this instrument.
polyphony | the maximum number of notes that this instrument can play at the same time. |
Instrument::~Instrument | ( | ) |
Destructor.
bool Instrument::AddNote | ( | const char * | fileName, |
char | note, | ||
int | alter, | ||
uint | octave | ||
) |
Add the given note to the sounds that this instruments can play.
If the given note has already been defined, nothing happens.
fileName | the file that contain the note's sound. |
note | a char representing the note in the British English notation (i.e. A, B, C, ..., G). |
alter | 1 if the note is altered by a sharp, -1 for a flat and 0 if it is not altered. |
octave | 4 for the central octave in piano. |
void Instrument::AddNoteToChord | ( | char | note, |
int | alter, | ||
uint | octave, | ||
float | duration, | ||
uint | noteNumber, | ||
char * | buffer, | ||
size_t & | bufferLength | ||
) |
Add a note to an already existing buffer.
note | a char representing the note in the British English notation (i.e. A, B, C, ..., G). |
alter | 1 if the note is altered by a sharp, -1 for a flat and 0 if it is not altered. |
octave | 4 for the central octave in piano. |
duration | the duration of the note in seconds. |
noteNumber | the number of the note already in the chord. |
buffer | the buffer where the note is added for the given length. |
length | the current length of the buffer. |
const csSndSysSoundFormat* Instrument::GetFormat | ( | ) | const [inline] |
Gets the csSndSysSoundFormat of the notes of this instrument.
return the csSndSysSoundFormat.
Definition at line 103 of file instrument.h.
size_t Instrument::GetLongestNoteSize | ( | ) | const [inline] |
Gets the size of the note with the longest buffer.
Definition at line 109 of file instrument.h.
size_t Instrument::GetNoteBuffer | ( | char | note, |
int | alter, | ||
uint | octave, | ||
float | duration, | ||
char *& | buffer, | ||
size_t & | length | ||
) |
Provide a buffer containing the decoded data for the given note of this instrument.
If there are no notes loaded, at the end of the method both the return value and length are 0. DO NOT MODIFY THE OBTAINED BUFFER because the data is not copied to save time and modifying it would damage the instrument's data. If you must modify it, copy it first and work on the copy.
note | a char representing the note in the British English notation (i.e. A, B, C, ..., G). |
alter | 1 if the note is altered by a sharp, -1 for a flat and 0 if it is not altered. |
octave | 4 for the central octave in piano. |
duration | the duration of the note in seconds. |
buffer | when the method is done this will contain the decoded data for the given note, or a null pointer if the note does not exist. |
length | when the method is done this will contain the length of the provided buffer. |
uint Instrument::GetPolyphony | ( | ) | const [inline] |
Gets the number of notes that this instrument can play at the same time.
Definition at line 97 of file instrument.h.
bool Instrument::IsDefined | ( | ) |
Checks if the instrument has a format and a set of defined notes.
Definition at line 73 of file instrument.h.
Definition at line 72 of file instrument.h.
Definition at line 71 of file instrument.h.