1 / 17

Computer Programming For Musical Applications II

Computer Programming For Musical Applications II. 08.Scheduling_Sequencing 25 November, 2008. Review. Tempo Clock Tasks Patterns. TempoClock. Timer that runs in the background, counting beats Allows you to schedule events some time in the future. TempoClock Methods.

Download Presentation

Computer Programming For Musical Applications II

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Computer Programming For Musical Applications II 08.Scheduling_Sequencing 25 November, 2008

  2. Review Tempo Clock Tasks Patterns MTE2007 Computer Programming For Musical Applications II

  3. TempoClock • Timer that runs in the background, counting beats • Allows you to schedule events some time in the future MTE2007 Computer Programming For Musical Applications II

  4. TempoClock Methods .tempo – set or return the current tempo in beats/sec .default – returns a permanent default clock that begins at startup .sched(delta, function) – schedules a function to be evaluated delta beats from the current logical time . . . Many More MTE2007 Computer Programming For Musical Applications II

  5. Scheduling with a TempoClock ( t =TempoClock.default; t.tempo=2; // beats per second 4.do({ arg i; TempoClock.default.sched(i, {Synth(\singrain,[freq: 440*(i+1), amp: 0.5, dur:0.8]).play;}) }); ) MTE2007 Computer Programming For Musical Applications II

  6. TempoClock Exercise • Create a SynthDef….. • Place the default tempo clock into the variable t • Set the tempo • Create a do loop that will loop 10 times and play a SynthDef every time it loops MTE2007 Computer Programming For Musical Applications II

  7. Tasks MTE2007 Computer Programming For Musical Applications II

  8. Tasks • When we schedule a function, the entire function is evaluated at the designated time • A Task is like a function where we can control when each statement of the function is executed • Allows us to create a sequence of events and step through or schedule them MTE2007 Computer Programming For Musical Applications II

  9. Tasks Task.new(func,clock); • Allows the function to be evaluated in steps, using the designated clock for timing • If no clock given, uses TempoClock.default MTE2007 Computer Programming For Musical Applications II

  10. An Example Task ( x = { loop // when we play the task it will loop {[200, 300, 400].do({ |f| Synth(\singrain, [freq: f, amp: 0.2, dur: 0.1]); 0.125.wait;}); // wait 1/8 beat before scheduling next event } } ) t = Task(x); t.play; // play the task t.stop;/ / stop t.play;// resume from where we left off MTE2007 Computer Programming For Musical Applications II

  11. Timing Tasks Task.play(argClock,doReset,quant); • argClock – the clock to handle the Task • doReset – boolean value, if true, start task from the beginning, else resume • quant – begin when current time is a multiple of this number • if quant is an array: [quant, phase], phase adds an offset in beats MTE2007 Computer Programming For Musical Applications II

  12. A Timed Task f = { Task({ loop {[60, 62, 64, 65, 67, 69, 71, 72].do({ |midi| Synth(\singrain, [freq: midi.midicps, amp: 0.2, dur: 0.1]); 0.25.wait;}); // end do } // end loop }); // end Task }; t = f.value.play(quant: 4); //start on next 4-beat boundary u = f.value.play(quant: [4, 0.5]); // next 4-beat boundary + a half-beat t.stop; u.stop; MTE2007 Computer Programming For Musical Applications II

  13. Task Exercise • Create a task that will loop through 5 values. Each time is loops through a value it should trigger a SynthDef to play, using the current value to set the frequency argument of the SynthDef. • Use different variables to play multiple versions of this task at the same time, using quant to set the start time MTE2007 Computer Programming For Musical Applications II

  14. Patterns MTE2007 Computer Programming For Musical Applications II

  15. Pseq: A Sequence Pattern Pseq(list,repeats,offset); • list – an array of values • repeats – number of times to repeat the pattern, set to inf to repeat forever • offset – begin at this index (0-based) Pseq.asStream; • convert a pattern to a stream • allows us to sequentially access the pattern values MTE2007 Computer Programming For Musical Applications II

  16. Basic Sequence Pattern Example ( a = Pseq([1, 2, 3, 4], 3); // repeat 3 times b = a.asStream; 13.do({ b.next.postln; }); ) MTE2007 Computer Programming For Musical Applications II

  17. Basic Sequence Pattern Example • Create a pattern of notes using Pseq to build the pattern into a stream. • Use this stream to control the frequency of a SynthDef which should be inside a timed do loop so that all the notes are not played at once… MTE2007 Computer Programming For Musical Applications II

More Related