Ascene . Agraph . Aengine
. Anode
Songbook . Song
WSLoader . Sound Loaders
Random . Rhythm . TimeKeeper
MIDI . OSC . HID . Piano
Plot . Envelope . Util
Music Theory with Tonal
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, options) |
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. Options include songId (0), presetDir(null) and InitVoice callback (null) |
LoadSongbookString(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 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))
yield;