09.12.2012 Views

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

The Kyma Language for Sound Design, Version 4.5

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

every 256 samples, it outputs the spectrum <strong>for</strong> the next frame. We are trying to make a synthetic set of<br />

pitches <strong>for</strong> the spectrum. Since we know they should be evenly spaced in log frequency, we have set the<br />

SyntheticSpectrumFrom<strong>Sound</strong>s to LogScale, and we are using a ramp wave (i.e. a linear function from<br />

zero to one) that repeats every 256 samples to specify the pitches — assuming that the first partial is the<br />

lowest, then the next partial, and so on linearly until reaching the highest pitch when the ramp reaches its<br />

highest value. Why did we use a Sample with loop rather than an Oscillator? Because the Sample, unlike<br />

the Oscillator, does not interpolate between the last value be<strong>for</strong>e the loop and the beginning of the loop.<br />

For wave<strong>for</strong>m generation, the Oscillator would be better, but <strong>for</strong> this specific application, we want<br />

something that drops immediately from one back to zero, without interpolation.<br />

OK, so far, with a 256 sample period of repetition, we have a static spectrum that does not change from<br />

frame to frame and that gives us components whose frequencies are evenly spaced in pitch space.<br />

What is the effect of increasing or decreasing the frequency of the Ramp wave?<br />

Increasing the frequency of the ramp wave effectively increases its slope. So each corresponding point<br />

along the line is a little larger than it would have been at the original repetition rate. <strong>The</strong> effect is that the<br />

pitches of all the components go up.<br />

Decreasing the repetition rate gives the ramp a shallower slope. So corresponding points are smaller than<br />

they were in the original ramp wave, and the pitches of all components are correspondingly lower.<br />

So far, so good. But we don’t have just a single ramp wave, we have a repeating ramp wave controlling the<br />

pitches of the components. A change in the repetition rate of the ramp means that it no longer lines up<br />

with the 256 sample-long frames. If we increase the repetition rate, the ramp will wrap around to zero<br />

be<strong>for</strong>e the end of each frame. In a sense, the repeating ramp is “rolling” with respect to the frame rate.<br />

Think of two identical tapes being played at very slightly different rates; they slowly move out of synchronization<br />

until they are so far out of synchronization that they line back up again. Or think of two sine<br />

waves that are 2 or 3 hertz apart in frequency; they gradually move out of phase with one another until<br />

they are fully 180 degrees out of phase at which point they line back up (causing a beating effect as they<br />

rein<strong>for</strong>ce or cancel each other during the “roll”).<br />

It turns out that this “roll” is exactly what we want to get the circular pitch effect. Think of one point on<br />

the ramp wave. If we increase the slope of the ramp, then on each frame, this point is higher than it was<br />

on the last. This is true until it reaches the maximum value. <strong>The</strong>n on the next frame, it returns to the lowest<br />

value again. This is the result we are after: that each component increase in pitch until reaching the<br />

highest frequency and then that it wrap around and sneak back in at a subaudio frequency.<br />

<strong>The</strong> Gain called 256 scales the ramp so that its range is (0,256). <strong>The</strong> Attenuator called interval density<br />

reduces that range to achieve the actual pitch interval that you specify with !Int. <strong>The</strong> log frequencies are<br />

set up so that one is the half sample rate and each decrease of 1/15 is a decrease of one octave from that<br />

maximum frequency. <strong>The</strong> Attenuator turns your interval into a fraction of an octave and uses that to<br />

scale the range of the ramp function.<br />

Now <strong>for</strong> the really cool part! How to specify a spectral envelope? It would be tempting to just take an Oscillator<br />

on the Hann wavetable and use that as the Amplitude input to the SyntheticSpectrum-<br />

From<strong>Sound</strong>s. But it would be wrong! Actually <strong>for</strong> a static spectrum, it would be OK. But each amplitude<br />

is matched with its corresponding partial number, not necessarily with any particular pitch. And we have<br />

partials that are changing frequency on each frame. So we need some way to associate specific amplitude<br />

values with specific pitches. One way to do this would be to have a table of values that list the amplitude<br />

value <strong>for</strong> each possible frequency, and use the current frequency value to look into the table <strong>for</strong> the correct<br />

amplitude value to use.<br />

This concept — that of a table where you can use one value as an index into the table and output the<br />

value found at that index — immediately suggests the Waveshaper.<br />

<strong>The</strong> Waveshaper is a nonlinear transfer function that maps values between -1 and 1 to arbitrary values<br />

stored in an arbitrary-sized table. So the first task is to get our all-positive frequencies to lie between -1<br />

and 1. This is accomplished by the ScaleAndOffset called -1 to 1. It simply multiplies by two and subtracts<br />

one.<br />

This scaled value is then used as an index into a Hann function (<strong>for</strong>ced to zero on the first and last entries<br />

of the table) by means of the Waveshaper called pch->amp.<br />

166

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!