The term Songbook can refer to both the the type of file for Songs.hz as well as the Music API class used to load such files.
Here you'll find the description of Songbook class interface used to load an perform songs from Songs.hz files.
Method | Description |
---|---|
constructor(songstr, strContext) |
Create a songbook instance based on the provided string that may have been loaded with Loader. strContext is a helpful string used by status messages. |
FindSong(songId) |
Return an instance of the Song class associated with the requested songbook entry. songId defaults to the songbook index 0 but can also be the string that identifies the song within its songbook. |
async *PerformSong(ctx, presetDir, songId=0) |
Convenvience method to perform the requested song via this MusicAPI. Context should be the MusicAPI fiber, usually this. Since is it an async generator function, it should be iterated 'til completion. |
LoadString(str, strContext="unknown", onError) |
Load the songbook based on the provided string. This method is invoked by the constructor.` |
let id = `t${this.GetId()}`;
let thisDir = path.dirname(this.GetFilePath());
let presetDir = thisDir;
let songFile = "reich.hz";
let songPath = path.join(thisDir, songFile);
let str = await FetchWSFile(songPath, false/*not binary*/);
let songbook = new Songbook(str, songFile);
for await (const val of songbook.PerformSong(this, presetDir, 0))
yield;