Safe Haskell | Safe-Inferred |
---|
Synopsis
- data PSignal
- sig_scale_id :: PSignal -> Pitch.ScaleId
- data Scale = Scale {}
- no_scale :: Scale
- from_pairs :: [(RealTime, Pitch)] -> PSignal
- from_sample :: RealTime -> Pitch -> PSignal
- from_segments :: [Segment.Segment Pitch] -> PSignal
- to_pairs :: PSignal -> [(RealTime, Pitch)]
- to_segments :: PSignal -> [Segment.Segment Pitch]
- constant :: Pitch -> PSignal
- constant_val :: PSignal -> Maybe Pitch
- prepend :: PSignal -> PSignal -> PSignal
- type ErrorText = Text
- to_nn :: PSignal -> (Signal.NoteNumber, [(RealTime, ErrorText)])
- unfoldr :: (state -> Maybe ((RealTime, Pitch), state)) -> state -> PSignal
- null :: PSignal -> Bool
- at :: PSignal -> RealTime -> Maybe Pitch
- at_negative :: PSignal -> RealTime -> Maybe Pitch
- segment_at :: PSignal -> RealTime -> Maybe (Segment.Segment Pitch)
- interpolate :: Segment.Interpolate Pitch
- head :: PSignal -> Maybe (RealTime, Pitch)
- last :: PSignal -> Maybe (RealTime, Pitch)
- drop_after :: RealTime -> PSignal -> PSignal
- clip_after :: RealTime -> PSignal -> PSignal
- drop_before :: RealTime -> PSignal -> PSignal
- clip_before :: RealTime -> PSignal -> PSignal
- shift :: RealTime -> PSignal -> PSignal
- apply_controls :: ControlMap -> PSignal -> PSignal
- apply_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> PSignal -> PSignal
- apply_environ :: DeriveT.Environ -> PSignal -> PSignal
- map_y_linear :: (Pitch -> Pitch) -> PSignal -> PSignal
- drop_discontinuity_at :: RealTime -> PSignal -> PSignal
- type Transposed = RawPitch DeriveT.Transposed_
- type Pitch = RawPitch DeriveT.Untransposed_
- data RawPitch a
- data PitchConfig = PitchConfig !DeriveT.Environ !ScoreT.ControlValMap
- symbolic_pitch :: RawPitch a -> Text
- pitch_scale_id :: RawPitch a -> Pitch.ScaleId
- pitch_transposers :: Pitch -> Set ScoreT.Control
- pitch_scale :: RawPitch a -> Scale
- pitch_eval_nn :: RawPitch a -> PitchConfig -> Either.Either PitchError Pitch.NoteNumber
- pitch_eval_note :: RawPitch a -> PitchConfig -> Either.Either PitchError Pitch.Note
- pitch_config :: RawPitch a -> PitchConfig
- pitch_controls :: PitchConfig -> Map ScoreT.Control Signal.Y
- data PitchError
- pitch :: Scale -> (PitchConfig -> Either.Either PitchError Pitch.NoteNumber) -> (PitchConfig -> Either.Either PitchError Pitch.Note) -> PitchConfig -> Pitch
- coerce :: RawPitch a -> RawPitch b
- apply_config :: PitchConfig -> RawPitch a -> RawPitch b
- apply :: Map ScoreT.Control Signal.Y -> Pitch -> Transposed
- add_control :: ScoreT.Control -> Double -> RawPitch a -> RawPitch a
- pitch_nn :: Transposed -> Either.Either PitchError Pitch.NoteNumber
- pitch_note :: Transposed -> Either.Either PitchError Pitch.Note
- constant_pitch :: Pitch.ScaleId -> Pitch.Note -> Pitch.NoteNumber -> Pitch
- nn_pitch :: Pitch.NoteNumber -> Pitch
Documentation
A pitch signal is similar to a Signal.Control
, except that its values
are Pitch
es instead of plain floating point values.
Instances
sig_scale_id :: PSignal -> Pitch.ScaleId Source #
Get the scale id of the signal.
A PSignal can contain pitches from multiple scales, though I don't think this should ever happen. But if it does, the first pitch wins.
PSignal can't take a Scale because that would be a circular import. Fortunately it only needs a few fields. However, because of the circularity, the Scale.Scale -> PSignal.Scale constructor is in Derive.Derive.
Scale | |
|
construct / destruct
from_segments :: [Segment.Segment Pitch] -> PSignal Source #
to_segments :: PSignal -> [Segment.Segment Pitch] Source #
to_nn :: PSignal -> (Signal.NoteNumber, [(RealTime, ErrorText)]) Source #
Flatten a signal to a non-transposeable Signal.NoteNumber. TODO I could probably avoid the intermediate list
query
segment_at :: PSignal -> RealTime -> Maybe (Segment.Segment Pitch) Source #
interpolate :: Segment.Interpolate Pitch Source #
A pitch interpolated a certain distance between two other pitches.
transform
apply_controls :: ControlMap -> PSignal -> PSignal Source #
Resample the signal according to the sig_transposers
and apply the given
controls to the signal.
Controls are added so if this is not correct for a given control then this will do the wrong thing. Transpose signals should be additive so it'll be ok as long as you only apply transposing signals and only apply the complete ControlMap once at the end (i.e. Perform.Midi.Convert).
apply_control :: ScoreT.Control -> ScoreT.Typed Signal.Control -> PSignal -> PSignal Source #
apply_controls
specialized for a single control.
apply_environ :: DeriveT.Environ -> PSignal -> PSignal Source #
Apply an environ to all the pitches in the signal. Unlike
apply_controls
, this doesn't have to resample the signal.
hacks
Pitch
type Transposed = RawPitch DeriveT.Transposed_ Source #
The transposed version of Pitch
.
type Pitch = RawPitch DeriveT.Untransposed_ Source #
This is an untransposed pitch. All pitches have transposition signals from the dynamic state applied when they are converted to MIDI or whatever backend. So if I want the final concrete pitch, I have to apply the transposition signals. But if I want to emit a note with this pitch, I want the untransposed one, or the transposition will be applied twice. I use a phantom type parameter to keep them straight.
A pitch is an abstract value that can generate a Pitch.NoteNumber
or
symbolic Pitch.Note
.
Instances
ToVal Pitch Source # | |
Defined in Derive.Typecheck to_val :: Pitch -> DeriveT.Val Source # | |
Typecheck Pitch Source # | |
Typecheck DeriveT.PitchFunction Source # | |
Defined in Derive.Typecheck | |
Show (RawPitch a) Source # | |
NFData (RawPitch a) Source # | It can't be reduced since it has lambdas, but at least this way you can easily rnf things that contain it. |
Defined in Derive.DeriveT | |
ShowVal (RawPitch a) Source # | Pitches have no literal syntax, but I have to print something. |
Pretty (RawPitch a) Source # | Will look like: 62.95nn,4i(*wayang) |
data PitchConfig Source #
A PitchConfig is the data that can continue to influence the pitch's frequency.
Pitches are configured by controls and by an environ. The controls
are for values that change over time, such as transposition or tuning.
They're combined additively, which is really only appropriate for
transposition. Controls are mostly applied only on conversion to the
performer. TODO I don't entirely remember why. However, this leads to
some trickiness because if I want to compare a pitch to an absolute
NoteNumber, I need the final transposed value, but if I put it in an event
it must be untransposed, or transposition will be applied twice.
To avoid double. To avoid this, there's a phantom type parameter to
distinguish an untransposed Pitch
from a Transposed
one.
The Environ is for symbolic configuration, such as key or tuning mode. Unlike controls, though, it's taken from the environ in scope when the pith is created. Otherwise, you can't evaluate a pitch with a different key by setting the environ.
Instances
Monoid PitchConfig Source # | |
Defined in Derive.DeriveT mempty :: PitchConfig # mappend :: PitchConfig -> PitchConfig -> PitchConfig # mconcat :: [PitchConfig] -> PitchConfig # | |
Semigroup PitchConfig Source # | |
Defined in Derive.DeriveT (<>) :: PitchConfig -> PitchConfig -> PitchConfig # sconcat :: NonEmpty PitchConfig -> PitchConfig # stimes :: Integral b => b -> PitchConfig -> PitchConfig # | |
Show PitchConfig Source # | |
Defined in Derive.DeriveT showsPrec :: Int -> PitchConfig -> ShowS # show :: PitchConfig -> String # showList :: [PitchConfig] -> ShowS # | |
Pretty PitchConfig Source # | |
Defined in Derive.DeriveT pretty :: PitchConfig -> Text Source # format :: PitchConfig -> Doc Source # formatList :: [PitchConfig] -> Doc Source # |
symbolic_pitch :: RawPitch a -> Text Source #
This is like pretty for pitch, but just shows the symbolic note name.
pitch_scale_id :: RawPitch a -> Pitch.ScaleId Source #
pitch_scale :: RawPitch a -> Scale Source #
pitch_config :: RawPitch a -> PitchConfig Source #
data PitchError Source #
Things that can go wrong evaluating a pitch.
UnparseableNote !Pitch.Note | |
OutOfRangeError !DeriveT.OutOfRange | |
InvalidInput | Input note doesn't map to a scale note. |
EnvironError !Key !(Maybe Text) | A required environ value was missing or had the wrong type or value. Nothing if the value is missing, otherwise a Text description. |
ControlError !ScoreT.Control !Text | Same as EnvironError, but for control vals. |
NotImplemented | The scale doesn't implement that operation. |
PitchError !Text | Other kind of error. |
Instances
Show PitchError Source # | |
Defined in Derive.DeriveT showsPrec :: Int -> PitchError -> ShowS # show :: PitchError -> String # showList :: [PitchError] -> ShowS # | |
Eq PitchError Source # | |
Defined in Derive.DeriveT (==) :: PitchError -> PitchError -> Bool # (/=) :: PitchError -> PitchError -> Bool # | |
Ord PitchError Source # | |
Defined in Derive.DeriveT compare :: PitchError -> PitchError -> Ordering # (<) :: PitchError -> PitchError -> Bool # (<=) :: PitchError -> PitchError -> Bool # (>) :: PitchError -> PitchError -> Bool # (>=) :: PitchError -> PitchError -> Bool # max :: PitchError -> PitchError -> PitchError # min :: PitchError -> PitchError -> PitchError # | |
Pretty PitchError Source # | |
Defined in Derive.DeriveT pretty :: PitchError -> Text Source # format :: PitchError -> Doc Source # formatList :: [PitchError] -> Doc Source # |
pitch :: Scale -> (PitchConfig -> Either.Either PitchError Pitch.NoteNumber) -> (PitchConfig -> Either.Either PitchError Pitch.Note) -> PitchConfig -> Pitch Source #
Make an abstract Pitch.
apply_config :: PitchConfig -> RawPitch a -> RawPitch b Source #
Apply a config to a pitch.
apply :: Map ScoreT.Control Signal.Y -> Pitch -> Transposed Source #
Apply just the controls part of a config to a pitch.
add_control :: ScoreT.Control -> Double -> RawPitch a -> RawPitch a Source #
pitch_nn :: Transposed -> Either.Either PitchError Pitch.NoteNumber Source #
Usually I only want to evaluate a fully transposed pitch. Exceptions
are documented by applying coerce
.
pitch_note :: Transposed -> Either.Either PitchError Pitch.Note Source #
Usually I only want to evaluate a fully transposed pitch. Exceptions
are documented by applying coerce
.
create
constant_pitch :: Pitch.ScaleId -> Pitch.Note -> Pitch.NoteNumber -> Pitch Source #
Create a Pitch that only emits the given NoteNumber, and doesn't respond to transposition.
nn_pitch :: Pitch.NoteNumber -> Pitch Source #
Like constant_pitch
, but easier to use, but uses no_scale, which means
the result will be unparseable.