Add a rhythm engine
Last updated
Last updated
The main APIs you'll be using are found in the Rhythm
and RhythmMusicGeneration
modules:
Give JJazzLab-X access to one or more Rhythm
objects provided by your engine
The main interface which provides descriptive information about the rhythm, with its RhythmVoices
, and hythmParameters
.
MusicGenerator
A Rhythm implementation should also implement the MusicGenerator
interface to be able to generate music
There is one RhythmVoice
for each track generated by your rhythm, e.g. "Drums", "Bass", "Piano"
The parameters to modulate the rhythm, e.g. "Complexity" or "Fill"
You should first create your own Netbeans module, as explained in the Getting started page.
Your engine must be recognized by the JJazzLab framework, so that it can be accessible to the end-user. For this you'll need to start by adding a RhythmProvider
implementation, as explained below.
RhythmProvider
The RhythmProvider
interface is defined in the Rhythm module.
Your implementation must use the @ServiceProvider
annotation so that the RhythmDatabase
instance can automatically find it upon startup. The general Netbeans mechanism used is described here.
When user needs to pick up a rhythm, the rhythm selection dialog asks the RhythmDatabase
to provide the available RhythmProvider
instances (e.g. "Yamaha style based generator") and their list of rhythms (e.g. "jazz", "pop", ...).
The RhythmProvider
implementation is responsible to provide:
An Info
object (name, description, author, version, uniqueId)
The list of built-in Rhythm
objects provided by this implementation
The list of file-based Rhythm
objects provided by this implementation
An optional settings dialog to tune the rhythm generation engine
Example: See RhythmStubProviderImpl.java for a simple RhythmProvider
implementation example.
Rhythm
A Rhythm
interface describes... a rhythm !
name, for example "samba-fast"
description
time signature
preferred tempo
feel : ternary/binary
etc...
It also defines the RhythmVoices
, RhythmParameters
.
The Rhythm implementation must also implement the MusicGenerator
interface to be able to generate music.
Example: See RhythmStub.java for a very simple Rhythm
implementation example.
RhythmVoice
There is one RhythmVoice
for each track generated by this rhythm, e.g. "Drums", "Bass", "Piano". The RhythmVoice
provides the recommended Midi instrument and settings for the track.
The RhythmVoices
information is used for example by the Mix Console to display the relevant tracks.
RhythmParameter
Examples of RhythmParameters
are "Variation", "Fill", or "Complexity".
The RhythmParameters
are the control knobs given to the user so he can modulate the rhythm for each song part. You see them in the Song Structure Editor, for each Song Part.
There are ready-to-use classes to quickly define your RhythmParameters
depending on their type (a boolean value, one value amongst a set of values, etc). When these classes are used the framework will automatically show the relevant UI widget in the Song Structure Editor. You can also define your own UI widgets if you prefer.
MusicGenerator
This is an interface which indicates the capability to generate rhythm music. It has just a single method which takes the music generation context as a parameter, and returns the musical phrases (one per track) that make the backing track.
When user presses the Play button for a given song, JJazzLab-X will:
prepare the MusicGenerationContext (e.g. mainly a Song object which contains a ChordLeadSheet and a SongStructure)
If Rhythm
implements the MusicGenerator
interface, pass it the context data and ask it to generate the backing track
wait until the MusicGenerator
has finished the music generation
convert the received music data into a Midi sequence
play the sequence.
So the MusicGenerator
is really where the heavy stuff will be done by your engine. There is no synchronization constraint since JJazzLab will simply block until music generation is complete.
Note that you can use any technology to perform the generation, including non-Java ones. Only the lightweight API that connects to JJazzLab needs to be in Java.
Example: See DummyGenerator.java for a very simple MusicGenerator
implementation example.