Music Documentation
Beep8 features generative music using ZzFx. You can generate music, or you can create your own.
The music generation is still experimental and the music created is not as good as I would like, so if you use it be prepared for your music to change (hopefully for the better).
If you have experience with generating music I would love to get some help with this. You can check the code on the Beep8 GitHub.
beep8.Music.generate([options])
Generates multi-track music in p1.js format. It creates a chord progression and then generates various parts (melody, chord, or drum). Optionally prepends tempo and hold information to the first part.
Parameters
- [options] (Object): Options for music generation.
Returns
- (string): The generated multi-track music string.
beep8.Music.isPlaying()
Checks if music is currently playing.
Returns
- (boolean): True if music is playing, otherwise false.
beep8.Music.pause()
Pauses the current music playback.
beep8.Music.play(song)
Plays a p1.js music string.
Parameters
- song (string): The music string to play.
beep8.Music.resume()
Resumes the current music playback.
If a song is currently playing, it will continue from where it left off. If no song is playing, it will do nothing.
beep8.Music.setTempo(tempo)
Set the tempo of a currently playing song.
Parameters
- tempo (number): The new tempo in BPM.
beep8.Music.setVolume(volume)
Sets the volume for the music playback.
Parameters
- volume (number): The volume level (0 to 1).
beep8.Music.stop([clearCurrentSong])
Stops the current music playback. If clearCurrentSong
is true, it will also clear the current song reference. This is disabled when the music is paused to allow resuming playback.
Parameters
- [clearCurrentSong] (boolean): Whether to clear the current song reference. (default: true)