Courses | DXARTS 461-3 | Fall 461
 
 

Composition Assignment A


Due: By class time Thursday, November 8.

REMEMBER: READ ALL INSTRUCTIONS AND QUESTIONS VERY CAREFULLY and ask questions if anything is unclear. Also, make sure you don't have any amps out of range.

Problem 1
Rewrite \oscili_2b from 04-Sinusoidal Oscillators-D.sc (rename it \oscili_2b_1) to provide dynamic frequency control using an envelope. From the score file you should be able to give the instrument two frequency values to perform a glissando over the duration of the note. Test your instrument with the following synth call:

s.sendMsg(\s_new, \oscili_2b_1, -1, 0, 0, \dur, 5, \freq1, 440, \freq2, 880);

The instrument should play a perceptually "smooth" glissando up over an octave.

Hint #1: See the helpfile for Line.sc

Hint #2: to get this 100% correct, it is important to remember the exponential nature of pitch space, as described in Math Basics for Computer Music.

Submit: your SynthDef

Problem 2
The sampling theorem states that to sample a signal correctly, the sampling frequency (rate) of the digital system should be at least twice the highest frequency present in the signal. If we synthesize a signal that contains frequency components higher than half the sampling rate, those components will "foldover".

Using the instrument from Problem 1 and a sampling rate of 44100 Hz, write a synth call that plays a 10 seconds sinusoid that starts with frequency of 100 Hz, rises to the maximum frequency and then ends at a "foldover frequency" of 440 Hz.

Hint : calculate the final frequency of the glissando as a function of the foldover frequency. It should be greater than the Nyquist frequency.

Submit: your synth call and a brief explanation on how you found the frequency values.

Problem 3
Perform the same test from Problem 2 (using the same frequencies) with the following sampling rates: 32000Hz, 22050Hz, 16000Hz, 8000Hz. To do this, you will need to use SuperCollider in Non-real-time mode to write out a soundfile. To begin with, your score should look like this:

a = Score.new(
[
[0.0, [\s_new, \oscili_2b_1, -1, 0, 0, \dur, 10, \freq1, "replace with your freq 1", \freq2, "your freq two"]],
[10.0, [\c_set, 0, 0]] // this is a dummy command to tell NRT to stop synthesizing
]
);

Filling out the frequency slots with your values. "a" is now a score object. You can then tell "a" to write out a file in NRT (non-real-time). Below is an example. See the Score helpfile for more information.

o = ServerOptions.new.numOutputBusChannels = 1; // mono output
a.recordNRT("/tmp/trashme.osc", "~/myfile_16000.aif".standardizePath, sampleRate: 16000, options: o);

This will write a soundfile named myfile_16000.aif to your home directory (remember to rename your files to avoid overwriting them).
What conclusions can you make from this experiment?

Submit: your code plus a brief text with your conclusions.

Problem 4
The following wave table is stored in memory. It is far, far, far shorter than a wavetable would normally be. This is in order to facilitate the calculations in this problem.

0 0.0
1 0.707
2 1.0
3 0.707
4 0.0
5 -0.707
6 -1.0
7 -0.707

These 8 samples represent one cycle of a sinusoid.
Here are the questions. You can answer them using a calculator that has a SIN function or typing math commands into LISP. But you might find writing program(s) or using a spreadsheet to be a useful approach, too.

1. What frequency will an oscillator play if it reads the table with a sample increment of 1 sample at a sampling rate of 16 Hz?
2. What sample increment should the oscillator use to play a frequency of 7Hz?
3. Write down the sample values for the first second of output at 7Hz using: a) truncation, b) linear interpolation, c) the actual value of a sine function.


Math Hint #1: 1 cycle = 2pi radians = 360 degrees.

Math Hint #2: To find the correct value to feed to the sin function, you will need to determine where you are in one cycle at any given point in the wave table.
For example: slot # 2 is 2/8 of the way into the table, a.k.a. 1/4 of the way. 1/4 of 360 degrees is 90 degrees. sin 90 = 1.0.
Another example: reading the sin function at the equivelent of slot # 3.5: 3.5/8 = 0.4375 of the way into the table. 0.4375 of 2pi radians = 2.7488... sin of this value is 0.3826...

Math Hint #3: when LISP or a calculator gives a number like -1.2343e-16, the "e-16" means move the decimal point 16 positions to the left. In other words, this is an extremely small number. For the purposes of this assignment, just consider such a number to be 0.

Math Hint #4: a generalized calculation for linear interpolation is V1 + R * (V2-V1), where V1 is the first value, V2 is the second value, and R is a ratio between 0 and 1 describing how far between the two values we want to land.
For example: to find the value half way between 4 and 2: V1=4, V2=2, R=.5 ==> 4+.5*(2-4) = 4+(-1) = 3.

4. What is the maximum error for each reading method with respect to the actual sine function? Express these two error values in dB. Use a reference value of 1 in your dB calculations (that is, calculate your dB by comparing the error to 1).

Submit: text with your answers (could use a table for the values of each case).

Problem 5
SuperCollider's "Osc" unit generator implements a wave table oscillator that performs linear interpolation. The "OscN" unit generator is a faster oscillator that doesn't interpolate. Both mechanisms produce noise when a fractional index is used to read the wave table.
To compare both methods, write SynthDefs with the following parameters:

* SynthDef 1: a single "Osc" unit generator that writes to the output, stored in a SynthDef called \osc.
* SynthDef 2: a single "OscN" unit generator that writes to the output, stored in a SynthDef called \oscn.
* SynthDef 3: generate a signal from an "Osc" unit generator (sound1) and a signal from an "OscN" unit generator (sound2). Send the difference of the two signals (sound1 - sound2) to the output. This SynthDef should be called \subtract.

All the 3 SynthDefs should have amplitude, frequency and duration as arguments. In addition, each SynthDef should have a Line.kr envelope, which sustains a value of 1.0 over the duration of each note.
You will notice that both "Osc" and "OscN" take a table (or buffer) argument. These tables are given to you in the score below (do not worry about how these are made yet, this will be discussed later). Each UGen uses a different kind of buffer. For this problem, the Osc UGen will take buffer number 1. OscN will use buffer number 2.
Finally, for each SynthDef use the following for your output

Out.ar(0, Maxamp.ar(mysound, 4410) * env); // replace "mysound" with your output

Maxamp will print out amplitude information from its input, at a given number of samples. You will use this information for the last part of the problem.
For \subtract, make sure to use the same frequency and amplitude for both oscillators.
Use a score containing the following buffer allocation and synth calls:

[
// this allocates two buffers: buffer 1 for the Osc UGen, buffer 2 will be for the OscN Ugen
[0.0, [\b_alloc, 1, 512]],
[0.0, [\b_alloc, 2, 512]],
[0.0, [\b_gen, 1, \sine1, 3, 1]],
[0.0, [\b_gen, 2, \sine1, 1, 1]],
[0.0, [\s_new, \oscn, -1, 0, 0, \dur, 5, \freq, 440, \amp, 0.5, \buffer, 2]],
[6.0, [\s_new, \osc, -1, 0, 0, \dur, 5, \freq, 440, \amp, 0.5, \buffer, 1]],
[12.0, [\s_new, \subtract, -1, 0, 0, \dur, 5, \freq, 440, \amp, 0.5, \buffer1, 1, \buffer2, 2]],
[18.0, [\c_set, 0, 0]]
]

You will then render a soundfile using the following commands in SuperCollider.

//a = Score.newFromFile("/path/to/my/score.sc"); NOT NEEDED BECAUSE YOU CREATE JUST CREATE THE SCORE
o = ServerOptions.new.numOutputBusChannels = 1; // mono output
a.recordNRT("/tmp/trashme.osc", "~/mysound.aif".standardizePath, options: o);

Questions:
1. What conclusions can you make?
2. What does the output of \subtract represent?
3. What is the peak output amplitude value of \subtract in dB? (look at the third block of amplitude levels printed out from Maxamp)

Submit: code and text with your answers

Problem 6
Find a frequency value that minimizes the amplitude output of instrument 3. Use the score file from the previous problem as a template (i.e. keep the 3 notes' timing and amplitude values). Explain how you achieve this.

Deliberables:
ONE SC file with SynthDef's as needed for all exercises, plus SC statements as your answers for the problems. Do NOT submit audio files, just one SC file with your code. 461 Dropbox.