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

Slides:



Advertisements
Similar presentations
CS4026 Formal Models of Computation Running Haskell Programs – power.
Advertisements

Haskore Musikbearbeitung mit Haskell Paul Hudak, Yale University, USA
The length of sound or silence in music reading.
Chapter 2: Rhythm and Pitch
Peter Rademaker & Robert Stremler. Preview 1.Introduction 2.The Basics 3.Simple Examples 4.Interpretation and Performance 5.MIDI 6.Algebraic Properties.
Rest Duration Ms. Delgados Music Class. Rest Duration A Whole Rest receives four full beats.
Why do a capella singers go flat…? The mathematics of tuning systems in music Colin
Music. Scale A series of notes differing in pitch according to a specific scheme An octave (eight notes)
Music Basics Acadeca. Music is sound organized in time It consists of soundwaves: Amplitude and frequency Amplitude= how loud or the decibel level Frequency=
Composing How do I get started?. Step 1 Select your form AB two contrasting sections ABA three sections, the first and third sections are the same, the.
A Third Look At ML 1. Outline More pattern matching Function values and anonymous functions Higher-order functions and currying Predefined higher-order.
For those who have never played an instrument
An Introduction to Music
Chapter 8 A Module of Regions. The Region Data Type  A region represents an area on the two-dimensional Cartesian plane.  It is represented by a tree-like.
Chapter 1 Music Notation.
Elements of Music Finish Start Tempo and Dynamics Timbre Harmony Form
Being comfortable with music as a Song Leader. The Staff:  Five lines and four spaces, indicating which pitch to play  Vertical lines break the staff.
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.
Paul Hertz University of Wyoming
L 8-9 Musical Scales, Chords, and Intervals, The Pythagorean and Just Scales.
Major Scale Construction. Properties of a Major Scale Let’s look at a C Major scale What do you notice about this sequence of pitches?
Cse536 Functional Programming 1 5/16/2015 Lecture #19, Dec 1 & 6, 2004 Todays Topics – Haskore System –The Music datatype –MIDI Instruments –Pitch & absolute.
CSE466 Autumn ‘00- 1 System Functional Requirements  Children’s toy…comes with PC software. Child plays notes on the screen and the device makes corresponding.
Music and Logo Some Music Theory Just enough.. KISS We will say in the key of C no flats or sharps unless indicated. For our purpose we will stick to.
Cse536 Functional Programming 1 6/17/2015 Lecture #19, Dec 1 & 6, 2004 Todays Topics – Haskore System –The Music datatype –MIDI Instruments –Pitch & absolute.
Cse536 Functional Programming 1 6/26/2015 Lecture #19, Dec. 6, 2004 Todays Topics –Interpreting Music –Performance –MidiFile Read – Chapters 21 - Interpreting.
Effective Ear Training Brian Ordona. Music Theory A Crash Course.
Chapter 22 From Performance to MIDI. Motivation  Abstractly, an MDL program denotes a Performance.  But a Performance is just a Haskell data structure.
The Language Of Music Music Theory Part 2 Staff, Clefs, Time, Notation By Mr. White.
The Nuts & Bolts of Music
PD Composition Structure Slow section, faster section Slow section, faster section GEMS GEMS A Practical Guide to Composition A Practical Guide to Composition.
Christmas Final Review 2nd quarter Band Time Signature Indicates the number of beats per measure.
Making music Consider music as structured sound Components include –Pitch –Duration –Instrument –Stereo direction Each attribute has a set of possible.
The GUIDO Music Notation Format
Fractals in Music Fractals are self-similar shapes with theoretically infinite detail In music, fractals appear in the relationship between amplitude and.
AP Music Theory Elements: Rhythm. Rhythm  General term used to refer to the aspect of music  Durational Symbols:  Breve – Double Whole Note/rest –
Lesson 7 : The Chromatic Scale. What is a Scale?? A series of sequential pitches spanning one octave.
Music Software Projects New York University Adjunct Instructor Scott Burton.
An Algebraic Theory of Polymorphic Temporal Media Paul Hudak Yale University Department of Computer Science PADL Symposium June 18, 2004.
Elementary Harmony What are the three elements of music? By Ann Kim.
Music Software projects New york university Adjunct Instructor Scott Burton.
Major Key Signatures. Disclaimer Page Chorus is a TEAM It is my goal to have 100% of our team understanding these concepts. If you already know this stuff,
The 4 Parameters of Sound PITCH = the frequency of vibration (heard as “high” vs. “low”) DURATION = the length of time a sound lasts (heard as aspects.
The Elements of Music.
Chapter 7 Western Musical Instruments. Strings They are bowed and plucked – Violin – Viola – Cello (also Violoncello) – Double Bass.
 6 th Musical Literacy 1.1 All students will be able to use a steady tone when performing.
A Brief Introduction to Musical Acoustics
Unit 1: Elements Key.  Key note or tonic – central tone of a melodic line  Key/tonality– the presence of a central tone and a central chord and scale.
Computing with Music: Creating Musical Patterns Campy, 2005 Quinnipiac University Computing with Music: Creating Musical Patterns John Peterson No Longer.
Chelmsford Public Schools Fine and Performing Arts Department Band Curriculum Map By the end of each grade level, students will be able to: Grade 5Grade.
Introduction To Music Theory
AP Music Theory Elements: Rhythm.
MUSIC HIGH SCHOOL – MUSIC THEORY
SOUND ORGANIZED IN TIME
III Symbolic Reality III.2 (We Nov 08) Denotators I—definition of a universal concept space and notations.
New York University Adjunct Instructor Scott Burton
Pitched Percussion Unit
Introduction to Functional Programming in Racket
II CONCEPT SPACES II.6 (Thu Feb 22) Denotators—definition of a universal concept space, notations, and examples.
Laptop Instrument Meeting 22 April 11, 2018.
How is Music Related to Math?
AP Music Theory Mr. Silvagni
Lab 7: Musical Scales The Just Scale The Tempered Scale Transposition
Mallet Percussion Instruments
III Symbolic Reality III.2 (Mo Nov 05) Denotators I—definition of a universal concept space and notations.
Compositional Functional Programming with the Haskore Music
Laptop Instrument Programming a Tune.
Compositional Functional Programming with the Haskore Music
Introduction to Functional Programming in Racket
AP Music Theory Wed 23 Jan 2019.
Presentation transcript:

Chapter 20 Functional Music Composition

MDL: Music Description Language MDL is a DSL for computer music composition that is even simpler than FAL and IRL. It begins with primitive pitches: type Pitch = (PitchClass, Octave) 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 For example, (Fs, 5) is an F-sharp in the fifth octave. By convention, (A, 4) denotes A440, the A above middle C whose frequency is 440 Hz.

The Music Data Type The Music data type captures the essence of MDL: data Music = Note Pitch Dur-- a note | Rest Dur-- a rest | Music :+: Music-- sequential composition | Music :=: Music-- parallel composition | Tempo Dur Music-- tempo scaling | Trans Int Music-- transposition | Instr IName Music-- instrumentation deriving (Show, Eq) type Dur = Ratio Int Ratio (from module Ratio) is Haskells type for rational numbers, whose main operation is: (%) :: (Integral a) => a -> a -> Ratio a

Instruments IName is a data type of instrument names borrowed from Midi: data IName = 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 |...

Absolute Pitches 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 ) pcToInt:: PitchClass -> Int pcToInt pc = case pc of Cf -> -1;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 -> 12 trans:: Int -> Pitch -> Pitch trans i p= pitch (absPitch p + i)

Convenient Note and Rest Names cf, c, cs, df, d, ds, ef, e, es, ff, f, fs, gf, g, gs, af, a, as, bf, b, bs :: Octave -> Dur -> 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...

Lines, Chords, Repetition, and Delay Lines and chords: line, chord:: [Music] -> Music line= foldr (:+:) (Rest 0) chord= foldr (:=:) (Rest 0) For example, a C major arpeggio and chord: cMaj= [ n 4 qn | n <- [c, e, g] ] cMajArp= line cMaj cMajChd= chord cMaj Repetition and delay: repeatM :: Music -> Music repeatM m = m :+: repeatM m delay:: Dur -> Music -> Music delay d m = Rest d :+: m

Duration It is sometimes useful to compute the duration of a Music value: dur :: Music -> Dur dur (Note _ d)= d dur (Rest d) = d dur (m1 :+: m2) = dur m1 + dur m2 dur (m1 :=: m2) = dur m1 `max` dur m2 dur (Tempo a m) = dur m / a dur (Trans _ m) = dur m dur (Instr _ m) = dur m

Retrograde Using dur we can compute the retrograde (i.e. reverse) of a Music value: 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 (m1 :+: m2) = revM m2 :+: revM m1 revM (m1 :=: m2) = let d1 = dur m1 d2 = dur m2 in if d1>d2 then revM m1 :=: (Rest (d1-d2) :+: revM m2) else (Rest (d2-d1) :+: revM m1) :=: revM m2

Example Recursively apply f (to elements in a sequence) and g (to accumulated phrases) n times: 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)) For example: 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

Percussion From the Midi Standard: data PercussionSound = AcousticBassDrum-- MIDI Key 35 | BassDrum1 | SideStick | AcousticSnare |... | MuteCuica | OpenCuica | MuteTriangle | OpenTriangle-- MIDI Key 82 deriving (Show,Eq,Ord,Ix,Enum) These must be mapped to Music values: perc :: PercussionSound -> Dur -> Music perc ps = Note (pitch (fromEnum ps + 35)) For example, a funky rhythm: 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) ) )))

More Examples [ see text for examples of: trills and rolls truncating parallel compositions self-similar (fractal) music ]