Safe Haskell | Safe-Inferred |
---|
Derive.Scale
Description
Scale is actually defined in Derive.Deriver.Monad to avoid circular imports. But you should refer to it from here.
The difference between this and Derive.Scale.Scales is that this is intended for using scales, while Scales is intended for implementing them.
Synopsis
- type Layout = Vector.Vector Pitch.Semi
- data Transposition
- newtype LookupScale = LookupScale (DeriveT.Environ -> Pitch.ScaleId -> Maybe (Either DeriveT.PitchError Scale))
- data Scale = Scale {
- scale_id :: !Pitch.ScaleId
- scale_pattern :: !Text
- scale_symbols :: ![Symbol]
- scale_transposers :: !(Set Control)
- scale_read :: DeriveT.Environ -> Pitch.Note -> Either DeriveT.PitchError Pitch.Pitch
- scale_show :: DeriveT.Environ -> Pitch.Pitch -> Either DeriveT.PitchError Pitch.Note
- scale_bottom :: !Pitch.Pitch
- scale_layout :: !Layout
- scale_transpose :: !Transpose
- scale_enharmonics :: !Enharmonics
- scale_note_to_call :: !(Pitch.Note -> Maybe ValCall)
- scale_input_to_note :: !(DeriveT.Environ -> Pitch.Input -> Either DeriveT.PitchError Pitch.Note)
- scale_input_to_nn :: !(ScoreTime -> Pitch.Input -> Deriver (Either DeriveT.PitchError Pitch.NoteNumber))
- scale_call_doc :: !DocumentedCall
- lookup_scale :: Pitch.ScaleId -> Deriver (Maybe Scale)
- data Range = Range {}
- type PitchNote = DeriveT.PitchConfig -> Either DeriveT.PitchError Pitch.Note
- type PitchNn = DeriveT.PitchConfig -> Either DeriveT.PitchError Pitch.NoteNumber
- data Definition
- = Make !Pitch.ScaleId !(Text, DocumentedCall) !(DeriveT.Environ -> LookupScale -> Either DeriveT.PitchError Scale)
- | Simple !Scale
- scale_id_of :: Definition -> Pitch.ScaleId
- layout :: [Pitch.Semi] -> Layout
- no_octaves :: Layout
- diatonic_layout :: Pitch.PitchClass -> Layout
- semis_per_octave :: Layout -> Pitch.Semi
- semis_at_pc :: Layout -> Pitch.PitchClass -> Pitch.Semi
- pc_per_octave :: Layout -> Maybe Pitch.PitchClass
- diatonic_difference :: Layout -> Pitch.Pitch -> Pitch.Pitch -> Pitch.PitchClass
- chromatic_difference :: Layout -> Pitch.Pitch -> Pitch.Pitch -> Pitch.Semi
- transpose :: Transposition -> Scale -> DeriveT.Environ -> Pitch.Octave -> Pitch.Step -> Pitch.Note -> Either DeriveT.PitchError Pitch.Note
- transpose_pitch :: Transposition -> Scale -> DeriveT.Environ -> Pitch.Octave -> Pitch.Step -> Pitch.Pitch -> Either DeriveT.PitchError Pitch.Pitch
- in_range :: Range -> Pitch.Pitch -> Bool
- pitches :: Scale -> DeriveT.Environ -> [Pitch.Pitch]
- notes :: Scale -> DeriveT.Environ -> [Pitch.Note]
- note_numbers :: Scale -> DeriveT.Environ -> Deriver [Pitch.NoteNumber]
- patch_scale :: Pitch.ScaleId -> [Pitch.NoteNumber] -> Patch.Scale
- assign_keys :: Int -> [Pitch.NoteNumber] -> [(Int, Pitch.NoteNumber)]
Documentation
type Layout = Vector.Vector Pitch.Semi Source #
The number of chromatic intervals between each Pitch.PitchClass
,
starting from 0, as returned by scale_read
. The length is the number of
degrees per octave. A diatonic-only scale will have all 1s, and a scale
without octaves has an empty layout.
This is analogous to Layout
, but is intended to be a minimal
implementation that all scales can export, without having to support the
full complexity of a chromatic scale.
Combined with scale_read
and scale_show
, I can use this to do math on
scale degrees.
data Transposition Source #
Instances
Show Transposition Source # | |
Defined in Derive.Deriver.Monad Methods showsPrec :: Int -> Transposition -> ShowS # show :: Transposition -> String # showList :: [Transposition] -> ShowS # |
newtype LookupScale Source #
A scale can configure itself by looking in the environment and by looking up other scales.
Constructors
LookupScale (DeriveT.Environ -> Pitch.ScaleId -> Maybe (Either DeriveT.PitchError Scale)) |
Instances
Show LookupScale Source # | |
Defined in Derive.Deriver.Monad Methods showsPrec :: Int -> LookupScale -> ShowS # show :: LookupScale -> String # showList :: [LookupScale] -> ShowS # |
Constructors
Scale | |
Fields
|
lookup_scale :: Pitch.ScaleId -> Deriver (Maybe Scale) Source #
This is an inclusive pitch range, intended for instrument ranges.
Constructors
Range | |
Fields
|
Instances
type PitchNn = DeriveT.PitchConfig -> Either DeriveT.PitchError Pitch.NoteNumber Source #
I would much rather pass a more specific value than Environ. Unfortunately, ChromaticScales.SemisToNoteNumber needs a per-scale value (e.g. Environ.key or Environ.tuning). So pitch_nn needs to be parameterized with a "get_key" function, but it also needs Environ.key. I think it's doable by parameterizing pitch_nn and hence note_to_call and moving smap_semis_to_nn into note_to_call, but it seems complicated.
data Definition Source #
Constructors
Make !Pitch.ScaleId !(Text, DocumentedCall) !(DeriveT.Environ -> LookupScale -> Either DeriveT.PitchError Scale) | Fancy scales can configure themselves. Since you can't just look at the Scale directly, it has the ScaleId (pattern, doc) extracted. |
Simple !Scale |
layout :: [Pitch.Semi] -> Layout Source #
no_octaves :: Layout Source #
semis_per_octave :: Layout -> Pitch.Semi Source #
Number of chromatic steps in an octave. Nothing if this scale doesn't have octaves.
semis_at_pc :: Layout -> Pitch.PitchClass -> Pitch.Semi Source #
pc_per_octave :: Layout -> Maybe Pitch.PitchClass Source #
Number of diatonic steps in an octave. Nothing if this scale doesn't have
octaves. This is the same as semis_per_octave
for scales without
a diatonic/chromatic distinction.
diatonic_difference :: Layout -> Pitch.Pitch -> Pitch.Pitch -> Pitch.PitchClass Source #
chromatic_difference :: Layout -> Pitch.Pitch -> Pitch.Pitch -> Pitch.Semi Source #
transpose :: Transposition -> Scale -> DeriveT.Environ -> Pitch.Octave -> Pitch.Step -> Pitch.Note -> Either DeriveT.PitchError Pitch.Note Source #
transpose_pitch :: Transposition -> Scale -> DeriveT.Environ -> Pitch.Octave -> Pitch.Step -> Pitch.Pitch -> Either DeriveT.PitchError Pitch.Pitch Source #
pitches :: Scale -> DeriveT.Environ -> [Pitch.Pitch] Source #
Return the pitches in the scale. If the scale has an unbounded range,
this may go on forever, so zip with note_numbers
if you want the usable
range. Also, not all scales actually have defined degrees.
notes :: Scale -> DeriveT.Environ -> [Pitch.Note] Source #
Return the notes in the scale. As with pitches
, it may be unbounded.
note_numbers :: Scale -> DeriveT.Environ -> Deriver [Pitch.NoteNumber] Source #
Return pitches of the scale's degrees.
patch_scale :: Pitch.ScaleId -> [Pitch.NoteNumber] -> Patch.Scale Source #
Make a patch scale from the NoteNumbers.
assign_keys :: Int -> [Pitch.NoteNumber] -> [(Int, Pitch.NoteNumber)] Source #
Try to assign MIDI keys that correspond to the NoteNumbers, but they won't line up if there are too many NoteNumbers.