@@ -217,12 +217,24 @@ def scale_notes (
217217 """Return MIDI note numbers for a scale within a pitch range.
218218
219219 Parameters:
220- key: Root note name (``"C"``, ``"F#"``, ``"Bb"``, etc.).
220+ key: Scale root as a note name (``"C"``, ``"F#"``, ``"Bb"``, etc.).
221+ This acts as a **pitch-class filter only** — it determines which
222+ semitone positions (0–11) are valid members of the scale, but does
223+ not affect which octave notes are drawn from. Notes are selected
224+ starting from ``low`` upward; ``key`` controls *which* notes are
225+ kept, not where the sequence starts. To guarantee the first
226+ returned note is the root, ``low`` must be a MIDI number whose
227+ pitch class matches ``key``. When starting from an arbitrary MIDI
228+ number, derive the key name with
229+ ``subsequence.chords.PC_TO_NOTE_NAME[root_pitch % 12]``.
221230 mode: Scale mode name. Supports all keys of :data:`SCALE_MODE_MAP`
222231 (e.g. ``"ionian"``, ``"dorian"``, ``"natural_minor"``,
223232 ``"major_pentatonic"``). Use :func:`register_scale` for custom scales.
224233 low: Lowest MIDI note (inclusive). When ``count`` is set, this is
225- the starting note from which the scale ascends.
234+ the starting note from which the scale ascends. **If ``low`` is
235+ not a member of the scale defined by ``key``, it is silently
236+ skipped** and the first returned note will be the next in-scale
237+ pitch above ``low``.
226238 high: Highest MIDI note (inclusive). Ignored when ``count`` is set.
227239 count: Exact number of notes to return. Notes ascend from ``low``
228240 through successive scale degrees, cycling into higher octaves
@@ -248,6 +260,16 @@ def scale_notes (
248260 # 15 notes of A minor pentatonic ascending from A3
249261 subsequence.scale_notes("A", "minor_pentatonic", low=notes.A3, count=15)
250262 # → [57, 60, 62, 64, 67, 69, 72, 74, 76, 79, 81, 84, 86, 88, 91]
263+
264+ # Misalignment: key="E" but low=C4 — first note is C, not E
265+ subsequence.scale_notes("E", "minor", low=60, count=4)
266+ # → [60, 62, 64, 67] (C D E G — all in E natural minor, but starts on C)
267+
268+ # Fix: derive key name from root_pitch so low is always in the scale
269+ root_pitch = 64 # E4
270+ key = subsequence.chords.PC_TO_NOTE_NAME[root_pitch % 12] # → "E"
271+ subsequence.scale_notes(key, "minor", low=root_pitch, count=4)
272+ # → [64, 66, 67, 69] (E F# G A — starts on the root)
251273 ```
252274 """
253275
0 commit comments