ebook img

The Haskell School of Music: From Signals to Symphonies PDF

384 Pages·2018·3.76 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview The Haskell School of Music: From Signals to Symphonies

TheHaskellSchoolofMusic Thistextbookexploresthefundamentalsofcomputermusicandfunctional programmingthroughtheHaskellprogramminglanguage.Functionalprogrammingis typicallyconsidereddifficulttolearn.Thisintroductioninthecontextofcreating musicwillallowstudentsandprofessionalswithamusicalinclinationtoleveragetheir experiencetohelpunderstandconceptsthatmightbeintimidatinginmoretraditional computersciencesettings.Conversely,thebookopensthedoorforprogrammersto interactwithmusicbyusingamediumthatisfamiliartothem. ReaderswilllearnhowtousetheEuterpealibraryforHaskell(www.euterpea.com) torepresentandcreatetheirownmusicwithcode,withouttheneedforothermusic software.Thebookexplorescommonparadigmsusedinalgorithmicmusic composition,suchasstochasticgeneration,musicalgrammars,self-similarity,and real-timeinteractivesystems.Othertopicscoveredincludethebasicsofsignal-based systemsinHaskell,soundsynthesis,andvirtualinstrumentdesign. paul hudakwasaprofessorofcomputerscienceatYaleUniversity,Connecticut, from1982to2015.Hewasbestknownforhiscontributionstothedevelopmentofthe Haskellprogramminglanguage.Askilledsaxophonistandjazzmusician,Hudakhad usedacombinationofhisenthusiasmformusicandcomputersciencetocreatethe EuterpealibraryforrepresentingmusicinHaskell. donya quickisResearchAssistantProfessorofMusicandComputationat StevensInstituteofTechnology,NewJersey.Herresearchexplorestheintersectionof artificialintelligenceandcomputationallinguisticswithmusic,andincludesworking onanautomatedcompositionsystemcalledKulitta.Inaddition,sheisalsoinvolvedin theMUSICAprojectforinteractiveimprovisationandcompositionbyconversion, whichispartoftheDAPRACommunicatingwithComputersprogram. The Haskell School of Music From Signals to Symphonies PAUL HUDAK DONYA QUICK StevensInstituteofTechnology UniversityPrintingHouse,CambridgeCB28BS,UnitedKingdom OneLibertyPlaza,20thFloor,NewYork,NY10006,USA 477WilliamstownRoad,PortMelbourne,VIC3207,Australia 314–321,3rdFloor,Plot3,SplendorForum,JasolaDistrictCentre,NewDelhi–110025,India 79AnsonRoad,#06–04/06,Singapore079906 CambridgeUniversityPressispartoftheUniversityofCambridge. ItfurtherstheUniversity’smissionbydisseminatingknowledgeinthepursuitof education,learning,andresearchatthehighestinternationallevelsofexcellence. www.cambridge.org Informationonthistitle:www.cambridge.org/9781108416757 DOI:10.1017/9781108241861 ©PaulHudakandDonyaQuick2018 Thispublicationisincopyright.Subjecttostatutoryexception andtotheprovisionsofrelevantcollectivelicensingagreements, noreproductionofanypartmaytakeplacewithoutthewritten permissionofCambridgeUniversityPress. Firstpublished2018 PrintedintheUnitedStatesofAmericabySheridanBooks,Inc. AcataloguerecordforthispublicationisavailablefromtheBritishLibrary. LibraryofCongressCataloging-in-PublicationData Names:Hudak,Paul,author.|Quick,Donya,author. Title:TheHaskellschoolofmusic:fromsignalstosymphonies/PaulHudak,DonyaQuick. Description:Cambridge,UnitedKingdom;NewYork,NY: CambridgeUniversityPress,2018.|Includesbibliographicalreferencesandindex. Identifiers:LCCN2018016879|ISBN9781108416757(hardback:alk.paper) Subjects:LCSH:Haskell(Computerprogramlanguage)|Computermusic–Instruction andstudy.|Functionalprogramming(Computerscience) Classification:LCCML74.4.H37H842018|DDC781.3/45133–dc23 LCrecordavailableathttps://lccn.loc.gov/2018016879 ISBN978-1-108-41675-7Hardback CambridgeUniversityPresshasnoresponsibilityforthepersistenceoraccuracy ofURLsforexternalorthird-partyinternetwebsitesreferredtointhispublication anddoesnotguaranteethatanycontentonsuchwebsitesis,orwillremain, accurateorappropriate. Contents Preface pagexi Acknowledgments xvi 1 ComputerMusic,Euterpea,andHaskell 1 1.1 TheNoteversusSignalDichotomy 2 1.2 BasicPrinciplesofProgramming 3 1.3 ComputationbyCalculation 4 1.4 ExpressionsandValues 8 1.5 Types 9 1.6 FunctionTypesandTypeSignatures 11 1.7 Abstraction,Abstraction,Abstraction 12 1.8 HaskellEqualityversusMusicalEquality 21 1.9 CodeReuseandModularity 22 1.10 [Advanced]ProgrammingwithNumbers 23 2 SimpleMusic 27 2.1 Preliminaries 27 2.2 Notes,Music,andPolymorphism 29 2.3 ConvenientAuxiliaryFunctions 34 2.4 AbsolutePitches 39 3 PolymorphicandHigher-OrderFunctions 42 3.1 PolymorphicTypes 42 3.2 AbstractionoverRecursiveDefinitions 44 3.3 Append 47 3.4 Fold 49 3.5 [Advanced]AFinalExample:Reverse 54 3.6 Currying 56 3.7 Errors 60 v vi Contents 4 AMusicalInterlude 63 4.1 TranscribinganExistingScore 63 4.2 Modules 65 4.3 TranscribingaMoreComplexScore 67 4.4 SimpleAlgorithmicComposition 72 5 SyntacticMagic 74 5.1 Sections 74 5.2 AnonymousFunctions 75 5.3 ListComprehensions 77 5.4 FunctionComposition 80 5.5 Higher-OrderThinking 81 5.6 InfixFunctionApplication 82 6 MoreMusic 84 6.1 DelayandRepeat 84 6.2 InversionandRetrograde 85 6.3 ComputingDuration 87 6.4 Super-Retrograde 87 6.5 cutandremove 88 6.6 RemovingZeros 89 6.7 TruncatingParallelComposition 91 6.8 Trills 93 6.9 GraceNotes 95 6.10 Percussion 95 6.11 AMapforMusic 97 6.12 AFoldforMusic 99 6.13 ComplexRhythms 100 6.14 CrazyRecursion 101 7 QualifiedTypesandTypeClasses 104 7.1 Motivation 104 7.2 Equality 106 7.3 DefiningOurOwnTypeClasses 108 7.4 Haskell’sStandardTypeClasses 113 7.5 OtherDerivedInstances 118 7.6 TheTypeofplay 121 7.7 ReasoningwithTypeClasses 122 8 FromMusictoMIDI 125 8.1 AnIntroductiontoMIDI 125 Contents vii 8.2 MIDIStreams 128 8.3 Euterpea’sPlaybackFramework 129 9 InterpretationandPerformance 134 9.1 AbstractPerformance 134 9.2 Players 139 9.3 PuttingItAllTogether 144 10 Self-SimilarMusic 148 10.1 Self-SimilarMelody 148 10.2 Self-SimilarHarmony 152 10.3 OtherSelf-SimilarStructures 153 11 ProofbyInduction 156 11.1 InductionandRecursion 156 11.2 ExamplesofListInduction 157 11.3 ProvingFunctionEquivalences 159 11.4 UsefulPropertiesonLists 162 11.5 InductionontheMusicDataType 166 11.6 [Advanced]InductiononOtherDataTypes 170 12 AnAlgebraofMusic 175 12.1 MusicalEquivalence 175 12.2 SomeSimpleAxioms 177 12.3 TheFundamentalAxiomSet 180 12.4 OtherMusicalProperties 182 13 L-SystemsandGenerativeGrammars 184 13.1 ASimpleImplementation 185 13.2 AMoreGeneralImplementation 187 13.3 AnL-SystemGrammarforMusic 189 14 RandomNumbers,ProbabilityDistributions,and MarkovChains 193 14.1 RandomNumbers 193 14.2 ProbabilityDistributions 196 14.3 MarkovChains 202 15 BasicInput/Output 205 15.1 IOinHaskell 205 15.2 doSyntax 206 15.3 ActionsAreJustValues 208 15.4 ReadingandWritingMIDIFiles 210 viii Contents 16 Higher-OrderTypesandMonads 211 16.1 TheFunctorClass 211 16.2 TheMonadClass 213 16.3 TheMonadPlusClass 221 16.4 StateMonads 222 16.5 TypeClassTypeErrors 225 17 MusicalUserInterfaces 227 17.1 Introduction 227 17.2 BasicConcepts 228 17.3 TheUISFArrow 233 17.4 Non-WidgetSignalFunctions 242 17.5 MusicalExamples 246 17.6 SpecialPurposeandCustomWidgets 251 17.7 AdvancedTopics 256 18 SoundandSignals 262 18.1 TheNatureofSound 262 18.2 DigitalAudio 273 19 Euterpea’sSignalFunctions 282 19.1 TheTypeofAudioSignals 282 19.2 GeneratingSound 289 19.3 Clipping 290 19.4 Instruments 292 20 SpectrumAnalysis 299 20.1 Fourier’sTheorem 299 20.2 TheDiscreteFourierTransform 305 20.3 TheFastFourierTransform 315 20.4 FurtherPragmatics 317 21 AdditiveandSubtractiveSynthesis 318 21.1 AdditiveSynthesis 319 21.2 SubtractiveSynthesis 326 22 AmplitudeandFrequencyModulation 331 22.1 AmplitudeModulation 331 22.2 FrequencyModulation 334 22.3 Examples 334 23 PhysicalModeling 336 23.1 Introduction 336 Contents ix 23.2 DelayLines 336 23.3 Karplus-StrongAlgorithm 340 23.4 WaveguideSynthesis 343 AppendixA ThePreludeListModule 346 AppendixB Haskell’sStandardTypeClasses 355 AppendixC Built-InTypesAreNotSpecial 365 AppendixD Pattern-MatchingDetails 367 AppendixE HaskellQuickReference 370 AppendixF EuterpeaQuickReference 373 AppendixG HSoMQuickReference 377 Bibliography 379 Index 381

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.