Curtis HenkelCurtis HenkelMatthew DuaneChatura AtapattuKevin RamkishunTONEDEFKevin RamkishunMotivationMotivationC l f h “M i l C Create a language for the “Musical Computer Scientist"h f l Bring the semantics of musical composition to a programming language Flexible enough for a variety of uses Simple music creation Algorithmic music creationLanguage OverviewLanguage OverviewIi i lImperative programming language Statically scoped, weakly‐typed Types are immutable No pointers No polymorphism of function names/* Comments *// Comments / Source file is piped in and optional output file can be piped outcan be piped out.TypesTypesintdigits onlyintdigits only boolean true or false string chars inside double quotes pitch $[A‐G][b#]?[0‐9]? sequence comma‐separated list of ints inside [ ] beat rational numbers note pitch + beat chord set of notesphraseordered list of chordsphraseordered list of chords rhythm 1,0,‐,_ within ' ' void voidOperatorsOperatorsA ith ti*///%Arithmetic:+ -* / // % Comparators: < > <= >= == != Unary: -! Note/Chord Manipulation: ^ ^^ : :: + Phrase Manipulation: << >> ** @@Assignment:=Assignment:Function DeclarationsFunction Declarationstypefunctionfunc name (type name list) {type functionfunc_name (type name list) {body} Program is a list of function declarations Applicative orderpp Pass‐by‐value parameters Special functionsmainmain print playSyntax OverviewSyntax Overviewexpression := literal | unop exprexpression := literal | unop expr| expr binop expr| name (expr list) | name = expr| [ expr list ] | name statement := expr; | if (expr) stmt [else stmt]p;| (p) [ ]| for (expr; expr; expr) stmt | while (expr) stmt| foreach(type name in expr) stmt| foreach(type name in expr) stmt| return expr;| {stmt list }| type name [= expr];Example Program ‐ Phrase Creationp gvoid function main() {note n = $C5 : 1//4;sequence s = [];for (int i = 0; i<10; i = i+1){s = s + [x]; /* Creates a sequence }phrase p=n << reverse sequence(s); /*Creates phrase using notephrase p n << reverse_sequence(s); / Creates phrase using note and sequence */play(p);}sequence function reverse_sequence (sequence in_seq) {sequence s = [];foreach (int x in in_seq) {s = [x] + s;}return s;}Language ImplementationLanguage ImplementationScannerSource Code dfInputScanner(.tdf)Tokenized InputParserSyntax TreeCompilerTreedBytecode InterpreterMi!BytecodeOutputInterpreterJFugue (Java)Music!OutputSample BytecodeSample Bytecodevoid function main() {f h(i ii [456]){Output:4foreach (int i in [4,5,6]) {print (i + "\n");}456}0 Jmp 29 Combine17 Concatp1 Hlt2 Entry 13 PushEmpty sequence 10 Bra 1011 Decompose12 Store 118 Jmp -119 Pop20 IsEmptypy q4 PushInt 65 Combine6 PushInt 513 Pop14 Load 115 ConvertType int-py21 Beq -1022 Pop23 PushInt 06 PushInt 57 Combine8 PushInt 415 ConvertType int >string 16 PushString \n23 PushInt 024 Ret 0StackStack type mbeat = int * int (* numerator, denominator *) type mnote = int * mbeat (* pitch, beat *)… type mchord = mnote list (* list of notes *) type mphrase = mchord list (* list of chords *) type msequence = int listArgument 2Argument 1Return AddressOld Frame PointerFramepointer MemInteger of int MemString of stringLocal 1Local 2… MemPitch of int MemBool of bool MemBeat of mbeat MemNote (mnote(65, mbeat (1, 4)))MemChord (mchord([mnote(61, mbeat(1, 2))])) MemNote of mnote MemChord of mchord MemPhrase of mphraseMemBeat (mbeat(1, 4))MemString (string(“Quicksort Music”))((5, (,4))) MemSequence of msequence MemRhythm of stringMemInteger (42)How We CollaboratedHow We CollaboratedSource Code Control SubversionSource Code Control ‐Subversion Hosting by Assembla.comStress frequent commitsSt ess eque t co ts Automatic E‐Mail on new commits to notify team membersGl DGoogle Documents Collaborative editing on all documents and presentationsp Proposal, Task List, LRM, Presentation, Final Report Instant Messaging, E‐Mail conversations Impromptu meetings (after class) as requiredLessons LearnedLessons LearnedKISS K i Si l Sid (lihé k)KISS ‐Keep it Simple Stupid (cliché, we know) Everything is just an integer or a stringf If you don’t have an easy solution, just add another layer of indirection Orthodox stack ‐> Object based stackSummary & ConclusionSummary & ConclusionSfll il d Tdf h Successfully implemented Tonedef per the Language Reference Manualk Future work Overlapping phrases User interaction in program Command argumentsDiff i d i iDifferent instruments, tempo and time
View Full Document