Presentation is loading. Please wait.

Presentation is loading. Please wait.

Laptop Instrument Meeting 22 April 11, 2018.

Similar presentations


Presentation on theme: "Laptop Instrument Meeting 22 April 11, 2018."— Presentation transcript:

1 Laptop Instrument Meeting 22 April 11, 2018

2 Duration Arrays Robust arrays One each for
Half note gets one beat Dotted quarter note gets one beat Quarter note gets one beat Eighth note gets one beat Include possible dotted notes Whole, half, quarter, eighth, sixteenth Include triplets Half note, quarter note, eighth note, sixteenth note

3 Note Spreadsheet Helmholtz ASA Midi ChucK

4 Interval Names 8 by 5 spreadsheet Columns labeled by interval quality
A, d, M, m, P Rows labeled by interval size 1 through 8 Cells grayed out if interval is not possible For example, P2

5 Interval Functions Invent an interval computing function
Input: base (lower) note specified as a note name, e.g. D Input: upper note specified as a note name, e.g. G Invoked by: chuck interval:D:G Returns: M4

6 Interval Functions (2) Invent another interval computing function
Input: base note specified as a note name, e.g. D Input: interval specified by usual notation, e.g. M3 Invoked by chuck interval2:D:M:3 Returns: F# But let’s think about the possible inputs and possible answers Computing the upper note of a generic interval: fun string upper (string lower, int scan) { [“A”, ”B”, “C”, “D”, “E”, “F”, “G”] => string notes[7]; // the array of note names int k[7]; 0 => k[“A”]; 1 => k[“B”]; 2 => k[“C”]; 3 => k[“D”]; 4 => k[“E”]; 5 => k[“F”]; 6 => k[“G”]; // the array of note indices return notes[ k[lower] + span – 1]; // note index + span -1 }

7 Converting Note Names Need an array of note names:
[“A”, ”B”, “C”, “D”, “E”, “F”, string notes[7]; Need the inverse array: int k[7]; 0 => k[“A”]; 1 => k[“B”]; 2 => k[“C”]; 3 => k[“D”]; 4 => k[“E”]; 5 => k[“F”]; 6 => k[“G”]; return notes[ k[lower] + span – 1]; // note index + span -1

8 Interval Function 1 Take in the base note
Find its numerical equivalent Take in the top note Use arithmetic to compute the interval size Use size to compute interval type Report result

9 Interval Function 2 Take in the base note
Find its numerical equivalent Take in the interval type Split it into character and number Use number to compute name of top note Use character to modify Report result Computing the upper note of a generic interval: fun string upper (string lower, int scan) { [“A”, ”B”, “C”, “D”, “E”, “F”, “G”] => string notes[7]; // the array of note names int k[7]; 0 => k[“A”]; 1 => k[“B”]; 2 => k[“C”]; 3 => k[“D”]; 4 => k[“E”]; 5 => k[“F”]; 6 => k[“G”]; // the array of note indices return notes[ k[lower] + span – 1]; // note index + span -1 }

10 Sharps and Flats How do we handle sharps and flats in note names?
Will using Bf work? Do we have to split the name in the input, for example B:f

11 Another Program Write a ChucK program that plays a random note and the major sixth above it. Hint: int rand2 (int min, int max); generates a random integer in the interval [min,max] In a program, this function is called as Std.rand2(50,150) => int f;

12 Chord Function Chord builder: Given a root note, compute and play the I chord How is the note given? What is the ChucK expression to compute the major third? What is the ChucK expression to compute the perfect fifth?

13 Calculating Notes Let m be the Midi designation of the root of a chord. Then m + 4 is the Midi designation of the major third m + 7 is the Midi designation of the perfect fifth m + ? Is the Midi designation of the minor third What other notes do we need to calculate when working with chords?

14 Passing Arguments The current process, called a shred in ChucK, is designated by the identifier me Small aside: What other special identifiers have you discovered in ChucK? The current process starts when you invoke ChucK from the command line. For example, C:\> chuck tuneplayer.ck

15 Passing Arguments (2) You can pass any number of arguments to a ChucK program from the command line. Possible choices are: Tempo Key signature Root of chord Usage (syntax) is chuck prog.ck:a:b:c Hint: Spaces are not allowed between colons. Why?

16 Passing Arguments (3) Within the program
The first argument is in the variable me.arg(0) The second argument is in the variable me.arg(1) Etc. The number of arguments is in the variable me.args() What is the first question that you should ask about me.arg(0), me.arg(1), …, me.args()

17 Conversions ChucK provides several functions that convert values from one type to another, or value to another atoi converts strings to integers atof converts strings to floats mtof converts Midi numbers to frequencies ftom converts frequencies to Midi numbers These functions are defined in the Std namespace so must be invoked as Std.atoi(“72”) for example.

18 Instantiating Instruments
Goal: Have different instruments play different lines in the piece, creating a real woodwind trio or brass quartet Solution: Run several processes (shreds) simultaneously in the ChucK virtual machine

19 Instantiating Instruments (2)
Step 1: Write a function that defines each instrument, the notes that it plays, and a play loop for the instrument The function most likely will have no parameters and will return no value, so its definition form is: fun void sample() { // function code }

20 Instantiating Instruments (3)
Step 2: Include function definitions in your main ChucK file so that your file looks like: // notes // durations // principal note array // lead instrument definition // play loop // function definitions

21 Instantiating Instruments (4)
Step 3: Insert the calls to the functions defining the other instruments // lead instrument definition spork ~ i2(); spork ~ i3(); spork ~ i4(); // play loop

22 Chord Function Write a ChucK program that plays the chord
First melodically, with whole notes Then harmonically, with a whole note In each case set the tempo to 80. How long will the whole note play? Set up the program to accept the root note as an argument Example: chuck chord:Bflat


Download ppt "Laptop Instrument Meeting 22 April 11, 2018."

Similar presentations


Ads by Google