Planeshift
Public Member Functions | Public Attributes

Instrument Class Reference

This class represent a musical instrument. More...

#include <instrument.h>

List of all members.

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

Detailed Description

This class represent a musical instrument.

Definition at line 68 of file instrument.h.


Constructor & Destructor Documentation

Instrument::Instrument ( uint  polyphony)

Constructor.

It sets the polyphony capabilities of this instrument.

Parameters:
polyphonythe maximum number of notes that this instrument can play at the same time.
Instrument::~Instrument ( )

Destructor.


Member Function Documentation

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.

Parameters:
fileNamethe file that contain the note's sound.
notea char representing the note in the British English notation (i.e. A, B, C, ..., G).
alter1 if the note is altered by a sharp, -1 for a flat and 0 if it is not altered.
octave4 for the central octave in piano.
Returns:
true if the note could be loaded, false otherwise.
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.

Parameters:
notea char representing the note in the British English notation (i.e. A, B, C, ..., G).
alter1 if the note is altered by a sharp, -1 for a flat and 0 if it is not altered.
octave4 for the central octave in piano.
durationthe duration of the note in seconds.
noteNumberthe number of the note already in the chord.
bufferthe buffer where the note is added for the given length.
lengththe 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.

Returns:
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.

Parameters:
notea char representing the note in the British English notation (i.e. A, B, C, ..., G).
alter1 if the note is altered by a sharp, -1 for a flat and 0 if it is not altered.
octave4 for the central octave in piano.
durationthe duration of the note in seconds.
bufferwhen the method is done this will contain the decoded data for the given note, or a null pointer if the note does not exist.
lengthwhen the method is done this will contain the length of the provided buffer.
Returns:
the number of bytes that are missing to reach the duration. This can be greater than 0 if the sound in the file used to load the note data does not last enough.
uint Instrument::GetPolyphony ( ) const [inline]

Gets the number of notes that this instrument can play at the same time.

Returns:
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.

Returns:
true if it is defined, false otherwise.

Member Data Documentation

Definition at line 73 of file instrument.h.

Definition at line 72 of file instrument.h.

Definition at line 71 of file instrument.h.


The documentation for this class was generated from the following file: