Presentation is loading. Please wait.

Presentation is loading. Please wait.

Laptop Instrument Meeting 14 March 12, 2018.

Similar presentations


Presentation on theme: "Laptop Instrument Meeting 14 March 12, 2018."— Presentation transcript:

1 Laptop Instrument Meeting 14 March 12, 2018

2 Plan for the Day Mid-term exam comments next time
Spring break and snow have interfered Expanding note specification Capturing input Simultaneous playing

3 Rests We’ve set up a tune as an array of arbitrary length
whose elements are arrays of integers of length 2 whose first element is the MIDI number of the note and whose second element is the index of the duration of the note in the duration array

4 Rests (2) Let’s extend the note pairs to allow 0 in the first slot (remember the first slot has index 0). We’ll fix the tune player to interpret this 0 as a rest. Example: If tune[23] = [ 0, 8 ], this means an eighth rest at position 23 (the 24th element) of the tune.

5 Tune Player Adjustments
for (0 => int i; i < tune.cap(); i++) Note: tune.cap() gives the capacity of the tune array. If there are 140 notes and rests in the tune, the capacity is 140 and the elements are indexed from 0 through 139.

6 Adjustments (2) Check for a rest, { if (tune[i][0] > 0)
{ Std.mtof(Tune[i][0]) => Benny.freq; 1.0 => Benny.noteOn; } else { 1.0 => Benny.off } duration[tune[i][1]] => now; }

7 Adjustments (3) Separating notes:
Include a really short pause between notes Can’t be added to the duration of a note. Why? How long is “really short”? How long is a 32nd note when the tempo is 144?

8 Adjustments (4) duration[tune[i][1]] - ns => now;
Solution: Define a note separation duration 5::ms => dur ns; and subtract this value from the playing time of a note duration[tune[i][1]] - ns => now; Then add two statements to play the silence 1.0 => Benny.noteOff; ns => now;

9 Test Program Write a program to play a C major scale, one octave, four quarter notes on each pitch, both ascending and descending. Write a program to play an F major scale, one octave, quarter note, quarter rest, quarter note, quarter rest on each pitch, both ascending and descending.

10 Capturing Input Explored functions already
fun int plus3 (int x) { return x+3 }; <<< plus3(84) >>>; 84 is captured as the value of the parameter x in the function plus3

11 Capturing Input (2) Example: Setting the tempo outside the program, so that the tune player will play at the specified tempo without having to change the program each time. chuck playtune:128

12 Capturing Input (3) We’re passing the value 128 to the program playtune, intending to use it as the tempo. Where does the 128 appear in the program? In the secret variable me.arg(0) BUT it is NOT an integer, it’s a string.

13 Capturing Input (4) // Shows getting command line arguments // chuck args:1:2:foo

14 Capturing Input (4) // Shows getting command line arguments // chuck args:1:2:foo // print number of args <<< "number of arguments:", me.args() >>>;

15 Capturing Input (4) // Shows getting command line arguments // chuck args:1:2:foo // print number of args <<< "number of arguments:", me.args() >>>; // Declare an array to hold the argument values int a[5]; for(0=>int i;i<me.args();i++) {<<<me.arg(i)>>>; Std.atoi(me.arg(i)) => a[i]; <<<a[i]>>>; }

16 Capturing Input (5) Adjust your scale player to accept the tempo as a command line argument.

17 Note Playing Ideas Original patch SinOsc => dac; oops
SinOsc s => dac; Two notes simultaneously require two generators, so we add one SinOsc t => dac; problem 1 + 1 = 2

18 Note Playing (2) Effects to the rescue Gain first
SinOsc s => Gain gn => dac;

19 Note Playing (2) Effects to the rescue Gain first
SinOsc s => Gain gn => dac; Unit generator class

20 Note Playing (2) Effects to the rescue Gain first
SinOsc s => Gain gn => dac; Unit generator class Effect class

21 Note Playing (2) Effects to the rescue Gain first
SinOsc s => Gain gn => dac; Unit generator class Effect class Why gn?

22 Note Playing (2) Effects to the rescue Gain first
SinOsc s => Gain gn => dac; Turn down the volume 0.5 => gn.gain; Unit generator class Effect class Why gn?

23 Note Playing (3) Second note SinOsc t => gn;

24 Note Playing (3) Second note SinOsc t => gn; Where’s Gain?

25 Note Playing (3) Second note SinOsc t => gn; Where’s dac?

26 Note Playing (3) Second note SinOsc t => gn;
Adjust the volume individually 1.0 => gn.gain; 0.4 => s.gain; 0.6 => t.gain; Where’s dac?

27 Note Playing (4) Simultaneous parts chuck soprano.ck alto.ck
synchronizes the players but make sure the volume adds to 1 or less

28 New Player (5) Your turn: Write two ChucK programs
The first plays an ascending two-octave scale The second plays a descending two-octave scale Play the scales simultaneously Write a four-part tune, one part per ChucK program, and play the tune. Use Wait for the Lord Use a Taize piece for the two-part tune

29 New Player (6) Create a two-part round and have your tune player play it. You may want to modify your tune player into one that is a round player. Modify your tune player to handle a classic barber shop song, such as Lida Rose and Will I Ever Tell You, that matches the women’s parts against the men’s


Download ppt "Laptop Instrument Meeting 14 March 12, 2018."

Similar presentations


Ads by Google