## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 3 years 9 months ago #1186

• Ray
• Moderator
• Posts: 702
• Karma: 44
This program includes several effects in the same code for pedalSHIELD UNO; you have Clean, Booster, Distortion, Fuzz, Bit-Crusher in the same code.
To change the effect, you just need to flip the toggle-switch, every time the switch is flipped, the effect change and once you reach the last one (bit-crusher) if goes to the first one (clean).

Basically, in the main loop you have:
//Depending on the Toggle switch position, the effect is changed (up to 4 effects)
{
toggle_position = digitalRead(TOGGLE); //update the new value
effect++;  //effect incrementation
if (effect>4) effect=0;  //if you reach the last effect, go to the first in a loop.

//set the default variables for all effects:
vol_variable=10000;
distortion_threshold=6000;
fuzz_threshold=6000;
bit_crush_variable=0;
}
Everytime you read the toggle and it is different from the previos read, the effect is incremented.
Also, every time the effect is changed, all the variables are reset (this part is not mandatory).

The full effect is this:
// CC-by-www.Electrosmash.com
// Based on OpenMusicLabs previous works.
// multi-effects.c including

//defining hardware resources.
#define LED 13
#define FOOTSWITCH 12
#define TOGGLE 2
#define PUSHBUTTON_1 A5
#define PUSHBUTTON_2 A4

//defining the output PWM parameters
#define PWM_FREQ 0x00FF // pwm frequency - 31.3KHz
#define PWM_MODE 0 // Fast (1) or Phase Correct (0)
#define PWM_QTY 2 // 2 PWMs in parallel

//other variables
int input;
int counter=0;
int effect=0;
int toggle_position=0;

//effects variables:
int vol_variable=10000;
int distortion_threshold=6000;
int fuzz_threshold=6000;
int bit_crush_variable=0;

void setup() {
//setup IO
pinMode(FOOTSWITCH, INPUT_PULLUP);
pinMode(TOGGLE, INPUT_PULLUP);
pinMode(PUSHBUTTON_1, INPUT_PULLUP);
pinMode(PUSHBUTTON_2, INPUT_PULLUP);
pinMode(LED, OUTPUT);

ADCSRB = 0x07; // t1 capture for trigger
DIDR0 = 0x01; // turn off digital inputs for adc0

// setup PWM
TCCR1A = (((PWM_QTY - 1) << 5) | 0x80 | (PWM_MODE << 1)); //
TCCR1B = ((PWM_MODE << 3) | 0x11); // ck/1
TIMSK1 = 0x20; // interrupt on capture interrupt
ICR1H = (PWM_FREQ >> 8);
ICR1L = (PWM_FREQ & 0xff);
DDRB |= ((PWM_QTY << 1) | 0x02); // turn on outputs
sei(); // turn on interrupts - not really necessary with arduino

//read the initial position of the toggle switch:
}

void loop()
{
//Turn on the LED if the effect is ON.
else  digitalWrite(LED, LOW);

//Depending on the Toggle switch position, the effect is changed (up to 4 effects)
{
toggle_position = digitalRead(TOGGLE); //update the new value
effect++;
if (effect>4) effect=0;

//set the default variables for all effects:
vol_variable=10000;
distortion_threshold=6000;
fuzz_threshold=6000;
bit_crush_variable=0;
}

}

ISR(TIMER1_CAPT_vect)
{
ADC_low = ADCL; // you need to fetch the low byte first

input = ((ADC_high << 8) | ADC_low) + 0x8000; // make a signed 16b value

//update variables with the push-buttons
counter++; //to save resources, the pushbuttons are checked every 100 times.
if(counter==100)
{
counter=0;
{
if (vol_variable<32768)vol_variable=vol_variable+10; //increase the volume
if(distortion_threshold<32768)distortion_threshold=distortion_threshold+25; //increase the distortion
if (fuzz_threshold<32768)fuzz_threshold=fuzz_threshold+25; //increase the fuzz
if (bit_crush_variable<16)bit_crush_variable=bit_crush_variable+1; //increase the bit crushing
}

{
if (vol_variable>0)vol_variable=vol_variable-10; //decrease volume
if (distortion_threshold>0)distortion_threshold=distortion_threshold-25; //decrease the distortion
if (fuzz_threshold>0)fuzz_threshold=fuzz_threshold-25; //decrease the fuzz
if (bit_crush_variable>0)bit_crush_variable=bit_crush_variable-1; //decrease the bit crushing
}
}

//update variables with the push-buttons

if (effect==0) //CLEAN EFFECT
{
//clean effect so, do nothing
}
//construct the input sumple summing the ADC low and high byte.
else if(effect==1) //VOLUME EFFECT
{
input = map(input, -32768, +32768,-vol_variable, vol_variable);
}
else if(effect==2) //DISTORTION EFFECT
{
if(input>distortion_threshold) input=distortion_threshold;
}
else if(effect==3) //FUZZ EFFECT
{
if(input>fuzz_threshold) input=32768;
else if(input<-fuzz_threshold) input=-32768;
}
else if(effect==4) //BIT CRUSHER EFFECT
{
input = input<<bit_crush_variable;
}

//write the PWM signal
OCR1AL = ((input + 0x8000) >> 8); // convert to unsigned, send out high byte
OCR1BL = input; // send out low byte
}

#### File Attachment:

File Name: multi-effects.zip
File Size: 2 KB

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 3 years 9 months ago #1188

 alessiow OFFLINE Junior Member Posts: 23 Thank you received: 11 Karma: 3 Nice job..I was working on doing mine a whole different way. was way over thinking it....lol The administrator has disabled public write access. The following user(s) said Thank You: Ray

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 3 years 8 months ago #1191

 Ray OFFLINE Moderator Posts: 702 Thank you received: 152 Karma: 44 I was working on doing mine a whole different way. was way over thinking it....lolCoding there are hundreds of ways to do the same thing... If you want to add your version feel free to do it, we always love to see other points of view. The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 10 months ago #2025

 raymissa OFFLINE New Member Posts: 2 Karma: 0 Hi! I had this idea of trying to make a "more user-friendly" interface via smartphone/tablet and put some additional features, let's say for example : combine effect A with effect B, or combine effect A, B, C, D.....and finally, combining ALL effects in 1 preset. This is just one of my "fantasy" ideas if it's possible to be made, coming with a minor knowledge of programming and electric/electronics in DSP. The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 10 months ago #2026

 Ray OFFLINE Moderator Posts: 702 Thank you received: 152 Karma: 44 That's a great idea, so far we just managed to create the 4 independent effects and just use a simple program to select which one do you one to play. Some effects can be easy to combine (like delay+distortion) but some others could be more tricky. Using a more user-friendly interface (like a tablet or a phone) is also interesting, but sometimes as a player you just want something easy and simple that works.... If you do any progress keep posting it! The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 10 months ago #2030

 raymissa OFFLINE New Member Posts: 2 Karma: 0 Ahh okay. If I may ask, like, "tricky" how? Is it because of the hardware components or something? Or some other reasons? True though. Actually why I did this kind of experiment is because it's for my final year project, and since I'm an "Information Technology student", I was told to add some "IT" sides of it , in this case : Adding some "mobile-platform" stuff (like Android, IOS, Linux, etc...for my case again; Android), and adding some basic features like putting additional features like the "combining effects" stuff, "for [this song], use [this effect]" kind of feature, and maybe other useful features that'll pop in my mind later, hahaha. The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 3 months ago #2117

 Boris OFFLINE New Member My English is not very good. Posts: 6 Karma: 0 I am not a musician, I was asked to send a simple pedal for a bass guitar. I program the controller pretty well and applied several effects in one code. Since the program bypasses unnecessary sections of code, this does not affect speed. (at least until I got a slowdown) I implemented: Fuzz, Overdrive, Horus, Compressor. I wanted to know the opinion of the musicians about the effects that can be implemented for bass. The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 2 months ago #2126

 Stefadv OFFLINE New Member Posts: 4 Thank you received: 2 Karma: 2 HI Boris i'm a beginner bass player, would you be kind to show me your code for your mutlple effect ? i m interested to try it. i ve done my own pedal arduino (check the new topic in forum "new format + new features" ) based on the original one. some new cool sounds would be fun to try ! thks ! The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 2 months ago #2127

 Stefadv OFFLINE New Member Posts: 4 Thank you received: 2 Karma: 2 HI what does the "CLEAN" effect actually do, i don't see (hear) any benefit when i m using it.... The administrator has disabled public write access.

## Multi-effects: Clean+Boost+Distortion+Fuzz+Cr​usher 1 year 2 months ago #2129

 Boris OFFLINE New Member My English is not very good. Posts: 6 Karma: 0 Hi Stefadv. My code is designed to work with my schema, which is different from the schema posted on this site. I added a screen and an encoder to select modes. I'm sorry but the comments in my code are in Russian. This is not a final version and in the future I will probably translate the comments into English. Pedal-3.7.ino Last Edit: 1 year 2 months ago by Boris. The administrator has disabled public write access.
Time to create page: 0.419 seconds
Joomla SEF URLs by Artio