concept pitch in category chuck

This is an excerpt from Manning's book Programming for Musicians and Digital Artists: Creating music with ChucK.
The “sss”
looks about the same, still noisy with lots of wiggles in the waveform, but the “eee” sound quickly enters into what’s called periodic oscillation, with a basic shape repeating over and over
. There might be small deviations due to noise, quavers in the voice itself, or other factors, but the oscillation generally repeats over and over again. This is characteristic of sounds that have pitch. Pitch is your perception of frequency from low to high. It’s what you sing or whistle of a song melody, and it’s what musicians notate and talk about in terms of note names and numbers. The keys of the piano keyboard are oriented from low (left) to high (right) pitches.
Most anything that gives you a sense of pitch exhibits periodic oscillation, and anything that oscillates periodically will sound pitchy (within certain frequency ranges). The region marked as T in figure 1.2 is the period of oscillation (usually given in seconds), and 1/T is the frequency of the oscillation in cycles per second. So in the case of the “eee” sound, if the period T is measured as 6.6 milliseconds (a millisecond is one 1000th of a second), then the frequency of oscillation will be 1/0.0066 = 150 cycles per second, or 150 Hz (the unit of frequency named after physicist Heinrich Hertz, pronounced “hurts”).
If you repeat that single period of “eee” over and over, looping at a convenient point like at the main peaks, you could synthesize an “eee” sound of any length you like. If you play that loop slightly faster, the pitch will go up. Play it slower and you get a lower pitch. That synthetic sound would be pretty dull and boring, because by selecting one period and looping that exactly over and over, you’ll have removed all the noise, slight deviations of pitch, and other things that made the original sound natural. This is one reason that synthetic speech sounds so, uh, synthetic.
We’ll look at two libraries, or collections of functions: the ChucK Standard library (called Std) and the ChucK Math library. By learning about the Standard library functions that convert numbers and units, you’ll be able to control pitch and loudness much more easily. You’ll also learn ways to convert between data types, from strings to numbers and back, for example. In the Math library, you’ll learn more about generating and using random numbers and how to round floating-point numbers to integers. You’ll also use some cool math procedures, like computing values of a sine function explicitly using the built-in sin() function of the Math library, to control synthesis parameters in musically interesting ways. Specifically, in section 2.3 you’ll use a sin() function to smoothly pan a signal left and right in the stereo sound field.
Remember from chapter 1, in order to play our “Twinkle” song you had to type in lots of numbers for pitches? Some of those, like 220 and 330, were easy. But how did we come up with those? Others, like 415.305 Hz, might have caused you to ask, “Where in the world did that come from?” Well, one of the most useful Standard library functions allows you to quickly figure out the frequency of any musical note. And the Standard library has loads of other useful functions, such as one that helps you compute a gain that’s related to your perception of loudness, and other functions to convert between different data types. Armed with a couple of Standard library functions, you’ll be able to play our “Twinkle” song much more easily, and your code will be more friendly and readable. So let’s dig in and look at some of the functions in the Standard library!
Listing 6.3. Sci-fi techno dance bass line using the PulseOsc UGen
//PulsOsc for techno-bass, by ChucK Programmer, 2014 PulseOsc p => dac; // connect a new PulseOsc to dac // infinite loop of sci-fi techno! while (true) { Math.random2f(0.01,0.5) => p.width; // set random pulse width if (Math.random2(0,1)) // pick a pitch randomly { 84.0 => p.freq; // from one of } else { 100.0 => p.freq; // two different pitches } 1 => p.gain; // turn on oscillator 0.06 :: second => now; // hang out a bit 0.0 => p.gain; // turn off oscillator 0.04 :: second => now; // hang out a bit }
looks about the same, still noisy with lots of wiggles in the waveform, but the “eee” sound quickly enters into what’s called periodic oscillation, with a basic shape repeating over and over
. There might be small deviations due to noise, quavers in