Please make a Pd patch that plays a chromatic scale using a clarinet wavetable loaded from the wavefile BbClar.ff.D3.wav. The scale should start to play after pressing a single start button, play a note from a 12-note chromatic scale every 1 second (the soundfile/wavetable is over 2 seconds long, so reading twice as fast will shorten note duration to just over a second), and then stop/reset after pressing a single stop button.
Consider the follwing steps:
1. Read the wavefile to an array (remember the resize flag!) using the soundfiler object. The output
of soundfiler will give you the length of the wavefile in samples N .
2. Use a metro and counter to output a number between 0 and 12 every 1500 ms. The number between 0 and 12 will be h, the semitones above the natural pitch of the wavetable (played without a change in speed).
3. You will read from the wavetable using a phasor object, and will need to determine how to set its frequency. There are a few ways you can do this, but you will need the values N and h (obtained above).
(a) determine at what frequency you should set the phasor so the sound’s pitch is unchanged; referring to the notes on wavetables, that would be the sampling rate divided by the length of the wavetable (fs/N), a transposition factor of 1.
(b) for higher pitches in the scale, the transposition factor will be 2h/12, where h is the number of semitones above the original pitch;
(c) multiply the transposition factor 2h/12 by fs/N to obtain the phasor frequency;
(d) you may use a number of arithmetic objects to implement the above math, including the pow object, but you might find this awkward with the triggering done only when an action (number or bang) arrives in an object’s leftmost inlet (though try it!). There are workarounds, including using the trigger object.
(e) alternatively, you may wish to implement the whole equation using the expr object along with variables such as$f1, a holder for h, and$f2, a holder for N—this will be cleaner and easier.
4. Make sure that every time you play a new note at a new frequency, it also resets the phase of the phasor to zero. Otherwise, you may play a new note/pitch starting somewhere in the middle of the wavetable rather than at the beginning (and it will sound clumsy!).
5. Polish with a single on/off button making sure it takes care of everything for you (there should be no messages, resets or buttons that have to be pressed manually in the patch).