Euterpea Cheat Sheet

From MCIS Wiki
Jump to: navigation, search

Notes

note :: Dur -> a -> Music a
rest :: Dur -> Music a
cff , cf , c, cs, css, dff , df , d, ds, dss, eff , ef , e, es, ess, fff , ff , f ,
fs, fss, gff , gf , g, gs, gss, aff , af , a, as, ass, bff , bf , b, bs, bss ::
                   Octave -> Dur -> Music Pitch

bn, wn, hn, qn, en, sn, tn, sfn, dwn, dhn,
dqn, den, dsn, dtn, ddhn, ddqn, dden :: Dur
bnr, wnr , hnr , qnr , enr, snr, tnr, dwnr , dhnr ,
dqnr , denr , dsnr , dtnr, ddhnr , ddqnr , ddenr :: Music Pitch
bn = 2; bnr = rest bn -- brevis rest
wn = 1; wnr = rest wn -- whole note rest
hn = 1/2; hnr = rest hn -- half note rest
qn = 1/4; qnr = rest qn -- quarter note rest
en = 1/8; enr = rest en -- eighth note rest
sn = 1/16; snr = rest sn -- sixteenth note rest
tn = 1/32; tnr = rest tn -- thirty-second note rest
sfn = 1/64; sfnr = rest sfn -- sixty-fourth note rest
dwn = 3/2; dwnr = rest dwn -- dotted whole note rest
dhn = 3/4; dhnr = rest dhn -- dotted half note rest
dqn = 3/8; dqnr = rest dqn -- dotted quarter note rest
den = 3/16; denr = rest den -- dotted eighth note rest
dsn = 3/32; dsnr = rest dsn -- dotted sixteenth note rest
dtn = 3/64; dtnr = rest dtn -- dotted thirty-second note rest
ddhn = 7/8; ddhnr = rest ddhn -- double-dotted half note rest
ddqn = 7/16; ddqnr = rest ddqn -- double-dotted quarter note rest

Basic Music Operations

-- Combiners
(:+:) :: Music a -> Music a -> Music a   -- Play one piece of music after the other
(:=:) :: Music a -> Music a -> Music a   -- Play two pieces of music at the same time
(/=:) :: Music a -> Music a -> Music a   -- Play the left music no longer that the right one

-- Modifiers
tempo :: Dur -> Music a -> Music a    -- Dur is a scale factor.  2 would make music go twice as fast
transpose :: AbsPitch -> Music a -> Music a  -- AbsPitch is an integer
instrument :: InstrumentName -> Music a -> Music a
phrase :: [PhraseAttribute] -> Music a -> Music a
player :: PlayerName -> Music a -> Music a

-- Instrument Names

AcousticGrandPiano | BrightAcousticPiano | ElectricGrandPiano
| HonkyTonkPiano | RhodesPiano | ChorusedPiano
| Harpsichord | Clavinet | Celesta
| Glockenspiel | MusicBox | Vibraphone
| Marimba | Xylophone | TubularBells
| Dulcimer | HammondOrgan | PercussiveOrgan
| RockOrgan | ChurchOrgan | ReedOrgan
| Accordion | Harmonica | TangoAccordion
| AcousticGuitarNylon | AcousticGuitarSteel | ElectricGuitarJazz
| ElectricGuitarClean | ElectricGuitarMuted | OverdrivenGuitar
| DistortionGuitar | GuitarHarmonics | AcousticBass
| ElectricBassFingered | ElectricBassPicked | FretlessBass
| SlapBass1 | SlapBass2 | SynthBass1
| SynthBass2 | Violin | Viola
| Cello | Contrabass | TremoloStrings
| PizzicatoStrings | OrchestralHarp | Timpani
| StringEnsemble1 | StringEnsemble2 | SynthStrings1
| SynthStrings2 | ChoirAahs | VoiceOohs
| SynthVoice | OrchestraHit | Trumpet
| Trombone | Tuba | MutedTrumpet
| FrenchHorn | BrassSection | SynthBrass1
| SynthBrass2 | SopranoSax | AltoSax
| TenorSax | BaritoneSax | Oboe
| Bassoon | EnglishHorn | Clarinet
| Piccolo | Flute | Recorder
| PanFlute | BlownBottle | Shakuhachi
| Whistle | Ocarina | Lead1Square
| Lead2Sawtooth | Lead3Calliope | Lead4Chiff
| Lead5Charang | Lead6Voice | Lead7Fifths
| Lead8BassLead | Pad1NewAge | Pad2Warm
| Pad3Polysynth | Pad4Choir | Pad5Bowed
| Pad6Metallic | Pad7Halo | Pad8Sweep
| FX1Train | FX2Soundtrack | FX3Crystal
| FX4Atmosphere | FX5Brightness | FX6Goblins
| FX7Echoes | FX8SciFi | Sitar
| Banjo | Shamisen | Koto
| Kalimba | Bagpipe | Fiddle
| Shanai | TinkleBell | Agogo
| SteelDrums | Woodblock | TaikoDrum
| MelodicDrum | SynthDrum | ReverseCymbal
| GuitarFretNoise | BreathNoise | Seashore
| BirdTweet | TelephoneRing | Helicopter
| Applause


Other functions:

timesM :: Int -> Music a -> Music a  -- Repeat n times
grace :: Int -> Rational -> Music Pitch -> Music Pitch  -- Grace note.  Relative pitch, duration, note

Signal Functions

Create an envelope using line segments.

envLineSeg :: Clock p => 
              [Double]  -- List of points to trace through.
           -> [Double]  -- List of durations for each line segment.
                      -- Needs to be one element fewer than 'amps'.
           -> Signal p () Double

Trace a series of exponential segments between specified points.

envExponSeg :: Clock p => 
           [Double]  -- List of points to trace through.
        -> [Double]  -- List of durations for each line segment.
                     -- Needs to be one element fewer than 'amps'.
        -> Signal p () Double

Creates a straight-line rise and decay envelope. Rise modifications are applied for the first 'rise' seconds, and decay from time 'dur' - 'dec'. If these periods are separated in time there will be a steady state during which the output will remain constant. If the overall duration idur is exceeded in performance, the final decay will continue on in the same direction, going negative.

envASR :: (Clock p) =>
         Double  -- rise time in seconds.
      -> Double  -- overall duration in seconds.
      -> Double  -- decay time in seconds.
      -> Signal p () Double

Apply an envelope consisting of 3 segments:

  1. stored function rise shape
  2. modified exponential pseudo steady state
  3. exponential decay

Rise modifications are applied for the first 'rise' seconds, and decay from time 'dur' - 'dec'. If these periods are separated in time the output will be modified by the first exponential pattern. If rise and decay periods overlap then both modifications will be in effect for that time. If the overall duration 'dur' is exceeded in performance, the final decay will continue on in the same direction, tending asymptotically to zero.

envCSEnvlpx :: forall p . Clock p =>
          Double  -- rise time in seconds.
       -> Double  -- overall duration in seconds.
       -> Double  -- decay time in seconds.
       -> Table   -- table of stored rise shape.
       -> Double  
          -- attenuation factor, by which the last value of the
          -- 'envCSEnvlpx' rise is modified during the note's pseudo
          -- steady state. A factor greater than 1 causes an
          -- exponential growth and a factor less than 1 creates an
          -- exponential decay. A factor of 1 will maintain a true
          -- steady state at the last rise value. Note that this
          -- attenuation is not by fixed rate (as in a piano), but
          -- is sensitive to a note's duration. However, if 'atss'
          -- is negative (or if steady state < 4 k-periods) a fixed
          -- attenuation rate of 'abs' 'atss' per second will be
          -- used. 0 is illegal.
       -> Double  
          -- attenuation factor by which the closing steady state
          -- value is reduced exponentially over the decay
          -- period. This value must be positive and is normally of
          -- the order of .01. A large or excessively small value is
          -- apt to produce a cutoff which is audible. A zero or
          -- negative value is illegal.
       -> Signal p () Double