CSE 490s Lab 2: Supercollider 2

In this lab we'll explore more of the syntax of Supercollider and make some sounds.

DANGER!! I haven't made all of these work under Windows-- they do work on a Mac. I think they'll work on Windows, but be aware...you may have to fix them...

Part I. Tutorials

Work through the following short tutorials. These are .sc documents; download to your workspace and open them from Supercollider.

6.Gates

7. Review

8. SynthDefs

9. Multichannel

Reference files:

10. Windows Examples (for information only...)

Other examples (I haven't run all of there; there may be some Mac>>Windows problems)

1IntroToSCSynth.sc
2aArchitecture.sc
2bUGenOscBasics.sc
2cSignalGenerators.sc
2dEnvelopes.sc
3SynthDefsSynth.sc
4aAM-FM.sc
4bFMPartII.sc
5Non-linearSynthesis.sc
6Sampling.sc
7GranularSynthesis.sc
8Wavesets.sc
9Noise.sc

Part II. Synthesis Assignment 2

Due: Monday, Oct. 17, 9 pm

Create a SC file that is titled with your last name and first initial followed by #2.sc.  For example, "HemingwayB#2.sc".  

In this file you should create an example of SuperCollider code that does the following:

(part 1)

1a. Create a SuperCollider example that demonstrates the use of a gate control signal to create envelopes at random times:
• Use LFNoise0 in combination with an ADSR envelope to create the random envelopes (you select the adsr envelope shape and timing)
• Use Blip as a source signal (you select the frequency and number of harmonics)

1b. Create a SuperCollider example that demonstrates ring modulation (type 1 amplitude modulation)(look in Supercollider help files):
• Use Dust to trigger a 'percussive' envelope to create random envelopes (you decide the Dust density)
• Apply these random envelopes to the output of a Blip signal generator (you decide the frequency and number of harmonics)
• Add an additional SinOsc unit generator and control its frequency with MouseX (you select MouseX's range of frequencies)
• At the very end multiple the output of the Dust by the output of the SinOsc.

Answer these question (in comments in your code file) What happens to the timbre? Can you adjust MouseX so that the audio sounds bell-like?
Be sure to play and to plot the results from all three with the scope!

(part 2)

Review the examples in the document 8SynthDefs. Below is an example of an FM instrument which
implements the Chowning FM trumpet. It has been slightly modified to create variables for duration
and gain. Also, instead of frequency, pitch is given by a MIDI number.

({ // Modifed example with new variables for duration and gain; also pitch as MIDI number
    var duration, gain, midiPitch, peakFMI, c, m;
    var fundFreq, carrierFreq, modulatorFreq, env, amp, instFreqDv, instFreq;

    duration = 0.6;
    gain = 0.5;
    midiPitch = 69;
    peakFMI = 5;
    c = 1;
    m = 1;

    fundFreq = midiPitch.midicps;
    carrierFreq = c * fundFreq; // C:M ratio determines the carrier and
    modulatorFreq = m * fundFreq; // the modulator frequencies
    env = Env.new([0, 5.0, 3.75, 3.0, 0]/5, [0.1, 0.1, duration - 0.3, 0.1], 'linear');
    amp = EnvGen.kr(env, doneAction:2);
    instFreqDv = peakFMI * amp * modulatorFreq;
    instFreq = SinOsc.ar(modulatorFreq,0,instFreqDv,carrierFreq);
    SinOsc.ar(instFreq,0,amp);
}.scope;)

2a. Conversion to Using SynthDef/Synth. Take this FM instrument and change its form to create a
SynthDef called FMInst. This instrument should take the following as arguments that can change for
each note: duration, gain, midiPitch, peakFMI, c and m. Also, write a Synth statement that
demonstrates playing one note on your instrument.

The form of the code should be similar to:

( // DEFINE YOUR SYNTHDEF
    SynthDef( "SinEnv", { arg duration=1, gain=0.5, midiPitch=69; // three arguments here which can change with every note
        var out, env, amp, frequency;

        frequency = midiPitch.midicps;
        env = Env.linen(0.1, duration - 0.2, 0.1, gain);
        amp = EnvGen.kr(env, doneAction: 2);
        // arguments are now used in the unit generators
        out = SinOsc.ar(frequency, 0, amp);
        Out.ar( 0, out );
    }).send(s);
)

The most important lines of code are the arguments at the top and the Out statement near the bottom.

Here is a Synth statement that demonstrates playing one note on this example instrument.

Synth( "SinEnv", [ \duration, 1, \gain, 0.5 , \midiPitch, 69] );

2b. Create a short melody with your new SynthDef by writing a series of Synth statements in a Routine.

Here is an example using the SynthDef example in part a:

( // In order to create a sequence of notes, the Synth must be within a Routine so that you can have a wait inbetween the notes
    Routine({
        Synth( "SinEnv", [ \duration, 0.2, \gain, 0.2 , \midiPitch, 60]);
        0.25.wait;
        Synth( "SinEnv", [ \duration, 0.3, \gain, 0.3 , \midiPitch, 64]);
        0.25.wait;
        Synth( "SinEnv", [ \duration, 0.4, \gain, 0.4 , \midiPitch, 67] );
        0.25.wait;
        Synth( "SinEnv", [ \duration, 1.0, \gain, 0.5 , \midiPitch, 72] );
    }).play;
)

Your melody should be more interesting than this example!

Email your SC file to bruceh@cs.washington.edu. KEEP A COPY!!

Assessment.  Each programming assignment will be assessed as either complete, incomplete or not received (C, I, or N).  

C:  To be complete, all components of the assigned need to be completed in the submitted work.  Omitting elements will lead to an incomplete.  
N: If the assignment is not received by the due date, it is assigned an N and there is no opportunity to redo the assignment. 
I: If you receive an incomplete, you will have an additional week to redo the assignment and to turn in a revised version.  If the revised version fulfills all elements of the assignment, it will considered complete and receive a C.  Revised work files should have the letter ‘Rev’ appended to the original file name.

---------------