maiacore 1.10.1
Music analisys library
ScoreCollection Class Reference

Represents a collection of musical scores, supporting batch analysis and management. More...

#include <score_collection.h>

Public Member Functions

 ScoreCollection (const std::string &directoryPath={})
 Constructs a ScoreCollection from a single directory path. More...
 
 ScoreCollection (const std::vector< std::string > &directoriesPaths={})
 Constructs a ScoreCollection from multiple directory paths. More...
 
std::vector< std::string > getDirectoriesPaths () const
 Returns the list of directory paths associated with the collection. More...
 
void setDirectoriesPaths (const std::vector< std::string > &directoriesPaths)
 Sets the list of directory paths and reloads the collection. More...
 
void addDirectory (const std::string &directoryPath)
 Adds a directory path to the collection (does not reload files automatically). More...
 
void addScore (const Score &score)
 Adds a Score object to the collection. More...
 
void addScore (const std::string &filePath)
 Loads a Score from a file path and adds it to the collection. More...
 
void addScore (const std::vector< std::string > &filePaths)
 Loads multiple Scores from file paths and adds them to the collection. More...
 
void clear ()
 Removes all scores from the collection.
 
int getNumDirectories () const
 Returns the number of directories in the collection. More...
 
int getNumScores () const
 Returns the number of scores in the collection. More...
 
std::vector< Score > & getScores ()
 Returns a reference to the vector of Score objects (modifiable). More...
 
const std::vector< Score > & getScores () const
 Returns a const reference to the vector of Score objects. More...
 
bool isEmpty () const
 Returns true if the collection contains no scores. More...
 
void merge (const ScoreCollection &other)
 Merges another ScoreCollection into this one, combining directories and scores. More...
 
void removeScore (const int scoreIdx)
 Removes a score from the collection by its index. More...
 
ExtendedMelodyPatternTable findMelodyPattern (const std::vector< Note > &melodyPattern, const float totalIntervalsSimilarityThreshold=0.5f, const float totalRhythmSimilarityThreshold=0.5f, const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &intervalsSimilarityCallback=nullptr, const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &rhythmSimilarityCallback=nullptr, const std::function< float(const std::vector< float > &)> &totalIntervalSimilarityCallback=nullptr, const std::function< float(const std::vector< float > &)> &totalRhythmSimilarityCallback=nullptr, const std::function< float(float, float)> &totalSimilarityCallback=nullptr) const
 Searches for a melodic pattern in all scores, returning extended results. More...
 
std::vector< ExtendedMultiMelodyPatternTable > findMelodyPattern (const std::vector< std::vector< Note > > &melodyPatterns, const float totalIntervalsSimilarityThreshold=0.5f, const float totalRhythmSimilarityThreshold=0.5f, const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &intervalsSimilarityCallback=nullptr, const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &rhythmSimilarityCallback=nullptr, const std::function< float(const std::vector< float > &)> &totalIntervalSimilarityCallback=nullptr, const std::function< float(const std::vector< float > &)> &totalRhythmSimilarityCallback=nullptr, const std::function< float(float, float)> &totalSimilarityCallback=nullptr) const
 Searches for multiple melodic patterns in all scores, returning extended results for each pattern. More...
 
ScoreCollection operator+ (const ScoreCollection &other) const
 Merges two ScoreCollections using the + operator. More...
 

Detailed Description

Represents a collection of musical scores, supporting batch analysis and management.

The ScoreCollection class provides methods for loading, managing, and analyzing multiple Score objects. It is designed for large-scale musicological research, corpus studies, and batch processing of MusicXML files.

Constructor & Destructor Documentation

◆ ScoreCollection() [1/2]

ScoreCollection::ScoreCollection ( const std::string &  directoryPath = {})
explicit

Constructs a ScoreCollection from a single directory path.

Parameters
directoryPathPath to a directory containing MusicXML files.

◆ ScoreCollection() [2/2]

ScoreCollection::ScoreCollection ( const std::vector< std::string > &  directoriesPaths = {})
explicit

Constructs a ScoreCollection from multiple directory paths.

Parameters
directoriesPathsVector of directory paths.

Member Function Documentation

◆ addDirectory()

void ScoreCollection::addDirectory ( const std::string &  directoryPath)

Adds a directory path to the collection (does not reload files automatically).

Parameters
directoryPathDirectory path string.

◆ addScore() [1/3]

void ScoreCollection::addScore ( const Score score)

Adds a Score object to the collection.

Parameters
scoreScore object to add.

◆ addScore() [2/3]

void ScoreCollection::addScore ( const std::string &  filePath)

Loads a Score from a file path and adds it to the collection.

Parameters
filePathPath to a MusicXML file.

◆ addScore() [3/3]

void ScoreCollection::addScore ( const std::vector< std::string > &  filePaths)

Loads multiple Scores from file paths and adds them to the collection.

Parameters
filePathsVector of MusicXML file paths.

◆ findMelodyPattern() [1/2]

ExtendedMelodyPatternTable ScoreCollection::findMelodyPattern ( const std::vector< Note > &  melodyPattern,
const float  totalIntervalsSimilarityThreshold = 0.5f,
const float  totalRhythmSimilarityThreshold = 0.5f,
const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &  intervalsSimilarityCallback = nullptr,
const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &  rhythmSimilarityCallback = nullptr,
const std::function< float(const std::vector< float > &)> &  totalIntervalSimilarityCallback = nullptr,
const std::function< float(const std::vector< float > &)> &  totalRhythmSimilarityCallback = nullptr,
const std::function< float(float, float)> &  totalSimilarityCallback = nullptr 
) const

Searches for a melodic pattern in all scores, returning extended results.

Each result row includes file metadata and all fields from Score::MelodyPatternRow.

Parameters
melodyPatternVector of Note objects representing the pattern.
totalIntervalsSimilarityThresholdMinimum interval similarity threshold.
totalRhythmSimilarityThresholdMinimum rhythm similarity threshold.
intervalsSimilarityCallbackCustom function to calculate interval similarity.
rhythmSimilarityCallbackCustom function to calculate rhythm similarity.
totalIntervalSimilarityCallbackFunction to aggregate interval similarity.
totalRhythmSimilarityCallbackFunction to aggregate rhythm similarity.
totalSimilarityCallbackFunction to combine total similarities.
Returns
ExtendedMelodyPatternTable with results from all scores.

◆ findMelodyPattern() [2/2]

std::vector< ExtendedMultiMelodyPatternTable > ScoreCollection::findMelodyPattern ( const std::vector< std::vector< Note > > &  melodyPatterns,
const float  totalIntervalsSimilarityThreshold = 0.5f,
const float  totalRhythmSimilarityThreshold = 0.5f,
const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &  intervalsSimilarityCallback = nullptr,
const std::function< std::vector< float >(const std::vector< Note > &, const std::vector< Note > &)> &  rhythmSimilarityCallback = nullptr,
const std::function< float(const std::vector< float > &)> &  totalIntervalSimilarityCallback = nullptr,
const std::function< float(const std::vector< float > &)> &  totalRhythmSimilarityCallback = nullptr,
const std::function< float(float, float)> &  totalSimilarityCallback = nullptr 
) const

Searches for multiple melodic patterns in all scores, returning extended results for each pattern.

Each result row includes pattern index, file metadata, and all fields from Score::MelodyPatternRow.

Parameters
melodyPatternsVector of melodic patterns (each a vector of Note).
totalIntervalsSimilarityThresholdMinimum interval similarity threshold.
totalRhythmSimilarityThresholdMinimum rhythm similarity threshold.
intervalsSimilarityCallbackCustom function to calculate interval similarity.
rhythmSimilarityCallbackCustom function to calculate rhythm similarity.
totalIntervalSimilarityCallbackFunction to aggregate interval similarity.
totalRhythmSimilarityCallbackFunction to aggregate rhythm similarity.
totalSimilarityCallbackFunction to combine total similarities.
Returns
Vector of ExtendedMultiMelodyPatternTable, one for each pattern.

◆ getDirectoriesPaths()

std::vector< std::string > ScoreCollection::getDirectoriesPaths ( ) const

Returns the list of directory paths associated with the collection.

Returns
Vector of directory path strings.

◆ getNumDirectories()

int ScoreCollection::getNumDirectories ( ) const

Returns the number of directories in the collection.

Returns
Number of directories.

◆ getNumScores()

int ScoreCollection::getNumScores ( ) const

Returns the number of scores in the collection.

Returns
Number of Score objects.

◆ getScores() [1/2]

std::vector< Score > & ScoreCollection::getScores ( )

Returns a reference to the vector of Score objects (modifiable).

Returns
Reference to vector of Score.

◆ getScores() [2/2]

const std::vector< Score > & ScoreCollection::getScores ( ) const

Returns a const reference to the vector of Score objects.

Returns
Const reference to vector of Score.

◆ isEmpty()

bool ScoreCollection::isEmpty ( ) const

Returns true if the collection contains no scores.

Returns
True if empty.

◆ merge()

void ScoreCollection::merge ( const ScoreCollection other)

Merges another ScoreCollection into this one, combining directories and scores.

Parameters
otherAnother ScoreCollection.

◆ operator+()

ScoreCollection ScoreCollection::operator+ ( const ScoreCollection other) const
inline

Merges two ScoreCollections using the + operator.

Parameters
otherAnother ScoreCollection.
Returns
New ScoreCollection containing all scores and directories from both.

◆ removeScore()

void ScoreCollection::removeScore ( const int  scoreIdx)

Removes a score from the collection by its index.

Parameters
scoreIdxIndex of the score to remove.

◆ setDirectoriesPaths()

void ScoreCollection::setDirectoriesPaths ( const std::vector< std::string > &  directoriesPaths)

Sets the list of directory paths and reloads the collection.

Parameters
directoriesPathsVector of directory path strings.

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