12 April 2007

rev_stereo~

rev_stereo~

Left/right input respectively for left/right stereo input.
The creation arguments (liveness, crossover frequency, HF damping) are suplied in three inlets as shown.
  • The "liveness" (actually the internal feedback percentage) should be 100 for infinite reverb, 90 for longish, and 80 for short and so on...
  • The crossover frequency and HF damping work together: at frequencies above crossover, the feedback is diminished by the "damping" as a percentage.So zero HF damping means equal reverb time at all frequencies, and 100% damping means almost nothing above the crossover frequency gets through.This is implemented to simulate a vintage analog reverb sound, because the analog circuitry used had also as an effect that the high frequencies were attenuated.

version

v1.0: built 11/04/2007 with Pd v0.40-2 [pd][pdf]
Final version; defaults are included included, output level has to be controlled from outside (not like in rev3~.pd)


interface

Input1 & 2: the left and right channel from stereo signal

Outputs1-4: 4 different combintions of the internal delay taps. Possibly combine them into left and right output

Controls:
INLET1: set a value for the internal feedback percentage, called liveness, usually between 85 and 100. It ranges form 0 to 100.
INLET2: set a value here that indicates the crossover frequency.Once reached, damping occures. It ranges from 0 to 20kHz. Default is 3000Hz.
INLET3: set a value for percentage of feedback damping after reaching the crossover frequency. It ranges from 0 to 100.


implementation

The input directly goes to the pd doit block, actually the reverbation calculation block. In this case there are 2 different inputs (left and right channel). It is possible to make a combination of the same input into this block.

The control signals are, if needed, translated to different range/values and are given a name. This is the case for INLET1 (gets name fb): the liveness input goes from 0 to 100 (default 85), but in reality has a maximum value of 25%. For INLET2 (gets name lop): the crossover frequency default is set to 3000 Hz. For INLET3 (gets name damp): HF damping is set to a percentage value (default is 50) and a linear transition is set to 50 ms in orde to obtain a smooth change of value.

In the figure below you can see the actual filterbank for calculating the reverbation effect. You can see there are 16 different delay lines that are combined into this diagram and all transformed with respect to the give parameters. Lop~ is used to substract the low frequency part of the signal from the origininal in order to obtain the high frequency part. After this operation damping with factor damp occures. The level of each delay tab is influenced by fb. The actual combinatorial diagram is just one implementation method. Different methods are possible. This is the best found.






10 April 2007

waves


waves

A block that implements some waves with a specific frequency and normalized output. It provides a (co)sine wave, (reverse) sawtooth, triangle and rectangular wave. Two blocks can be added or combined and rescaled in any other way to make new waves. One waves block connected to another one gives quadratic waves.

version

sin~ [pd]
v1.0: built with Pd v0.40-2 [pd] [pdf]
v1.1: adapted with Pd v0.40-2 [pd] [pdf]
sine wave added, RESET knob added
v2.0: built with Pd v0.40-2 [pd] [pdf]
new control logic
reverse sawtooth added

interface

Input 1: A value for the frequency of the wave. It is expressed in Hertz and thus must be positive.
Input 2: Reset knob. When it is pressed, the wave is restarted from the beginning. For a sine wave, square and sawtooth this is 0, for a cosine, reverse sawtooth and triangle it is 1
Input 3: MIDI control change number. This is used to select the wave: when MIDI control change message 52 sends a value of 127 (aka is pressed in), the different waveforms are cycled.

Output 1: A waveform with a specified frequency, specified form and an amplitude that ranges between 0 and 1.

implementation



fig: respectively prints of a reverse sawtooth, sine or cosine, sawtooth, triangle and quadratic wave
The frequency value one inputs is turned into a signal type with sig~. You get a signal with constant amplitude equal to the value specified. Then a phasor~ object runs through every value starting from 0 to 1 and again at a frequency specified. This already is a ready-made sawtooth signal.
The sine block is based on the relationship between sine and cosine function. Read more in documentation of sin~
The sawtooth wave is also used as table lookup signal for the other waves. The cos~ block calculates for each sample the cosine value. This sine is raised above 0 and normalized by dividing with two, or less expensive: multiplying with a half.
The triangle is calculated by shifting the sawtooth so it lies around zero, then taking the absolute value so that the negative part is mirrored to the positive side. This triangle wave has to be scaled by multiplying it with two.
To obtain a reverse sawtooth, the sawtooth is multiplied with -1 which results in a mirroring of the wave around the x-axis. To rescale the wave to a range of 0 to 1, a shift is performed by adding 1 to the wave.
The rectangular wave is made by selectively choosing a 1 or a 0 to output. This is done by the moses block. Because it takes only control lines or values, one has to add a snapshot~ block before it that is banged after each DSP cycle with the bang~ block. The sig~ block transforms this control signal into an audio signal again.
All waves can be seen in the graph when banged on the knob that is located next to the select block on top. It isn't automatically rewritten because that would slow down calculations. Every time a new wave is selected it will be drawn once.
The control logic is simple. When a specific MIDI control change number is received with a value of 127 a counter adds up. This addition is modulo the number of waveforms. An extra select block is added to select a number from the counter and then bang the right message. Each output in this patch has a multiplication with one or zero to turn it on or off.
-ronny 4/14/07 6:59 PM



06 April 2007

phaser~

phaser~

Adds a phase-shifted sound to the original sound, producing a swirling modulation that creates spaciousness and depth. Three different methods are selectable and one can control the frequency and range of the modulation, also providing different control wave forms.


version


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

interface

Input1: incoming mono audio signal
Input2: this inlet takes values between 0 and 127 that specify the frequency of the control waves. It stands for the RATE parameter.
Input3: this inlet takes values between 0 and 127 that specify the range of the control waves. It stands for the DEPTH parameter.

Output1: The phase shifted mono signal that is output.

Controls:
Different control curves: For a sine wave, sawtooth, triangle or square wave, currently the MIDI control messages are assigned this way: respectively 52, 53, 54, 55.
Different phaser implementations: Also assigned with MIDI control change messages: 4 allpass stages is 56, 3 times 4 stages is 57 and 6 stages is 58. The default is four allpass stages.

implementation

The basic building block of the phaser is a pd allpass~ block. As seen in the figure it is a real one-zero (non-recursive) 'reverse' filter followed by a real one-pole (recursive) filter, both with the same coëfficiënts. For visual reasons, the coëfficiënts are passed to an outlet. This combination thus presents one stage of allpass filtering. This leaves the gain of all frequencies unchanged, but it alters the phase response.
The coëfficiënts of these allpass filters are altered in time. The waves block outputs a specific control curve with a chosen frequency (RATE). This curve (that lies between 0 and 1) is then scaled with the DEPTH parameter and it is also offset to lie under one. The DEPTH parameter is divided by 131 because the maximum value of the curve is 0.97 and when a range is chosen it can maximally extend to zero. The maximum value that can be passed is 127, so the 131 divides the interval maximally.
With the select and ctlin block one can choose between three setups. The A-form (A has no special meaning) uses four stages and outputs the signal coming from the last stage. The B-form, that sounds more boosted, uses three times four stages and sums every block of four stages. The C-form is another widely spread form that uses 6 allpass stages.

05 April 2007

beat detection in pure data

Today I've also been working on a beat detection algorithm for pure data.
The basic idea behind the whole algorithm is outlined in beat this!.
It consists of four steps:
  • filterbank
  • smoothing
  • diff-rect
  • comb filtering
The first three steps (see website for more explanation) are done by the bonk~ block that is included in the standard Pd download. So as an output we get, for eleven parts of the frequency spectrum, the loudness of an attack.
The last step use a bunch of combfilters, each representing a specific tempo. All filters are convoluted with each signal and this should have to give higher energy values for comb filters that are close to the tempo of the signal.
I made a combfilter block that we can use afterwards. It uses three arguments: window, frame or blocksize firstly, then the resonant frequency and then the bandwidth. The bandwidth specifies how wide the teeth of the comb are: when it is close to zero, most of the signal is let through. When it's close to 0.5, the teeth are very wide and there is not much space between them.
I already realize that the convolution is better done in the frequency domain, because it is a multiplication there.
But the rest is for tomorrow or something.
Sleep tight

04 April 2007

flanger~


flanger~

This block applies a flanger effect on the incoming mono audio signal, that is the original signal delayed with a variable delay. It gives a metallic resonant effect like a jet plane taking off or landing. You can choose between several control curves and a free input for a control curve. You also have to include an argument otherwise the effect won't work.

version

waves v2.0: look at the documentation of this block to see what it does [pd]
v1.0: built 4/04/2007 with Pd v0.40-2 [pdf]
v1.1: built 5/04/2007 with Pd v0.40-2 [pdf]
waves block added for more choices in control curve
free control added
v1.2: built 13/04/2007 with Pd v0.40-2 [pd][pdf]
waves block is separated in development and documentation
thus no real differences with previous version, alone the documentation has changed.
v2.0: built 13/04/2007 with Pd v0.40-2 [pd][pdf]
a feedback loop is added and the level and feedback are unified into one control

interface

Input1: incoming mono audio signal
Input2: modulation frequency (MODFREQ) ranges from 0-127 (representing normalized values between 0 and 1). This parameter specifies how fast the delayed signal changes between leaping forward and lagging behind. It's modulation curve is selectable in the waves block: one can cycle through different waveforms by pushing a specific button (see documentation on waves). The amplitude is fixed to 10. If one wants to use a different amplitude for the control curve of the variable delay, the previous version should be used.
Input3: the feedback level (FBK) ranges from 0-127. This parameter specifies the range of the variable delay, how far it lags behind or leaps forward. It represents the maximum difference from no delay. When leaping forward the pitch gets higher and vice versa. If it's zero, the loop is off.
Input4: an inlet for a control signal that directly controls the variable delay time. Be careful to give a quite low frequency signal with an amplitude that is not too big.

Output1: outgoing mono audio signal: this is only the wet signal, the original signal delayed with a variable delay.

implementation

The input signal is written into a delay line.
The waves block outputs a normalized waveform with a frequency specified by the MODFREQ parameter.
The amplitude is fixed to 10 by a multiplication. This waveform is then used as the varying delay time for the vd~ block. When the values of the waveform are greater than zero, the delay will leap forward (with a maximum of one block size), when it's smaller it leaps behind (the delay time is greater).
This signal is put in the feedback loop, which feedback level is controlled by a simple amplitude logic consisting of scale block (/127) and a multiplication.

It is important to include an argument. This is needed to make, at the same time, 2 different flanger computations possible. Otherwise the delay-lines of several flanger effects used would have the same name. Now with the dollar sign, the name of the argument is inserted.




02 April 2007

stereomultitapdelay~


monomultitapdelay~

This is a versatile delay effect. It can simulate the traditional delay (as in the monotraditionaldelay~ block and others), and many more. One has ten taps at his disposal, each one is separately controllable: delay time DLY, volume level of that tap LVL and place in the stereo image PAN. The first five taps also have the feedback level FBK parameter (as for the traditional delay).
Use:
  • To simulate the monotraditionaldelay~ use one of the first five taps, set LVL and PAN to 0. All other parameters are also 0. Now choose your DLY and FBK.
  • Ping-pong delay: Look at the figure on top of this page. Every tap is routed to another output. Here you see a L-R style. Other styles are: L_C_R, dynamic and random.
Every tap is output separately, but the stereo signal is on the last two outputs. All these signals are wet (that means, the original signal is not included)

version

monotraditionaldelaysimple~ v1.0 [pd]
pan~ v1.0 [pd]
v1.0: built 2/04/2007 with Pd v0.40-2 [pd][pdf]
Temporary version; presets will be included, display will be less full, more inputs will be added to control the effect like other delay blocks (BPM, measure, an array of DLY,...)

interface

Input1: the mono signal you want to delay/ go crazy

Outputs1-10: the mono signal that is output by the corresponding tap
Outputs11-12: the left and right main output of the effect. All the taps are summed here after being placed in the stereo image.

Controls:
DLY1-10: set a value here that indicates when the delayed signal will be throughput. It ranges from 0 to 3000msec.
LVL1-10: set a value here that indicates the volume level of the corresponding tap. It ranges from 0 to 100, 100 meaning at the same level as the input signal.
FBK1-5: set a value here that indicates the attenuation of the inner delay loop of this tap. It ranges from 0 to 100, 100 meaning that the loop will keep on repeating infinitely and as loud as the input signal (instability)(TO DO)
PAN1-10: set a value here that indicates where the mono signal is placed in the stereo image. It ranges from -127 to 127, 0 meaning CENTER. The panning curve used is the equal power sine curve.

implementation


The input is directly written in a delay line delay with a maximum delay length of 3000 msec. It is also on a bus with the throw~ block for every tap to grab the signal from.
The main output section also consists of two buses, one for each channel of the stereospectrum.

From left to right: a single delay part with feedback control, a single delay part and a single tap part.
A delay in a tap is done by reading the delay line delay at a specific time. The delread~ object does this. For the five first taps also a simple mono traditional delay block is foreseen. It's nothing but a skinned version of the original monotraditionaldelay~ block. It also has no display. You can see the implementation in the figure hereunder.
Every tap is then attenuated by the LVL parameter before being sent to its output. Also this attenuated signal is panned with a pan~ block, also a simpler version of the original monopanner~ block. See the figure underneath. As you can see, also here the controls are left out and only the inlets are kept. It is then put on the buses outL and outR. There will be no documentation for these two blocks as long as their not used elsewhere.

For completeness also the implementation of the controls and display are given. Every parameter is sent or received apart, where a pack and unpack block could have been used. This is not done because the idea exists that it would slow down the algorithm. This because every time a parameter would change, a whole array must be re-sent, packed and unpacked. On the other side, it would look nicer.

01 April 2007

monotraditionaldelay~

monotraditionaldelaybpm~

This block implements a traditional delay effect with feedback loop. Every parameter can be changed by the inlets, except the measure. It handles a mono signal and outputs a mono signal too. It is based on the parameter bpm and works on the tempo of the song. You can choose how much times the delayed signal is repeated between two beats.

version

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

interface

Input 1: the mono signal you want to delay
Input 2: the beats per minute parameter BPM
Input 3: the feedback parameter FBK

Input 4: the on/off switch for external control

Output 1: the delayed, wet mono signal

Controls:

params: These four number boxes show the current values of the respective parameters. There's also a small slider to display the DLY parameter physically (easier to compare the effect of the BPM on the DLY). The DLY value is the delay time between the current and the next signal samples. The BPM value is current tempo that is chosen. actFBK is the current feedback level, which indicates the attenuation of the next delayed signal compared to the current one. The memFBK is the value of FBK that will be used when the switch is turned to back on.

TO DO: find another name for this parameter, as the FBK is not really remembered. This is not a problem, because one has to be able to set a new value before turning it on again.
top number box and horizontal slider: adjust the beats per minute (BPM) parameter. One can choose a tempo for the delay. It ranges from 20bpm tot 250bpm. This equals a maximum delay value of 3000msec when a BPM value of 20bpm is chosen and the measure is 1/1.
bottom number box and horizontal slider: adjust the feedback (FBK) level parameter. The signal is attenuated with this value divided by 1000. In other words, you can vary the level from 0 (no delay audible) to 0.999 (maximum amplitude of the delayed signals, keeps on repeating as if it never ends) with steps of thousands.
switch button: is used to set the FBK parameter to 0 and thus turning of the delayed signal. When the switch is turned back on, the last chosen value of FBK or the new value if the controls are changed, will be reset.

measure: One can specify how many times the signal is sent back into the delayloop between two beats. A fraction of 1/2 will divide the DLY time by two, so that two delays are heard between two beats.

TODO: maybe also some fractions with a numerator greater than the denominator can be added to the effect.

implementation

The delay itself is pretty simple: the incoming signal is read by a delread~ object that writes the signal into a delay line called delay1 and with length 3000msec. Although there's no visible loop, this is how the loop is formed: after a delay time DLY the associated delread~ object reads what's in the delay line, outputs it and sends it back into the delwrite~ object. Before outputting the delayed signals they are attenuated every time by a factor FBK ranging between 0 and 0.999 (with 1 clipping is to easy), in steps of thousands. That's why the control parameter lies between 0.001 and 999.
A possibility is left in the implementation to also mix the wet output with the original, dry signal, by connecting the unconnected throw~ and catch~ objects.
TO DO: It's possible to also implement an HF DAMP function which simulates a retro analog delay effect. It's nothing more than adding a lowpass filter with fairly high cutoff frequency (or even adjustable) in the delayline.
A short calcultation is done to compute the delay time parameter from the BPM and the measure choice DIV. DLY=DIV*60000*BPM^-1. The bang and multiplication block have to be added to ensure direct reaction when another measure is chosen. Here also the default value of 1 is set by using it as a parameter in the multiplication lbock.

The initialisation is done mainly at the left of the canvas: The BPM is set to its maximum value 250 so that the DLY is as small as possible. FBK is set to zero and the switch is off too.

The switch functions because the value of the toggle (0 or 1) is used to multiply the current FBK with, resulting in a zero when the switch is off and the actual value if it is on.