Karya, built on 2018-05-31T02:46:59 (patch 0a1a35479c514820d77330ae8a978975ba22a47a)

Derive.Scale.Scales

Description

Utilities for simple scales, which simply map pitch names to frequencies. Ok, so they also have octave structure, used by the input mechanism and to parse to Pitch.Pitches, but it can be set to the number of degrees in the scale if you don't have octaves.

Synopsis

# Documentation

Make a simple scale where there is a direct mapping from input to note to nn.

An empty scale that doesn't do anything.

# types

data DegreeMap Source #

Constructors

 DegreeMap Fieldsdm_to_semis :: Map Pitch.Note Pitch.Semi dm_to_note :: Vector.Vector Pitch.Note dm_to_nn :: Vector.Vector Pitch.NoteNumber dm_per_octave :: Pitch.SemiNumber of scale steps per octave. Actually, simple scales are just a collection of frequencies and don't need to have a notion of an octave. But since the input mechanism wants to orient around octaves, it needs to know how many keys to assign to each octave. So if your scale has no octaves, then just set this to 7, that way it lines up with the piano keyboard.dm_start_octave :: Pitch.Octave dm_start_pc :: Pitch.PitchClass
Instances
 # Instance detailsDefined in Derive.Scale.Scales MethodsshowList :: [DegreeMap] -> ShowS # # Instance detailsDefined in Derive.Scale.Scales MethodsformatList :: [DegreeMap] -> Doc Source #

Arguments

 :: Pitch.PitchClass -> Pitch.Octave The first Note is this Octave and PitchClass. -> Pitch.PitchClass -> [Pitch.Note] -> [Pitch.NoteNumber] -> DegreeMap

# scale functions

## transpose

Transpose function for a non-transposing scale.

Indicate that this scale responds to the standard set of transpose signals. It still has to implement the support in its scale_note_to_call.

## note_to_call

A specialization of note_to_call that operates on scales with a DegreeMap, i.e. a static map from notes to degrees, and from degrees to NNs.

Create a note call that respects chromatic and diatonic transposition. However, diatonic transposition is mapped to chromatic transposition, so this is for scales that don't distinguish.

## input

Input to note for simple scales without keys.

Input to NoteNumber for scales that have a direct relationship between Degree and NoteNumber.

An Input maps directly to a NoteNumber. This is an efficient implementation for scales tuned to 12TET.

This obeys Controls.octave but none of the other transposer controls. This is inconsistent with computed_input_to_nn, but trying to implement diatonic transposition would make this not so direct any more. And in any case, Cmd.MidiThru shouldn't let through any transposers other than octave.

Convert input to nn by going through note_to_call. This works for complicated scales that retune based on the environment but is more work.

### diatonic

Convert an absolute Pitch in the input keyboard's layout to a relative Pitch within a scale with the given number of diatonic steps per octave, or Nothing if that key should have no pitch.

The MIDI kbd is absolute. This means that relative scales start on different keys rather than all starting on C. For example, in C major C produces the first scale degree, while in D major D produces the first scale degree.

In addition, if the scale octave is not an even multiple of the kbd octave (7), the extra notes produce Nothing. This check has to be done to the relative PitchClass. That way, a D on a 6 note scale starting on D is 1, and a C is Nothing. Thus, the returned Pitch is relative to the given tonic, so it should be formatted as-is, without the key.

The ASCII kbd is relative. This means that relative scales always start on "C". So the tonic note of a key in a relative scale is irrelevant, C major and D major both start in the same place. Of course, they produce different frequencies, but that's the responsibility of scale_note_to_call.

Unlike absolute_to_pitch, if the scale octave is not an even multiple of the kbd octave (10), the extra notes wrap to the next highest octave.

Try to fit a note from a keyboard into a scale. Round the note up to the nearest multiple of the keyboard octave and adjust the octave accordingly.

## call_doc

Documentation of the standard scale_degree.

### DocumentedCall

Prepend a bit of text to the documentation.

# util

Arguments

 :: (Typecheck.Typecheck a, ShowVal.ShowVal a) => (a -> Maybe.Maybe val) -> Maybe.Maybe val if Just, a missing value gets this, otherwise it's an error -> EnvKey.Key -> BaseTypes.Environ -> Either BaseTypes.PitchError val

Read and parse an environ value, or throw a ScaleError.

read_environ_default :: (Typecheck.Typecheck a, ShowVal.ShowVal a) => (a -> Maybe.Maybe val) -> Maybe.Maybe a -> EnvKey.Key -> BaseTypes.Environ -> Either BaseTypes.PitchError val Source #

Like read_environ, except the default is given to the parse function.

Arguments

 :: Typecheck.TypecheckSymbol val => Maybe.Maybe val if Just, a missing value gets this, otherwise it's an error -> EnvKey.Key -> BaseTypes.Environ -> Either BaseTypes.PitchError val

This is read_environ, but for instances of Typecheck.TypecheckSymbol.

## keys

get_key :: key -> Map Pitch.Key key -> Maybe.Maybe Pitch.Key -> Either BaseTypes.PitchError key Source #

Find a key in a map, or throw a ScaleError.