Skip to content

Main content

Random Scale-Constrained Melody Generator

Generate exact-count independent MIDI pitches with replacement from supplied tonic-relative pitch classes and scientific octave bounds, delegating octave and A4=440 Hz frequency metadata; no rhythm, key spelling or musical-quality claim.

Loading tool…

Description

Generate exact-count independent MIDI pitches with replacement from supplied tonic-relative pitch classes and scientific octave bounds, delegating octave and A4=440 Hz frequency metadata; no rhythm, key spelling or musical-quality claim.

A musical fixture expresses pitch or timing through explicit numeric conventions such as MIDI numbers, semitone intervals, beats, and durations. A reproducible symbolic sequence is separate from a performed sound or a judgment of musical quality.

Generate exact-count independent MIDI pitches with replacement from supplied tonic-relative pitch classes and scientific octave bounds, delegating octave and A4=440 Hz frequency metadata; no rhythm, key spelling or musical-quality claim.

When to use this tool

Use this generator to create reproducible scale melody cases from the supplied model or bank. Inspect the returned evidence before using cases in a test or exercise.

How to use the tool and how it works

  1. Supply count, tonicPitchClass, scaleOffsets, minimumOctave, maximumOctave in the field shapes below. Set seed when you need an explicit replay.
  2. Run the tool and correct any input error. For generated controls, distinguish a successful fixture containing an invalid case from failure to generate the fixture.
  3. Read availableMidi, notes. Use the conventions below and keep answer-bearing fields separate when presenting an exercise.

Filter MIDI 0 through 127 by octave bounds and tonic-relative scale offsets, then independently draw notes from the eligible MIDI bank and delegate their pitch representations.1

Input fieldMeaning and unitsAccepted input
countRequested count; the mechanics explain whether one draw expands into several returned records.Required. Safe integer; minimum 1; maximum 1024.
tonicPitchClassTonic Pitch ClassRequired. Safe integer; minimum 0; maximum 11.
scaleOffsetsScale OffsetsRequired. Array of Safe integer; minimum 0; maximum 11.; minimum items 1; maximum items 12.
minimumOctaveMinimum OctaveRequired. Safe integer; minimum -1; maximum 9.
maximumOctaveMaximum OctaveRequired. Safe integer; minimum -1; maximum 9.
seedOptional numeric seed; takes precedence over context randomness. Without either, use the fixed tool.io default seed.Optional. Safe integer.
Output fieldInterpretationReturned shape
availableMidiAvailable MidiRequired. Array of Safe integer; minimum 0; maximum 127.; minimum items 1; maximum items 128.
notesNotesRequired. Array of Object; no unknown keys.; minimum items 1; maximum items 1024.
notes[].midiMidiRequired. Safe integer; minimum 0; maximum 127.
notes[].noteNoteRequired. Text; minimum UTF-16 length 2; maximum UTF-16 length 4.
notes[].octaveOctaveRequired. Safe integer; minimum -1; maximum 9.
notes[].frequencyHzFrequency HzRequired. Finite number; strictly above 0.
randomnessReplay metadata: source is seed or context; seed is the normalized 32-bit seed or null for a context source.Required. Object; no unknown keys.
randomness.seedOptional numeric replay seed; normalization and precedence are explained below.Required. Safe integer. or Null.
randomness.sourceSourceRequired. Text; one of "context", "seed".

An explicit safe-integer seed takes precedence over injected context randomness and is normalized to an unsigned 32-bit integer. With no seed and no context source, replay uses the fixed tool.io default seed. A context source must return finite values from zero inclusive to one exclusive; its advancing state must be retained separately. randomness records the source and normalized seed, or null for context. These generators are not cryptographic random sources.

json
{
  "input": {
    "count": 6,
    "tonicPitchClass": 0,
    "scaleOffsets": [
      0,
      2,
      4,
      5,
      7,
      9,
      11
    ],
    "minimumOctave": 4,
    "maximumOctave": 4,
    "seed": 42
  },
  "output": {
    "availableMidi": [
      60,
      62,
      64,
      65,
      67,
      69,
      71
    ],
    "notes": [
      {
        "midi": 67,
        "note": "G4",
        "octave": 4,
        "frequencyHz": 391.99543598174927
      },
      {
        "midi": 65,
        "note": "F4",
        "octave": 4,
        "frequencyHz": 349.2282314330039
      },
      {
        "midi": 69,
        "note": "A4",
        "octave": 4,
        "frequencyHz": 440
      },
      {
        "midi": 67,
        "note": "G4",
        "octave": 4,
        "frequencyHz": 391.99543598174927
      },
      {
        "midi": 62,
        "note": "D4",
        "octave": 4,
        "frequencyHz": 293.6647679174076
      },
      {
        "midi": 65,
        "note": "F4",
        "octave": 4,
        "frequencyHz": 349.2282314330039
      }
    ],
    "randomness": {
      "seed": 42,
      "source": "seed"
    }
  }
}

Limitations and assumptions

  • Scale offsets must be distinct and the eligible bank nonempty. Sampling allows repeated notes; no melodic continuity, voice-leading, rhythm, or instrument playability is enforced.
  • A replay requires the same complete input and implementation. Randomized construction does not guarantee uniform coverage of every feasible output; finite samples can repeat unless a distinct-selection rule is explicitly stated.
  • The field tables state structural bounds; cross-field constraints and bounded search or output budgets also apply. Unknown keys are rejected where the object contract disallows them. Input errors are distinct from null fields and deliberate invalid controls in a successful output.

Alternative or Complementary methods

For a supplied example, inspect the returned construction or delegated check directly. To evaluate a consumer, also test cases chosen for its own boundaries; a generated finite corpus does not establish exhaustive coverage.

References

  1. Tool behavior and example: Random Scale-Constrained Melody Generator — tool.io

Similar or alternative tools

  • Random Bounded-Interval Melody Generator

    Generate a MIDI melody from an explicit starting pitch with uniform local choices including repeated notes inside a pitch range and maximum semitone step, delegating frequency and signed interval answers; not uniform over complete melodies.

  • Random Polyrhythm Event Grid Generator

    Generate exact rational event grids for shared-cycle polyrhythms or shared-beat polymeters with delegated tempo timing.