/
Laptop Instrument Meeting 14 Laptop Instrument Meeting 14

Laptop Instrument Meeting 14 - PowerPoint Presentation

dardtang
dardtang . @dardtang
Follow
342 views
Uploaded On 2020-06-15

Laptop Instrument Meeting 14 - PPT Presentation

March 12 2018 Plan for the Day Midterm exam comments next time Spring break and snow have interfered Expanding note specification Capturing input Simultaneous playing Rests Weve set up a tune as ID: 778169

tune note playing gain note tune gain playing sinosc player dac capturing args input program play chuck class duration

Share:

Link:

Embed:

Download Presentation from below link

Download The PPT/PDF document "Laptop Instrument Meeting 14" is the property of its rightful owner. Permission is granted to download and print the materials on this web site for personal, non-commercial use only, and to display it on your personal computer provided you do not modify the materials and that you retain all copyright notices contained in the materials. By downloading content from our website, you accept the terms of this agreement.


Presentation Transcript

Slide1

Laptop Instrument

Meeting 14

March 12, 2018

Slide2

Plan for the Day

Mid-term exam comments next time

Spring break and snow have interfered

Expanding note specification

Capturing input

Simultaneous playing

Slide3

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

Slide4

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 24

th

element) of the tune.

Slide5

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.

Slide6

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;

}

Slide7

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 32

nd

note when the tempo is 144?

Slide8

Adjustments (4)

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

;

Slide9

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.

Slide10

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

Slide11

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

Slide12

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.

Slide13

Capturing Input (4)

// Shows getting command line arguments

// chuck args:1:2:foo

Slide14

Capturing Input (4)

// Shows getting command line arguments

// chuck args:1:2:foo

// print number of

args

<<< "number of arguments:",

me.args

() >>>;

Slide15

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

]>>>;

}

Slide16

Capturing Input (5)

Adjust your scale player to accept the tempo as a command line argument.

Slide17

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

Slide18

Note Playing (2)

Effects to the rescue

Gain first

SinOsc

s => Gain

gn

=>

dac

;

Slide19

Note Playing (2)

Effects to the rescue

Gain first

SinOsc

s => Gain

gn

=>

dac

;

Unit generator class

Slide20

Note Playing (2)

Effects to the rescue

Gain first

SinOsc

s => Gain

gn

=>

dac

;

Unit generator class

Effect

class

Slide21

Note Playing (2)

Effects to the rescue

Gain first

SinOsc

s => Gain

gn

=>

dac

;

Unit generator class

Effect

class

Why

gn

?

Slide22

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

?

Slide23

Note Playing (3)

Second note

SinOsc

t =>

gn

;

Slide24

Note Playing (3)

Second note

SinOsc

t =>

gn

;

Where’s Gain?

Slide25

Note Playing (3)

Second note

SinOsc

t =>

gn

;

Where’s

dac

?

Slide26

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

?

Slide27

Note Playing (4)

Simultaneous parts

chuck soprano.ck alto.ck

synchronizes the players

but

make sure the volume adds to 1 or less

Slide28

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

Slide29

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