easyiec.problems.Melody#

class easyiec.problems.Melody(n_steps=16)[source]#

Bases: Problem

Sixteen-step melodies in a chosen scale.

Each step gene is a scale degree (two octaves), a hold (the previous note continues) or a rest; further genes choose the scale, the root and the tempo. Heuristic objectives describe singability: the share of stepwise motion, the mean interval, the range, whether the tune ends on the tonic, and repetition of motifs.

describe(x)[source]#

Text description of a candidate (for text-only judges).

features(x)[source]#

Phenotype features in psychological space (default: image features).

notes(x)[source]#

List of (start_step, length, midi_pitch) and the decoded parameters.

objectives(x)[source]#

Key performance indicators (engineering problems); empty by default.

render_plot(x, ax)[source]#

Plot-type phenotypes (curves, layouts) draw here; used by _image().

to_audio(x, sr=22050)[source]#

Mono float waveform in [-1, 1] (additive synthesis with an ADSR envelope).

utility(x, target=None)[source]#

Default hidden utility in [0, 1] (ground truth of benchmarks).

With a target genome it is a Gaussian similarity of standardized phenotype features; subclasses with explicit objectives override it.

wav_bytes(x, sr=22050)[source]#

The melody as a 16-bit PCM WAV file (bytes).

Examples using easyiec.problems.Melody#

Beyond images: melodies and slogans

Beyond images: melodies and slogans