08 May 2007

octaver~

octaver~

This block has two outputs, respectively the input signal one octave higher and the input signal one octave lower. The synthesised octave effect is obtained by doubling (octave-up) or halving (octave-down) the frequency of the original input signal. This is possible due to the simple two-to-one relationship between the frequencies of musical notes which are separated by an octave.

version

v1.0: built 8/05/2007 with Pd v0.40-2 [pd][pdf]

interface

Input1: incoming mono audio signal

Output 1: original signal one octave lower
Output 2: origininal signal one octave higher

implementation

For the left output (octave higher) the purpose is to take out the odd harmonics. The result is a signal with only the even ones left, which sounds an octave higher. The spectral envelope of the input will remain roughly unchanged. In this way we avoid the chipmunk effect resulting by using a speed change to obtain a pitch shift. To do so we use a variable comb filter without feedback (non recirculating) that combines two delayed copies of the incoming signal. One copy with a fixed delay (delread~) with a window size set to that one of the pitch following algorithm. The delay in ms is adjust to the output of fiddle~: 1000.2048/Fs with Fs= sample rate. (where mtof is used to translate MIDI pitch to frequency) The variable delay is the same, plus 1/2 of the measured period of the input signal, 1000/(2f) ms where f is the frequency in cycles per second. These two delay times are added and smoothed with line~ and then used as input in the variable delay line vd~. The resonant frequencies of the resulting comb filter are 2f,4f,6f,... because the difference between the two delays is 1/2f. The the response is zero for f,3f,5f.... Thus the odd harmonics have been filtered out. You can consider this operation in a different way. The incoming signal is output twice, a half cycle apart: odd harmonics are shifted 180 degrees and cancel eachother out. The even ones are in phase, so they don't.

For the right output (octave lower) we use ring modulation. The ring modulation itself happens in osc~ and with the multiplier block. Multiplying with 2 is done to get the original better balanced. Again we get the fundamental frequency from the fiddle~ block (after conversion from MIDI pitch). This is then of course multiplied with 1/2 to get one octave lower.
The moses is used to stick the most recent good guess, because when fiddle fails it outputs 0. Because fiddle~'s analyse is most closely aligned to the middle of the window(2048/2) a standard pd delay block of fixed 1024 samples of the original signal, can be used for synchronization. You can change this to get a different effect. It is also possible to change the factor 1/, by example a large integer (15) and you'll also get a completely different effect (introduction of formants).
In this implementation we use osc~ to get the ring modulation. You have to notice that osc~ only uses the sine wave to modulate the original signal.
We could use our own waves block to get more possibilities.


No comments: