View unanswered posts | View active topics It is currently Wed Jan 17, 2018 9:04 pm

Reply to topic  [ 3 posts ] 
 DSP Guitar Effects Pedal 
Author Message

Joined: Sun Aug 26, 2012 2:08 pm
Posts: 1064
Location: Lacey, WA USA
Online IDE for a graphical programming environment to use the Teensy 3.x audio libraries. Loads of audio effects like flange, filter, envelopes, plus synthesized instruments of a few kinds.

Export and place into your code.

With just three blocks, I have 12 bit ADC, Flanger, and 12 bit DAC. See the notes on how to control each effect by simply clicking on the element after you've placed it. The ADC has a schematic for simple circuitry to properly bias the input. Maximum input is 0.6V peak, so a volume control is a good idea. A buffer amp should be included, but a guitar may not require amplification.

The Teensy input should be biased to 0.6V, with a maximum of 1.2Vpp signal. I think I'd include an Op Amp with LEDs that blink when the signal exceeds 1Vpp.

#include <Audio.h>
#include <Wire.h>
#include <SPI.h>
#include <SD.h>
#include <SerialFlash.h>

// GUItool: begin automatically generated code
AudioInputAnalog         adc1;           //xy=151,95
AudioEffectFlange        flange1;        //xy=471,186
AudioOutputAnalog        dac1;           //xy=793,261
AudioConnection          patchCord1(adc1, flange1);
AudioConnection          patchCord2(flange1, dac1);
// GUItool: end automatically generated code

Here is what it says about controlling and using the FLANGE block:

Type AudioEffectFlange
ID flange1
name flange1

Originally, flanging was produced by playing the same signal on two synchronized reel-to-reel tape recorders and making one of the reels slow down and speed up by pressing on the flange of the reel (hence the name). This is a type of comb filtering, and produces a harmonically-related series of peaks and notches in the audio spectrum.

This flanger uses a delay line, combining the original voice with only one sample from the delay line, but the position of that sample varies sinusoidally.

The effect can be represented as:
result = sample(0) + sample(dt + depth*sin(2*PI*Fe))

The value of the sine function is always a number from -1 to +1 and so the result of depth*(sin(Fe)) is always a number from -depth to +depth. Thus, the delayed sample will be selected from the range (dt-depth) to (dt+depth). This selection will vary at whatever rate is specified as the frequency of the effect, Fe. Typically a low frequency (a few Hertz) is used.

Audio Connections
Port Purpose
In 0 Signal Input
Out 0 Flanged Output
begin(delayBuffer, length, offset, depth, delayRate);
Create a flanger by specifying the address of the delayline, the total number of samples in the delay line (often done as an integer multiple of AUDIO_BLOCK_SAMPLES), the offset (how far back the flanged sample is from the original voice), the modulation depth (larger values give a greater variation) and the modulation frequency, in Hertz.
voices(offset, depth, delayRate);
Alters the parameters in a running flanger (previously started with begin).
File > Examples > Audio > Effects > Flange
The longer the length of the delay buffer, the more memory blocks are used.

Try these settings:
int s_idx = 2*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/4;
double s_freq = 3;

The flange effect can also produce a chorus-like effect if a longer delay line is used with a slower modulation rate, for example try:
int s_idx = 3*FLANGE_DELAY_LENGTH/4;
int s_depth = FLANGE_DELAY_LENGTH/8;
double s_freq = .0625;

Steve Greenfield AE7HD

Thu Nov 17, 2016 10:11 am

Joined: Sun Aug 26, 2012 2:08 pm
Posts: 1064
Location: Lacey, WA USA
The AudioMixer can be used for a clipping effect. It will take a bit of care to design it so that it does not just hard clip. Perhaps by using more than one mixing block and combining some of the unclipped signal back in with the clipped signal.

Type AudioMixer4
ID mixer1
name mixer1

Combine up to 4 audio signals together, each with adjustable gain. All channels support signal attenuation or amplification.

Audio Connections
Port Purpose
In 0 Input signal #1
In 1 Input signal #2
In 2 Input signal #3
In 3 Input signal #4
Out 0 Sum of all inputs
gain(channel, level);
Adjust the amplification or attenuation. "channel" must be 0 to 3. "level" may be any floating point number from 0 to 32767. 1.0 passes the signal through directly. Level of 0 shuts the channel off completely. Between 0 to 1.0 attenuates the signal, and above 1.0 amplifies it. All 4 channels have separate settings.
File > Examples > Audio > SamplePlayer
File > Examples > Audio > Synthesis > PlaySynthMusic
File > Examples > Audio > Analysis > SpectrumAnalyzerBasic
File > Examples > Audio > Analysis > DialTone_Serial
File > Examples > Audio > MemoryAndCpuUsage
Signal clipping can occur when any channel has gain greater than 1.0, or when multiple signals add together to greater than 1.0.

More than 4 channels may be combined by connecting multiple mixers in tandem. For example, a 16 channel mixer may be built using 5 mixers, where the fifth mixer combines the outputs of the first 4.

Steve Greenfield AE7HD

Thu Nov 17, 2016 10:13 am

Joined: Sun Aug 26, 2012 2:08 pm
Posts: 1064
Location: Lacey, WA USA
The website says that there is a bit of a noise floor problem.

I think using a separate well-filtered and well-regulated AREF voltage is a start. I also thought I might see if there is a difference in the noise floor based on which input pin is used. The Teensy can multiplex the analog inputs over several pins, some may have more or less noise based on the location of internal and external wiring.


I thought I might start with the 3.2, as it is the least expensive current model of the Teensy ARM boards, and we only need one analog channel. If speed is a problem, I also have a 3.5 and 3.6 on hand to try.


Steve Greenfield AE7HD

Mon Nov 21, 2016 10:15 am
Display posts from previous:  Sort by  
Reply to topic   [ 3 posts ] 

Who is online

Users browsing this forum: No registered users and 2 guests

You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
Powered by phpBB® Forum Software © phpBB Group
Designed by ST Software