Constructor
# new Music(zzfxMusic)
Create a music object and cache the zzfx music samples for later use
Parameters:
Name | Type | Description |
---|---|---|
zzfxMusic |
Array | Array of zzfx music parameters |
- Source:
Example
// create some music
const music_example = new Music(
[
[ // instruments
[,0,400] // simple note
],
[ // patterns
[ // pattern 1
[ // channel 0
0, -1, // instrument 0, left speaker
1, 0, 9, 1 // channel notes
],
[ // channel 1
0, 1, // instrument 1, right speaker
0, 12, 17, -1 // channel notes
]
],
],
[0, 0, 0, 0], // sequence, play pattern 0 four times
90 // BPM
]);
// play the music
music_example.play();
Methods
# play(volumeopt, loopopt) → {AudioBufferSourceNode}
Play the music
Parameters:
Name | Type | Attributes | Default | Description |
---|---|---|---|---|
volume |
Number |
<optional> |
1 | How much to scale volume by |
loop |
Boolean |
<optional> |
1 | True if the music should loop when it reaches the end |
- Source:
Returns:
- The audio node, can be used to stop sound later
- Type
- AudioBufferSourceNode