# Project 6

## 1. Short Questions

As always, show your work where applicable. Please include your answers for this section in `ANDREWID-p5-answers.txt`.

### 1. Perception

1. What is the frequency range to which human ears are most sensitive?

1. 20-100Hz
2. 550-1880Hz
3. 2000Hz-5000Hz
4. 10000-20000 Hz
2. Harmonic Series are the frequency components that are 1, 2, 3, 4, … times the fundamental frequency. Based on equal temperament where an octave is equally divided into 12 log-spaced semitones, (1) what are the pitches whose fundamentals approximate the harmonic series for A2? Show the first six of them (starting with A2) with necessary calculations. (2) Are the fundamentals of the pitch series exact harmonics?

3. We learned in the lecture on perception that human ears can discern a 5-cent pitch change. If the reference note is C4 (261.63Hz), and we raise the pitch by 5 cents, what is the fundamental frequency of the raised pitch?

4. Localization of sound: Amplitude panning uses just one cue for localization. In this question, let’s make a sound that gives better localization over headphones by delaying one of the channels by some amount of time. In the picture below, assume that B and C are the locations of the right and left ear respectively; the ear distance BC is 18 cm (0.18 m). The left channel is x[t]. What would the right channel be? Assume the amplitude is proportional to 1/d where d is the distance, and the speed of sound is 343 m/s. Write your answer in the form: V x[t-T] by calculating the values for V and T. Note that T is the amount that the sound x[t] is delayed, and V is the volume (amplitude).

### 2. Audio Effects

1. In this question we are only concerned with sound intensity from speaker A. Intensity is power per unit of area, so relative intensity is the same as relative (ratio of) power. There are two loudspeakers located as such:

1. Let’s say you are using linear panning. What is the relative intensity of the sound from speaker A when θ is 0?
2. Still using linear panning, what is the relative intensity of the sound from speaker A when θ is θ_max/2?
3. Now using constant power panning, what is the relative intensity of the sound from speaker A when θ is 0? (Use the constant power panning formula in Roads.)
4. Again using constant power panning, what is the relative intensity of the sound from speaker A when θ is θ_max/2?
2. Why is constant power panning often better than linear panning?

3. Your friend is driving in circles around you. Explain why you would not hear a Doppler effect.

4. We considered convolution in the last project. What sound effects in the list below can not be performed using convolution? Or in other words, which of the following sound effects cannot be achieved by convoluting the original sound with some function like an impulse or a decaying exponential? Choose the right answers from below:

1. Compression
2. Pan
3. Delay
4. Chorus
5. Equalization
6. Reverb
5. Which of the above effects use feedback (the output of the effect is used as a part of input)?

### 3. Physical Model

1. In MSW synthesis, tone production can be divided into two main parts: a non-linear excitation and a linear resonance. If we use MSW to synthesize a trumpet tone, the non-linear excitation would be caused by:

1. Air pressure builds up in mouth
2. Air flow regulated by vibrating lips
3. Valves pressed by fingers
4. Material of the trumpet
5. Shape of the tube

When using a waveguide model for a single-string instrument, what happens if no energy is absorbed by the bridge?

## 2. Physical Models and Patterns

In this project, you will explore physical models and pattern generators. Your main composition task is to generate music using physical model functions built into Nyquist. One problem you will encounter immediately is that just as a violin does not play itself, physical models require careful control to create musical sounds. The warm-up exercises are designed to explore physical models and their control.

### 1. Warm-Up Exercises

Using `clarinet-freq`, create a sequence of clarinet tones separated by 1 s of silence as follows:

1. A 1-second tone at pitch C4 with no vibrato and a breath (roughly the amplitude control) envelope that sounds natural to you.
2. A 2-second tone at pitch D4 with breath envelope vibrato. Design a vibrato that you think sounds natural. You will find the clarinet model has a fairly sudden threshold below which there is no oscillation and above which the tone is fairly strong. If breath vibrato causes the breath envelope to cross this threshold, the clarinet tone may pulse on and off. Control vibrato so that this does NOT happen.
3. A 5-second tone at pitch E4 that has a slow crescendo. The sound should start with a noisy breathy sounding attack that barely has any pitch. Within 1 second, the pitch should be clear. The crescendo should obviously continus until at least 4 seconds. You will find the clarinet model is very sensitive to the breath envelope and there is a very narrow range of envelope values over which a crescendo takes place. You will need to determine good envelope values experimentally.
4. The 8-second sequence (F4, G4, A4, rest, F4, G4, A4, rest) where each element has a duration of 1 second. The first 3 "notes" should be made with one call to clarinet-freq(), using the frequency control to change pitch. (Hint: to get from F4 to G4, the frequency envelope should step up by step-to-hz(G4) - step-to-hz(F4).) The second 3 notes should be separate calls to clarinet-freq(). Try to get a continuous sound similar to the first 3 notes by slightly overlapping F4 to G4 to A4. (Hint: Overlapping is easy if you use a score or write expressions where you can explicitly control start times and durations as opposed to using the seq() construct.)

Put your code (for all of these tones and sequences) in `ANDREWID-p6-warmup.sal`. Concatenate all the sounds with some silence separating them in `ANDREWID-p6-warmup.wav`.

### 2. Composition

Use `score-gen` with pattern generators to algorithmically compose a piece for physical models. You can use any of the physical models in Nyquist: `clarinet`, `sax`, `flute`, `bowed`, `mandolin`, `wg-uniform-bar`, `wg-tuned-bar`, `wg-glass-harm`, `wg-tibetan-bowl`, `modal-bar`, and `sitar`. (Acknowledgment: these unit generators are ported from Synthesis Tool Kit by Perry Cook and Gary Scavone.)

Your piece should have multiple pattern generators, including nested pattern generators to get variation at more than one time scale. For example, if you have a cycle of pitches, you could add an offset to the cycle on each repetition so that you hear the melodic cycle transposed each period. Alternatively, you might generate small random pitch intervals at the small time scale and have the average pitch slowly drift up or down at a larger time scale. You can use make-window and make-repeat to further manipulate streams of data.

You should also have at least two “voices” as opposed to a single melodic line. As always consider panning, reverberation, other effects, and careful mixing to make your piece musical and interesting.

Duration should be at least 60 seconds. Hand in the following files:

`ANDREWID-p6-comp.sal` - the code. `ANDREWID-p6-comp.wav` - the sound file. `ANDREWID-p6-comp.txt` - a short statement of your intention in the composition.

### 3. Pattern Examples

To get you started on some advanced pattern generation, here are some interesting examples to study:

1. This example repeats each value in the cycle 7 times, expanding the cycle to a longer time scale. Without the " for: 1" parameter, the whole cycle (one full period) would repeat 7 times (but cycle would repeat the data anyway, so what's the point?) With the " for: 1 ", the generated period is only 1 so a period is completed after each number is output, so each number is repeated 7 times.

`make-copier(make-cycle({24 36 48 60}, for: 1), repeat: 7)`

1. This example adds two streams. This is one way to get behavior at different time scales:

```make-sum(long-term-pattern-generator, short-term-pattern-generator)```

2. This example makes a series starting at 5 and increasing by 2 each time. The `make-line({5 2})` pattern returns 5, 2, 2, 2, ..., and `make-accumulate` sums the series to get 5, 7, 9, 11, ...

`make-accumulate(make-line({5 2}))`

When all else fails and you really want a specific computation, you can use `make-eval()` to invoke a function to compute a stream of numbers. In this example, a custom function, `myfunc`, does some computation and returns a value to incorporate into a pattern stream. `mypat` uses `make-eval` to call `myfunc`.

```define myfunc() ``````return real-random() set mypat = make-eval({myfunc})```

Of course, `myfunc()` could also access and modify data from another pattern. The simple way to do this is using a global variable since make-eval does not have any way to accept parameters and SAL cannot construct closures.

## Hand-In Summary/Check-list

Answers for "1. Short Questions": `ANDREWID-p6-answers.txt`

Code for "2. Physical Models and Patterns, 1. Warm-Up Exercises": `ANDREWID-p6-warmup.sal`

NOTE: just put the code for 2.1.1-2.1.4 into one file.

Sounds for "2. Physical Models and Patterns, 1. Warm-Up Exercises": `ANDREWID-p6-warmup.wav`

NOTE: concatenate the sounds for 2.1.1-2.1.4 into one wave file (ideally with a little silence separating each part).

Code for "2. Physical Models and Patterns, 2. Composition": `ANDREWID-p6-comp.sal`

Final sound for "2. Physical Models and Patterns, 2. Composition": `ANDREWID-p6-comp.wav`

A short statement of your intention of the composition: `ANDREWID-p6-comp.txt`