/**
* @class
* @classdesc Encapsulates each TrackMetaData in the music composed of an array of tunings and staffs
*/
class TrackMetaData {
/**
* Constructs a new TrackMetaData
*/
constructor() {
this.tuning = [];
this.staffs = [];
}
/**
* Adds tuning to array of tunings
* @param {string} newTuning Tuning to add
*/
addTuning(newTuning) {
this.tuning.push(newTuning);
}
/**
* Add staff to array
* @param {Staff} staff Staff object to add to array of staffs
*/
addStaff(staff) {
this.staffs.push(staff);
}
/**
* Copies tunings and staffs from object
* @param {object} source Source must have tuning, staffs
* @property {string[]} source.tuning String array of tunings
* @property {Staff[]} source.staffs Array of Staff objects
*/
copy(source) {
source.tuning.forEach(element => {
this.addTuning(element);
});
source.staffs.forEach(element => {
this.addStaff(element);
});
}
/**
* Converts TrackMetaData to a pretty string
* @returns {string} The pretty string representation of the TrackMetaData
*/
toString() {
let output = "";
output += "Tuning: ";
this.tuning.forEach((element) => {
output += element;
output += " ";
});
output += "\n";
output += "Staffs: \n";
this.staffs.forEach((element) => {
output += element.toString();
output += "\n";
});
return output;
}
}
module.exports = TrackMetaData