Skip to content

Discussion/Proposal: octave as int #2009

Description

@mscuthbert

Currently octaveless notes/pitches are first-class objects. You can create an F# and not specify the octave (.octave = None) -- it matches all F#s for certain searches. Great for music-theoretical representation. It throws errors on F# >= F? because who knows which F# and which F.

It's a pain for music notation layout and a frequent source of bugs -- where people expect .octave to be an int.

(You've probably forgotten about .implicitOctave which returns .octave if it's an int, and defaults.pitchOctave otherwise, which I don't think anyone has ever changed from 4 in the history of music21...)


Proposal

.octave becomes an int. Always. If not specified at object creation time it defaults to 4.

.octaveIsImplicit is a new bool that stores whether the octave was not specified. The few places that are truly None-octave aware can consult .octaveIsImplicit first. Is True at object creation but becomes False the first time octave is set.

.implicitOctave becomes a perfect synonym for .octave. It will become deprecated no earlier than v.12 (probably v.13) and removed a version or two later.

Thoughts?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions