Karya, built on Mon Jul 24 11:39:07 PDT 2017 (patch 33511aca01257b76b88de7c7a2763b7a965c084e)

Safe Haskell None

Derive.PSignal

Synopsis

# Documentation

data PSignal Source #

A pitch signal is similar to a Signal.Control, except that its values are Pitches instead of plain floating point values.

Instances

 # MethodsshowList :: [PSignal] -> ShowS # # Methodsmconcat :: [PSignal] -> PSignal # # Methodsrnf :: PSignal -> () # # Methods # MethodsformatList :: [PSignal] -> Doc Source # # There's no way to convert a pitch back into the expression that produced it, so this is the best I can do.Similar to ShowVal BaseTypes.ControlRef, there's no signal literal so I use the value at 0. A pitch can be turned into an expression, but not necessarily accurately since it doesn't take things like pitch interpolation into account. Methods # Methods # Methods # Methods # Methods # Methods # Methods

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.

data Scale Source #

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.

Constructors

 Scale !Pitch.ScaleId !(Set Score.Control)

Instances

 # MethodsshowsPrec :: Int -> Scale -> ShowS #show :: Scale -> String #showList :: [Scale] -> ShowS # # MethodsformatList :: [Scale] -> Doc Source #

# construct and convert

Set the signal value, with a discontinuity.

Flatten a signal to a non-transposeable Signal.NoteNumber.

unfoldr :: (state -> Maybe ((RealTime, Pitch), state)) -> state -> PSignal Source #

# apply controls

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 are probably mostly 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_controls specialized for a single control.

Apply an environ to all the pitches in the signal. Unlike apply_controls, this doesn't have to resample the signal.

# signal functions

Find the last pitch before the point.

data Sample y Source #

Constructors

 Sample Fieldssx :: !X sy :: !y

Instances

 Eq y => Eq (Sample y) # Methods(==) :: Sample y -> Sample y -> Bool #(/=) :: Sample y -> Sample y -> Bool # Read y => Read (Sample y) # MethodsreadsPrec :: Int -> ReadS (Sample y) #readList :: ReadS [Sample y] # Show y => Show (Sample y) # MethodsshowsPrec :: Int -> Sample y -> ShowS #show :: Sample y -> String #showList :: [Sample y] -> ShowS # # MethodspeekElemOff :: Ptr (Sample Double) -> Int -> IO (Sample Double) #pokeElemOff :: Ptr (Sample Double) -> Int -> Sample Double -> IO () #peekByteOff :: Ptr b -> Int -> IO (Sample Double) #pokeByteOff :: Ptr b -> Int -> Sample Double -> IO () #peek :: Ptr (Sample Double) -> IO (Sample Double) #poke :: Ptr (Sample Double) -> Sample Double -> IO () # # MethodstoJSONList :: [Sample Double] -> Value # # Methods # MethodspokeElemOff :: Ptr (Sample Double) -> Int -> Sample Double -> IO () Source #peekByteOff :: Ptr b -> Int -> IO (Sample Double) Source #pokeByteOff :: Ptr b -> Int -> Sample Double -> IO () Source #poke :: Ptr (Sample Double) -> Sample Double -> IO () Source # Serialize y => Serialize (Sample y) # Methodsget :: Get (Sample y) Source #

# Pitch

The transposed version of Pitch.

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.

data RawPitch a Source #

A pitch is an abstract value that can generate a Pitch.NoteNumber or symbolic Pitch.Note.

Instances

 # Methods # Methods Show (RawPitch a) # MethodsshowsPrec :: Int -> RawPitch a -> ShowS #show :: RawPitch a -> String #showList :: [RawPitch a] -> ShowS # # It can't be reduced since it has lambdas, but at least this way you can easily rnf things that contain it. Methodsrnf :: RawPitch a -> () # # Will look like: 62.95nn,4i(*wayang) Methodsformat :: RawPitch a -> Doc Source #formatList :: [RawPitch a] -> Doc Source # # Pitches have no literal syntax, but I have to print something. Methods

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.

Constructors

 PitchConfig !BaseTypes.Environ !Score.ControlValMap

Instances

 # MethodsshowList :: [PitchConfig] -> ShowS # # Methodsmconcat :: [PitchConfig] -> PitchConfig # # MethodsformatList :: [PitchConfig] -> Doc Source #

This is like pretty for pitch, but just shows the symbolic note name.

Things that can go wrong evaluating a pitch.

Constructors

 UnparseableNote OutOfRange !(Maybe Pitch.NoteNumber) !Score.ControlValMap Note out of the scale's range. The values are transpositions from the environment, in case it was out of range because of a transposition.Some scales have a restricted range, in which case they should throw BaseTypes.out_of_range, which pitch_nn and pitch_note will annotate with the transposition signals. Other scales have unlimited range, in which case they're limited by the backend. In this case pitch_nn checks 0--127, which happens to be MIDI's limitation. InvalidInput Input note doesn't map to a scale note. EnvironError !BaseTypes.Key !Text A required environ value was missing or had the wrong type or value. The Text is a show_val of the wrong Val. ControlError !Score.Control !Text Same as EnvironError, but for control vals. NotImplemented The scale doesn't implement that operation. PitchError !Text Other kind of error.

Instances

 # Methods # Methods # MethodsshowList :: [PitchError] -> ShowS # # MethodsformatList :: [PitchError] -> Doc Source #

Make an abstract Pitch.

Apply a config to a pitch.

Apply just the controls part of a config to a pitch.

Usually I only want to evaluate a fully transposed pitch. Exceptions are documented by applying coerce.

Usually I only want to evaluate a fully transposed pitch. Exceptions are documented by applying coerce.

## create

Create a Pitch that only emits the given NoteNumber, and doesn't respond to transposition.