Class RhythmPredictor
Rhythm predictor using Markov chains and N-gram models.
public sealed class RhythmPredictor
- Inheritance
-
RhythmPredictor
- Inherited Members
Remarks
Create a new rhythm predictor.
Constructors
RhythmPredictor(int, int?)
Rhythm predictor using Markov chains and N-gram models.
public RhythmPredictor(int order = 2, int? seed = null)
Parameters
orderintMarkov chain order (1 = first-order, 2 = second-order, etc.)
seedint?Random seed for reproducibility (null = random)
Remarks
Create a new rhythm predictor.
Methods
Generate(IReadOnlyList<Rational>, int)
Generate a rhythm sequence.
public List<Rational> Generate(IReadOnlyList<Rational> seed, int length)
Parameters
seedIReadOnlyList<Rational>lengthint
Returns
Exceptions
- ArgumentNullException
seedis null.
GenerateMeasure(IReadOnlyList<Rational>, TimeSignature)
Generate a complete measure.
public List<Rational> GenerateMeasure(IReadOnlyList<Rational> seed, TimeSignature meter)
Parameters
seedIReadOnlyList<Rational>meterTimeSignature
Returns
Exceptions
- ArgumentNullException
seedis null.
GetStats()
Get model statistics.
public RhythmModelStatistics GetStats()
Returns
Predict(IReadOnlyList<Rational>)
Predict the next duration given recent context.
public RhythmPrediction Predict(IReadOnlyList<Rational> recentDurations)
Parameters
recentDurationsIReadOnlyList<Rational>
Returns
Exceptions
- ArgumentNullException
recentDurationsis null.
Train(NoteBuffer)
Train from a NoteBuffer: the durations of its notes in the order they sound, rests left out. The buffer itself is not reordered.
public void Train(NoteBuffer buffer)
Parameters
bufferNoteBuffer
Remarks
The transitions learned are between notes adjacent in time. They used to be between notes adjacent in the buffer — the order a caller happened to append them — so a buffer built voice by voice, or a chord entered top-down, taught the model rhythms nobody played, while every other buffer-reading analyzer sorted first.
Exceptions
- ArgumentNullException
bufferis null.
Train(IReadOnlyList<Rational>)
Train the predictor on a sequence of durations.
public void Train(IReadOnlyList<Rational> durations)
Parameters
durationsIReadOnlyList<Rational>
Exceptions
- ArgumentNullException
durationsis null.