Constructor
new Music(zzfxMusic)
Create a music object and cache the zzfx music samples for later use
Parameters:
Name | Type | Description |
---|---|---|
zzfxMusic |
- 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 0, 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
playMusic(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> | false | True if the music should loop |
- Source
Returns:
- The audio source node
- Type:
- AudioBufferSourceNode