Table of Contents

Class RhythmPredictor

Namespace
Celeritas.Core.Analysis
Assembly
Celeritas.dll

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

order int

Markov chain order (1 = first-order, 2 = second-order, etc.)

seed int?

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

seed IReadOnlyList<Rational>
length int

Returns

List<Rational>

Exceptions

ArgumentNullException

seed is null.

GenerateMeasure(IReadOnlyList<Rational>, TimeSignature)

Generate a complete measure.

public List<Rational> GenerateMeasure(IReadOnlyList<Rational> seed, TimeSignature meter)

Parameters

seed IReadOnlyList<Rational>
meter TimeSignature

Returns

List<Rational>

Exceptions

ArgumentNullException

seed is null.

GetStats()

Get model statistics.

public RhythmModelStatistics GetStats()

Returns

RhythmModelStatistics

Predict(IReadOnlyList<Rational>)

Predict the next duration given recent context.

public RhythmPrediction Predict(IReadOnlyList<Rational> recentDurations)

Parameters

recentDurations IReadOnlyList<Rational>

Returns

RhythmPrediction

Exceptions

ArgumentNullException

recentDurations is 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

buffer NoteBuffer

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

buffer is null.

Train(IReadOnlyList<Rational>)

Train the predictor on a sequence of durations.

public void Train(IReadOnlyList<Rational> durations)

Parameters

durations IReadOnlyList<Rational>

Exceptions

ArgumentNullException

durations is null.