Haskore Musikbearbeitung mit Haskell Paul Hudak, Yale University, USA

Slides:



Advertisements
Similar presentations
Chapter 20 Functional Music Composition. MDL: Music Description Language MDL is a DSL for computer music composition that is even simpler than FAL and.
Advertisements

Peter Rademaker & Robert Stremler. Preview 1.Introduction 2.The Basics 3.Simple Examples 4.Interpretation and Performance 5.MIDI 6.Algebraic Properties.
Instruments of the Orchestra Revision. There are 4 families of instruments in the orchestra:  Strings  Brass  Woodwind  Percussion.
Instrument Families.
Questions on Orchestra Family Instruments
Instrumental Families
Timbre A description of the actual sounds that you hear. “Tone color” or “quality”
Chapter 2: PERFORMING MEDIA  Voices/Singing Ten important points 1. There is a much wider range of pitch and volume than is used in speaking 2. Vowel.
Understanding Music - Instrumental Music. What we will be learning about in this topic...
Families of Musical Instruments
Families and Classifications of Instruments
Music Appreciation Musical Instruments.
Y Fernandez- CMS Instruments 1. Families of Instruments String Instruments Violin Viola Cello Double Bass Violin Viola Cello Double Bass.
Music JEOPARDY Family of Instruments By A. Vilcins
Instruments of the Orchestra
MGC (Music Generator for Composing). Pronunciation MGC MGC mmmmGiC mmmmGiC Magic Magic.
Elements of Music. Harmony Two or more notes together Two or more notes together Chord – three or more notes at one time Chord – three or more notes at.
Cse536 Functional Programming 1 5/16/2015 Lecture #19, Dec 1 & 6, 2004 Todays Topics – Haskore System –The Music datatype –MIDI Instruments –Pitch & absolute.
The Stars and Stripes Forever
Cse536 Functional Programming 1 6/17/2015 Lecture #19, Dec 1 & 6, 2004 Todays Topics – Haskore System –The Music datatype –MIDI Instruments –Pitch & absolute.
ElementsSoundHistory Note equal in value to 1/4 that of a whole note.
MGC (Music Generator for Composing). Pronunciation MGC MGC mmmmGiC mmmmGiC Magic Magic.
Musical Instruments.
MUSICAL INSTRUMENTS CLASSIFICATION. 1. STRING INSTRUMENTS A string instrument is a musical instrument that produces sound by string that vibrates. They.
Presented By: Miss Cross.  There are four main types of instruments: ◦ Winds ◦ Brass ◦ Strings ◦ Percussion  Which instruments belong to which categories?
Musical Instruments Grade Ten Music.
Elements of Music Music History.
Music Core Content.
Which instruments are members of the percussion family? A.) violin, viola, cello B.) xylophone, snare drum bass drum C.) oboe, bassoon, clarinet,
Performing Media: Voices and Instruments.  Singing most widespread and familiar way of making music.  Differences in cultural tastes the tone color.
Musical Instruments.
The Instruments of the Orchestra 4 Families of Instruments Strings Winds Brass Percussion.
Year 7.  Music Theory (Pitch and Rhythm)  Melody Writing Rules  Instruments of the Orchestra, including their families and pitch range  Benjamin Britten’s.
Musical Instrument Families. Why are there different families Each instrument family has their own unique TIMBRE or sound How is sound produced –By vibrations!
Instruments of the orchestra. Instrument Families By the end of this lesson you should: Know what an orchestra is Understand the layout of an orchestra.
Chapter 7 Western Musical Instruments. Strings They are bowed and plucked – Violin – Viola – Cello (also Violoncello) – Double Bass.
SPELLING PRACTISE. ORCHESTRA 1. Write the word. Spell it, Study it, Remember it.
Instruments. Strings Commonly made of wood and strings (usually four). Played by drawing a bow across the strings or plucking the strings. Examples: violin,
Music By: Raegan Light.
Instruments.  Which categories would you consider instruments to fall under?  Melody  Harmony  Rhythm/Beat  Dynamics So where would instruments fall…
Instruments are grouped into 4 major families  Brass instruments all share these characteristics  They are made of metal and have a brass finish 
Orchestral Seating Chart ► The symphony orchestra is composed of three groups: Strings, Winds and Percussion ► The String section consists of basses, cellos,
1. Woodwind 2. Brass 3. Strings 4. Percussion/Keyboard.
Music Core Content Instrument Families Voice Parts Brass S oprano Woodwind A lto String T enor Percussion Bass How each instrument or voice sounds.
Each corner of the room is a different answer (A, B, C, or D)
Musical Instruments.
Instruments of the H R O S C A E T R.
Instruments of the Orchestra. There are four “families” of instruments Woodwinds Strings Brass Percussion.
Musical Instruments. Instrument Families There are four instrument families –Brass Instruments –Woodwind Instruments –Percussion Instruments –String Instruments.
Music Instruments Band Welcome to your first day! This quarter you will: Learn to read music Learn the instrument families and instruments!
Performance media INSTRUMENTS = mechanism other than a voice that produces musical sounds. (single note or multi) CLASSES OF INSTRUMENTS 1 WOODWIND 2 BRASS.

The Orchestra.
Musical instrument families
Types of Musical Groups and Ensembles
Introduction to Music Musical Instruments
Musical Instruments and Ensembles
Chapter 2—Performing Media: Voices and Instruments
Music Appreciation Musical Instruments.
Flute, Clarinet, Oboe, Bassoon & Saxophone
Family Categories Strings Strings Woodwinds Woodwinds Brass Brass Percussion Percussion.
Instrumentation and Transposition
A Variety of Instruments and the Families in Which They Belong
Benjamin Britten's The Young Person's Guide to the Orchestra.
Family Of Instruments Test
Compositional Functional Programming with the Haskore Music
INSTRUMENTS OF THE ORCHESTRA AND CONCERT BAND
Inputting Instrument Information into Destiny
Compositional Functional Programming with the Haskore Music
Performing Media: Voices & Instruments
Presentation transcript:

Haskore Musikbearbeitung mit Haskell Paul Hudak, Yale University, USA

type Pitch = (PitchClass, Octave) -- (A,4) = A440 (440Hz) data PitchClass = Cf | C | Cs | Df | D | Ds | Ef | E | Es | Ff | F | Fs | Gf | G | Gs | Af | A | As | Bf | B | Bs deriving (Eq,Show) type Octave = Int data Music = Note Pitch Dur [NoteAttribute]| Rest Dur | Music :+: Music | Music :=: Music | Tempo (Ratio Int) Music | Trans Int Music | Instr IName Music | Player PName Music | Phrase [PhraseAttribute] Music deriving (Show, Eq) type Dur = Ratio Int -- (%) :: (Integral a) => a -> a -> Ratio a Der Datentyp Music

Instrumente des MIDI Standards Acoustic Grand Piano | Bright Acoustic Piano | Electric Grand Piano | Honky Tonk Piano | Rhodes Piano | Chorused Piano | Harpsichord | Clavinet | Celesta | Glockenspiel | Music Box | Vibraphone | Marimba | Xylophone | Tubular Bells | Dulcimer | Hammond Organ | Percussive Organ | Rock Organ | Church Organ | Reed Organ | Accordion | Harmonica | Tango Accordion | Acoustic Guitar (nylon) | Acoustic Guitar (steel) | Electric Guitar (jazz) | Electric Guitar (clean) | Electric Guitar (muted) | Overdriven Guitar | Distortion Guitar | Guitar Harmonics | Acoustic Bass | Electric Bass (fingered) | Electric Bass (picked) | Fretless Bass | Slap Bass 1 | Slap Bass 2 | Synth Bass 1 | Synth Bass 2 | Violin | Viola | Cello | Contrabass | Tremolo Strings | Pizzicato Strings | Orchestral Harp | Timpani | String Ensemble 1 | String Ensemble 2 | Synth Strings 1 | Synth Strings 2 | Choir Aahs..... Musical Instrument Digital Interface

an der Zahl | Voice Oohs | SynthVoice | OrchestraHit | Trumpet | Trombone | Tuba | Muted Trumpet | French Horn | Brass Section | Synth Brass 1 | Synth Brass 2 | Soprano Sax | Alto Sax | Tenor Sax | Baritone Sax | Oboe | Bassoon | English Horn | Clarinet | Piccolo | Flute | Recorder | Pan Flute | Blown Bottle | Shakuhachi | Whistle | Ocarina | Lead 1 (square) | Lead 2 (sawtooth) | Lead 3 (calliope) | Lead 4 (chiff) | Lead 5 (charang) | Lead 6 (voice) | Lead 7 (fifths) | Lead 8 (bass+lead) | Pad 1 (new age) | Pad 2 (warm) | Pad 3 (polysynth) | Pad 4 (choir) | Pad 5 (bowed) | Pad 6 (metallic) | Pad 7 (halo) | Pad 8 (sweep) | FX1 (train) | FX2 (soundtrack) | FX3 (crystal) | FX4 (atmosphere) | FX5 (brightness) FX6 (goblins) | FX7 (echoes) | FX8 (sci-fi) | Sitar | Banjo | Shamisen | Koto | Kalimba | Bagpipe | Fiddle | Shanai | TinkleBell | Agogo | Steel Drums | Woodblock | Taiko Drum| Melodic Drum | Synth Drum | Reverse Cymbal | Guitar Fret Noise | Breath Noise | Seashore | Bird Tweet | TelephoneRing | Helicopter | Applause | Gunshot | Percussion deriving (Show,Eq,Ord,Enum)

Transponieren type AbsPitch = Int absPitch :: Pitch -> AbsPitch absPitch (pc,oct) = 12*oct + pcToInt pc pitch :: AbsPitch -> Pitch pitch ap = ( [C,Cs,D,Ds,E,F,Fs,G,Gs,A,As,B] !! mod ap 12, quot ap 12 ) trans :: Int -> Pitch -> Pitch trans i p = pitch (absPitch p + i) pcToInt :: PitchClass -> Int pcToInt pc = case pc of Cf -> should Cf be 11? C -> 0 Cs -> 1 Df -> 1 D -> 2 Ds -> 3 Ef -> 3 E -> 4 Es -> 5 Ff -> 4 F -> 5 Fs -> 6 Gf -> 6 G -> 7 Gs -> 8 Af -> 8 A -> 9 As -> 10 Bf -> 10 B -> 11 Bs -> should Bs be 0?

Noten und Pausenbezeichnungen cf, c, cs, df, d, ds, ef, e, es, ff, f, fs, gf, g, gs, af, a, as, bf, b, bs :: Octave -> Dur -> [NoteAttribute] -> Music cf o = Note (Cf,o); c o = Note (C,o); cs o = Note (Cs,o) df o = Note (Df,o); d o = Note (D,o); ds o = Note (Ds,o)... wn, hn, qn, en, sn, tn, dhn, dqn, den, dsn:: Dur wnr, hnr, qnr, enr, snr, tnr, dhnr, dqnr, denr, dsnr:: Music wn = 1; wnr = Rest wn-- whole hn = 1%2; hnr = Rest hn-- half qn = 1%4; qnr = Rest qn-- quarter... dhn = 3%4; dhnr = Rest dhn-- dotted half dqn = 3%8; dqnr = Rest dqn-- dotted quarter...

Beispiel: Alle Jahre wieder ajw :: Music ajw = let o = 4 in (g o dqn [] :+: a o en [] :+: g o qn [] :+: f o qn [] ) :+: (e o hn [] :+: d o hn [] ) :+: (c o qn [] :+: d o en [] :+: e o en [] :+: f o qn [] :+: e o qn []) :+: d o dhn [] :+: qnr :+: e o qn [] :+: g o qn [] :+: a o qn [] :+: g o qn [] :+: c (o+1) hn [] :+: b o qn [] :+: a o qn [] :+: g o qn [] :+: f o en [] :+: e o en [] :+: f o qn [] :+: g o qn [] :+: e o dhn [] :+: qnr

Abspielen von Musik test :: Music -> IO () test m = outputMidiFile "test.mid" (performToMidi (testPerf m) defUpm) testPerf :: Music -> Performance testPerf m = perform defPMap defCon m defCon :: Context -- a default Context defPMap :: String -> Player -- default player map defUpm :: UserPatchMap -- default user patch map play m = do test m; system wmplayer test.mid; return ()

Nützliche Hilfsfunktionen Notenfolgen und Akkorde: line, chord:: [Music] -> Music line= foldr (:+:) (Rest 0) chord= foldr (:=:) (Rest 0) Beispiel: C major arpeggio und C Akkord: cMaj= [ n 4 qn [] | n <- [c, e, g] ] cMajArp= line cMaj cMajChd= chord cMaj Wiederholung (endlich oder unendlich) repeatNM :: Int -> Music -> Music repeatNM n m = m :+: repeatM m (n-1) repeatNM 0 m = Rest 0 Verzögerung delay:: Dur -> Music -> Music delay d m = Rest d :+: m Umkehrung revM :: Music -> Music

Musik rückwärts spielen revM :: Music -> Music revM _ _ _)= n revM _) = r revM (Tempo a m) = Tempo a (revM m) revM (Trans i m) = Trans i (revM m) revM (Instr i m) = Instr i (revM m) revM (Phrase pas m) = Phrase pas (revM m) revM (m1 :+: m2) = revM m2 :+: revM m1 revM (m1 :=: m2) = let d1 = dur m1 -- Musikdauer bestimmen d2 = dur m2 in if d1>d2 then revM m1 :=: (Rest (d1-d2) :+: revM m2) else (Rest (d2-d1) :+: revM m1) :=: revM m2

Begleitung Aus dem Midi Standard: data PercussionSound = AcousticBassDrum-- MIDI Key 35 | BassDrum1 | SideStick | AcousticSnare |... | MuteCuica | OpenCuica | MuteTriangle | OpenTriangle-- MIDI Key 82 deriving (Show,Eq,Ord,Ix,Enum) Umwandlung in Musik: perc :: PercussionSound -> Dur -> Music perc ps = Note (pitch (fromEnum ps + 35)) Beispiel: funkGroove = let p1 = perc LowTom qn p2 = perc AcousticSnare en in Tempo 3 (Instr Percussion (cut 8 (repeatM ((p1 :+: qnr :+: p2 :+: qnr :+: p2 :+: p1 :+: p1 :+: qnr :+: p2 :+: enr) :=: roll en (perc ClosedHiHat 2) ) )))

Weitere Beispiele Wende n mal f iterativ auf Musik und g auf akkumulierte Sequenzen an: rep:: (Music -> Music) -> (Music -> Music) -> Int -> Music -> Music rep f g 0 m= Rest 0 rep f g n m= m :=: g (rep f g (n-1) (f m)) Zum Beispiel: run= rep (Trans 5) (delay tn) 8 (c 4 tn []) cascade= rep (Trans 4) (delay en) 8 run cascades= rep id (delay sn) 2 cascade waterfall= cascades :+: revM cascades

Triller trill :: Int -> Dur -> Music -> Music trill i d p nd as) = if d >= nd then n else Note p d as :+: trill (negate i) d (Note (trans i p) (nd-d) as) trill i d (Tempo a m) = Tempo a (trill i (d*a) m) trill i d (Trans a m) = Trans a (trill i d m) trill i d (Instr a m) = Instr a (trill i d m) trill i d (Player a m) = Player a (trill i d m) trill i d (Phrase a m) = Phrase a (trill i d m) trill _ _ _ = error "Trill input must be a single note" trilln :: Int -> Int -> Music -> Music trilln i nTimes m = trill i (dur m / (nTimes%1)) m

Stars and Stripes forever ssfMelody = line (m1 ++ m2 ++ m3 ++ m4) m1 = [trilln 2 5 (bf 6 en []), Phrase [Art staccato] (line [ef 7 en [], ef 6 en [], ef 7 en []])] m2 = [Phrase [Art legato] (line [bf 6 sn [], c 7 sn [], bf 6 sn [], g 6 sn []]), Phrase [Art staccato] (line [ef 6 en [], bf 5 en []])] m3 = [Phrase [Art legato] (line [ef 6 sn [], f 6 sn [], g 6 sn [], af 6 sn []]), Phrase [Art staccato] (line [bf 6 en [], ef 7 en []])] m4 = [trill 2 tn (bf 6 qn []),bf 6 sn [], denr] ssf = Instr "flute" (Tempo 2 (ssfMelody))

Überblick