HOMEWORK 2 - with ANSWERS

1. Show how to use GEN07 and GEN10 to create the following function as function table f1 in Csound.

f 1

f1 0 1024 7 0 256 1 512 -1 256 0
f1 0 1024 10 0.814 0 0.092 0 0.036 0 0.02 0 0.014 0 0.01 0 0.08 0 0.08

2. Write a Csound orchestra file for the following computer music instrument assuming a sampling rate of 44000 Hz and a control rate of 1100 Hz.

sr = 44000
kr = 1100
ksmps = 40
nchnls = 1
instr 1
  k1 linseg 0, p3/5, p4, p3/5, p4/2, 2*p3/5, p4/2, p3/5, 0
  a1 oscil k1, p5, 1
  out a1
endin

3. Write the Csound note statements of the score file that will play the instrument from problem 2 three times with 1 second of silence between each pair of notes. The first note begins at time 0. Use the following data:

Note DurationAmplitudeFrequency (Hz)
1 sec10000440
2 sec15000660
3 sec20000880
i1 0 1 10000 440
i1 2 2 15000 660
i1 5 3 20000 880

4. For the first note above, calculate the sampling increment and determine the first three samples output to the wave file for this note.

I = fL/R = (440)(1024)/44000 = 10.24
First three samples pulled from the wave table, assuming truncation, are
 Sample 1	table[0] = 0
 Sample 2	table[10.24] --> table[10] = 10/256
 Sample 3	table[20.48] --> table[20] = 20/256
These values are multiplied by the value of the amplitude envelope (k1), which is 0 for
the first 40 samples. 

5. Using the oscil.cpp program, modify the program code so that the selection of samples from the function table are chosen using the interpolation method. (That is, if the sampling increment is non-integral, generate a sample for the .wav file from two samples of the table.)

output = (index - int(index))*(table[int(index)] - table[int(index+1)]) + table[int(index)];

COURSE INFORMATION | HOMEWORK ASSIGNMENTS
COURSE PROJECT | CS240 HELP DESK