Planeshift
Functions

psMusic Namespace Reference

This namespace contains a set of functions that are usefull for the processing of music and musical scores. More...

Functions

bool CheckDuration (int duration)
 Check wheather the given number of DURATION_QUARTER_DIVISIONS correspond to a specific duration taken into account by the enum Duration.
bool CheckValidity (iDocument *musicalScore, csRef< iDocumentNode > &partNode)
 Checks if the given document is a valid musical score and provide the <part> node.
void EnharmonicPitch (char &pitch, int &accidental)
 Turns the given pitch into the enharmonic equivalent.
bool GetAttributes (iDocument *musicalScore, int &quarterDivisions, int &fifths, int &beats, int &beatType, int &tempo)
 Gets the attributes in the first measure of the given score.
Duration GetBiggestDuration (int duration)
 Returns the biggest duration that can be represented on the score which is less or equal to the given one.
bool GetMeasures (iDocument *score, csRefArray< iDocumentNode > &measures)
 Gets the XML nodes representing the measures contained in the musical score.
bool GetStatistics (iDocument *musicalScore, ScoreStatistics &stats)
 Returns the statistics of the score.
void NextPitch (char &pitch, uint &octave)
 Turns the given pitch into the next one in the scale.
void PreviousPitch (char &pitch, uint &octave)
 Turns the given pitch into the previous one in the scale.
bool ZCompressSong (const csString &inputScore, csString &outputScore)
 Compress a song with the zlib compression algorithm.
bool ZDecompressSong (const csString &inputScore, csString &outputScore)
 Decompress a song with the zlib compression algorithm.

Detailed Description

This namespace contains a set of functions that are usefull for the processing of music and musical scores.


Function Documentation

bool psMusic::CheckDuration ( int  duration)

Check wheather the given number of DURATION_QUARTER_DIVISIONS correspond to a specific duration taken into account by the enum Duration.

Parameters:
durationthe duration expressed as the number of DURATION_QUARTER_DIVISIONS.
Returns:
true if the given duration can be expressed by the type Duration, false otherwise.
bool psMusic::CheckValidity ( iDocument *  musicalScore,
csRef< iDocumentNode > &  partNode 
)

Checks if the given document is a valid musical score and provide the <part> node.

Parameters:
musicalScorethe musical score.
partNodea reference that will contain the part XML node.
Returns:
true if the document is valid, false otherwise.
void psMusic::EnharmonicPitch ( char &  pitch,
int accidental 
)

Turns the given pitch into the enharmonic equivalent.

Parameters:
pitchthe pitch of the note.
accidentalthe alteration of the note.
bool psMusic::GetAttributes ( iDocument *  musicalScore,
int quarterDivisions,
int fifths,
int beats,
int beatType,
int tempo 
)

Gets the attributes in the first measure of the given score.

The provided attributes are always valid. If the musical score contains non valid attributes (e.g. beatType <= 0), they are set to a valid default value.

Parameters:
musicalScorethe musical score.
quarterDivisionsthe number of divisions in a quarter for the score.
fifthsthe tonality of the score.
beatsbeats of the song.
beatTypethe beat type of the song.
tempothe beat per minutes of the song.
Returns:
true if the document is a valid musical score and the attributes could be found in the first measure, false otherwise. False is returned also if there are not measures in the given score.
Duration psMusic::GetBiggestDuration ( int  duration)

Returns the biggest duration that can be represented on the score which is less or equal to the given one.

Parameters:
durationThe maximum duration as the number of DURATION_QUARTER_DIVISIONS.
Returns:
The duration value.
bool psMusic::GetMeasures ( iDocument *  score,
csRefArray< iDocumentNode > &  measures 
)

Gets the XML nodes representing the measures contained in the musical score.

Parameters:
scorethe musical score.
measuresa reference to a csRefArray that will contain the XML nodes.
Returns:
true if the document is a valid musical score, false otherwise.
bool psMusic::GetStatistics ( iDocument *  musicalScore,
ScoreStatistics stats 
)

Returns the statistics of the score.

Parameters:
musicalScorethe musical score.
statsthe retrieved statistics of the given score.
Returns:
true if the document is a valid musical score, false otherwise.
void psMusic::NextPitch ( char &  pitch,
uint &  octave 
)

Turns the given pitch into the next one in the scale.

Parameters:
pitchthe pitch of the note.
octavethe octave of the note.
void psMusic::PreviousPitch ( char &  pitch,
uint &  octave 
)

Turns the given pitch into the previous one in the scale.

Parameters:
pitchthe pitch of the note.
octavethe octave of the note.
bool psMusic::ZCompressSong ( const csString &  inputScore,
csString &  outputScore 
)

Compress a song with the zlib compression algorithm.

Attention:
the output string is not a normal string but a sequence of bytes. It could contain null characters. Do not treat it like a null terminated string.
Parameters:
inputScorethe musical sheet in uncompressed XML format.
outputScoreat the end this string will contain the compressed score.
Returns:
true if the compression is done without errors, false otherwise.
bool psMusic::ZDecompressSong ( const csString &  inputScore,
csString &  outputScore 
)

Decompress a song with the zlib compression algorithm.

Parameters:
inputScorethe compressed musical sheet.
outputScoreat the end this string will contain the uncompressed score.
Returns:
true if the decompression is done without errors, false otherwise.