//Varius: the Lilypond-ChucK Two-way Variations Virtual Composer //Varius is a program that explores formulaic generation of music variations as well as the playability of computer-generated music by live musicians //The program takes in a lilypond chord sequence that can be scored by non-computer musicians, generates a set of variations, //and prints out the lilypond score for the variations for live musicians to reproduce and interpret. //This is the main interface for Varius, combining all classes/functions together to read, perform and write a variation. //The sound output is based on Canon in D program Copyright (C) 2007 Pedro López-Cabanillas /* Instance variables */ fileReader rd; chordPro chords; int table[][]; varius vr; /* Opening starter lilypond file */ // default file me.sourceDir() + "/example.ly" => string filename; //TODO: getting file name from console //loading the input lilypond file if(rd.load(filename)!=1) { cherr <= "Error processing file. Please check your lilypond file. " <= IO.newline(); me.exit(); } //processing the chords loaded chords.process(rd.getRaw(), rd.getNumChords(), rd.getTimeSig()) @=> table; /*for(0 => int i; i < rd.getNumChords(); i++) { <<<"chord " + i>>>; for (0 => int j; j < 5; j++) { <<>>; } }*/ //playback constants and functions Mandolin s1 => JCRev reverb => dac; 0 => s1.noteOff; .1 => s1.gain; .9 => reverb.gain; .2 => reverb.mix; VoicForm s2 => JCRev reverb2 => dac; 0.03 => s2.vibratoGain; 0 => s2.phonemeNum; 0 => s2.noteOff; .2 => s2.gain; .9 => reverb2.gain; .2 => reverb2.mix; 1 => int t1; // whole 2 => int t2; // half 4 => int t4; // quarter 8 => int t8; // eighth 16 => int t16; // 16th 32 => int t32; // 32th // dotted figures 3 => int t2d; // dotted half 5 => int t4d; // dotted quarter 9 => int t8d; // dotted eigth fun dur duration(int figure, float tempo) { if (figure == t2d ) return duration(t2, tempo) + duration(t4, tempo); else if (figure == t4d) return duration(t4, tempo) + duration(t8, tempo); else if (figure == t8d) return duration(t8, tempo) + duration(t16, tempo); else return 240::second / ( figure * tempo ); } 50.0 => float tempo; //default fun void playNow(int notes[][], int numNotes, StkInstrument gen) { for( 0 => int i; i < numNotes; i++) { if(notes[i][0] == -1) { notes[i][1] => tempo; 1::second => now; <<<"set tempo" + tempo>>>; } else { if (notes[i][0] > 0 ) { Std.mtof( notes[i][0]) => gen.freq; 1.0 => gen.noteOn; } duration(notes[i][1], tempo) => now; 0.0 => gen.noteOff; <<<"note: " + notes[i][0] + " length " + notes[i][1]>>>; } } } //Selecting your variations //CHANGE THIS ACCORDING TO WHAT YOU WANT TO OUTPUT!!! 2 => int numVar; [1,2] @=> int variations[]; //Initializing the score vr.Varius(variations, numVar, table, rd.getNumChords(), rd.getNom(), rd.getDenom()); int test[][]; vr.getTrebleTable() @=> test; /*for(0 => int i; i < vr.getNumTreble(); i++) { <<<"length: " + test[i][0] + " note: " + test[i][1]>>>; }*/ //Play the score spork~playNow(vr.getTrebleTable(), vr.getNumTreble(), s1); spork~playNow(vr.getBassTable(), vr.getNumBass(), s2); 1::day => now;