├── .gitignore ├── README.md ├── adjust_trimmer └── adjust_trimmer.ino ├── clean └── clean.ino ├── distortion └── distortion.ino ├── distortion_assymetric └── distortion_assymetric.ino ├── test_all └── test_all.ino ├── clean_sampled └── clean_sampled.ino ├── echo └── echo.ino ├── delay_long └── delay_long.ino ├── sinewave └── sinewave.ino ├── delay └── delay.ino ├── octaver └── octaver.ino ├── sinewave_j0uni └── sinewave_j0uni.ino ├── chorus_vibrato └── chorus_vibrato.ino ├── tremolo └── tremolo.ino ├── reverb └── reverb.ino ├── metronome └── metronome.ino └── LICENSE /.gitignore: -------------------------------------------------------------------------------- 1 | # Compiled Object files 2 | *.slo 3 | *.lo 4 | *.o 5 | 6 | # Compiled Dynamic libraries 7 | *.so 8 | *.dylib 9 | 10 | # Compiled Static libraries 11 | *.lai 12 | *.la 13 | *.a 14 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | pedalSHIELD 2 | =========== 3 | 4 | pedalSHIELD is an Arduino Open Source guitar pedal made for guitarists, hackers and programmers. Users can program their own effects in C/C++ or download ready effects from the online library. 5 | 6 | It is designed to be a platform to learn about digital signal processing, effects, synthesizers and experiment without deep knowledge in electronics or programming 7 | 8 | All info in www.electrosmash.com/pedalshield 9 | 10 | -------------------------------------------------------------------------------- /adjust_trimmer/adjust_trimmer.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | 6 | /*The program helps to adjust the trimmer 1 (RV1). 7 | when the input level is too high, the led turns on.*/ 8 | 9 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 10 | int POT0, POT1, POT2, in_DAC0, in_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 11 | int LED = 3; 12 | int FOOTSWITCH = 7; 13 | int TOGGLE = 2; 14 | 15 | void setup() 16 | { 17 | //ADC Configuration 18 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 19 | ADC->ADC_CR=2; // Starts ADC conversion. 20 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 21 | 22 | pinMode(LED, OUTPUT); 23 | } 24 | 25 | void loop() 26 | { 27 | //Read the ADCs 28 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 29 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 30 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 31 | 32 | if (in_ADC0>=4090) 33 | { 34 | digitalWrite(LED, HIGH); 35 | delay(200); 36 | } 37 | 38 | else 39 | digitalWrite(LED, LOW); 40 | } 41 | 42 | -------------------------------------------------------------------------------- /clean/clean.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 6 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 7 | int LED = 3; 8 | int FOOTSWITCH = 7; 9 | int TOGGLE = 2; 10 | 11 | void setup() 12 | { 13 | //ADC Configuration 14 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 15 | ADC->ADC_CR=2; // Starts ADC conversion. 16 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0 and 1. 17 | 18 | //DAC Configuration 19 | analogWrite(DAC0,0); // Enables DAC0 20 | analogWrite(DAC1,0); // Enables DAC0 21 | } 22 | 23 | void loop() 24 | { 25 | //Read the ADCs 26 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 27 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 28 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 29 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 30 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 31 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 32 | 33 | //Add volume feature with POT2 34 | out_DAC0=map(in_ADC0,0,4095,1,POT2); 35 | out_DAC1=map(in_ADC1,0,4095,1,POT2); 36 | 37 | //Write the DACs 38 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 39 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 40 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 41 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 42 | } 43 | -------------------------------------------------------------------------------- /distortion/distortion.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 6 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 7 | const int LED = 3; 8 | const int FOOTSWITCH = 7; 9 | const int TOGGLE = 2; 10 | int upper_threshold, lower_threshold; 11 | 12 | void setup() 13 | { 14 | //ADC Configuration 15 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 16 | ADC->ADC_CR=2; // Starts ADC conversion. 17 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 18 | 19 | //DAC Configuration 20 | analogWrite(DAC0,0); // Enables DAC0 21 | analogWrite(DAC1,0); // Enables DAC1 22 | } 23 | 24 | void loop() 25 | { 26 | //Read the ADCs 27 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 28 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 29 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 30 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 31 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 32 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 33 | 34 | upper_threshold=map(POT0,0,4095,4095,2047); 35 | lower_threshold=map(POT0,0,4095,0000,2047); 36 | 37 | if(in_ADC0>=upper_threshold) in_ADC0=upper_threshold; 38 | else if(in_ADC0=upper_threshold) in_ADC1=upper_threshold; 41 | else if(in_ADC1ADC_MR |= 0x80; // DAC in free running mode. 16 | ADC->ADC_CR=2; // Starts ADC conversion. 17 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 18 | 19 | //DAC Configuration 20 | analogWrite(DAC0,0); // Enables DAC0 21 | analogWrite(DAC1,0); // Enables DAC1 22 | } 23 | 24 | void loop() 25 | { 26 | //Read the ADCs 27 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 28 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 29 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 30 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 31 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 32 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 33 | 34 | upper_threshold=map(POT0,0,4095,4095,2047); 35 | lower_threshold=map(POT1,0,4095,0000,2047); 36 | 37 | if(in_ADC0>=upper_threshold) in_ADC0=upper_threshold; 38 | else if(in_ADC0=upper_threshold) in_ADC1=upper_threshold; 41 | else if(in_ADC1ADC_MR |= 0x80; // DAC in free running mode. 16 | ADC->ADC_CR=2; // Starts ADC conversion. 17 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0 and 1. 18 | 19 | //DAC Configuration 20 | analogWrite(DAC0,0); // Enables DAC0 21 | analogWrite(DAC1,0); // Enables DAC0 22 | 23 | //Pin Configuration 24 | pinMode(LED, OUTPUT); 25 | pinMode(FOOTSWITCH, INPUT); 26 | pinMode(TOGGLE, INPUT); 27 | } 28 | 29 | void loop() 30 | { 31 | //Read the ADCs 32 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 33 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 34 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 35 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 36 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 37 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 38 | 39 | //Add volume feature for POT0 40 | out_DAC0=map(in_ADC0,0,4095,1,POT0); 41 | out_DAC1=map(in_ADC1,0,4095,1,POT0); 42 | 43 | //Add volume feature for POT1 44 | out_DAC0=map(out_DAC0,0,4095,1,POT1); 45 | out_DAC1=map(out_DAC1,0,4095,1,POT1); 46 | 47 | //Add volume feature for POT2 48 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 49 | out_DAC1=map(out_DAC1,0,4095,1,POT2); 50 | 51 | //Write the DACs 52 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 53 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 54 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 55 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 56 | 57 | //Check the FOOTSWITCH and light the LED 58 | if (digitalRead(FOOTSWITCH)) digitalWrite(LED, HIGH); 59 | else digitalWrite(LED, LOW); 60 | 61 | //Check the TOGGLE SWITCH and light the LED 62 | if (digitalRead(TOGGLE)) digitalWrite(LED, HIGH); 63 | else digitalWrite(LED, LOW); 64 | } 65 | -------------------------------------------------------------------------------- /clean_sampled/clean_sampled.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | /* clean_sampled.ino adds a sampled funtcion to the previous clean_volume program. It sets the output sample rate at 44.1 KHz (CD quality). 6 | - Main Loop: Both ADCS and potentiometes are read. 7 | - TC4_Handler: It is the sampling funtion, executed every 22.6us(44.1 KHz) adjusts 8 | the volume and writes de DACs.*/ 9 | 10 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 11 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 12 | int LED = 3; 13 | int FOOTSWITCH = 7; 14 | int TOGGLE = 2; 15 | 16 | void setup() 17 | { 18 | /* turn on the timer clock in the power management controller */ 19 | pmc_set_writeprotect(false); 20 | pmc_enable_periph_clk(ID_TC4); 21 | 22 | /* we want wavesel 01 with RC */ 23 | TC_Configure(/* clock */TC1,/* channel */1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC 24 | | TC_CMR_TCCLKS_TIMER_CLOCK2); 25 | TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate 26 | //TC_SetRC(TC1, 1, 109); // sets <> 96 Khz interrupt rate 27 | 28 | TC_Start(TC1, 1); 29 | 30 | // enable timer interrupts on the timer 31 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 32 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 33 | 34 | /* Enable the interrupt in the nested vector interrupt controller */ 35 | /* TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 36 | (=(1*3)+1) for timer1 channel1 */ 37 | NVIC_EnableIRQ(TC4_IRQn); 38 | 39 | //ADC Configuration 40 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 41 | ADC->ADC_CR=2; // Starts ADC conversion. 42 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0 and 1. 43 | 44 | //DAC Configuration 45 | analogWrite(DAC0,0); // Enables DAC0 46 | analogWrite(DAC1,0); // Enables DAC0 47 | } 48 | 49 | void loop() 50 | { 51 | //Read the ADCs 52 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0); // wait for ADC 0, 1, 8, 9, 10 conversion complete. 53 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 54 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 55 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 56 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 57 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 58 | } 59 | 60 | void TC4_Handler() 61 | { 62 | // We need to get the status to clear it and allow the interrupt to fire again 63 | TC_GetStatus(TC1, 1); 64 | 65 | //Adjust the volume with POT2 66 | out_DAC0=map(in_ADC0,0,4095,1,POT2); 67 | out_DAC1=map(in_ADC1,0,4095,1,POT2); 68 | 69 | //Write the DACs 70 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 71 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 72 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 73 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 74 | } 75 | -------------------------------------------------------------------------------- /echo/echo.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 6 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 7 | int LED = 3; 8 | int FOOTSWITCH = 7; 9 | int TOGGLE = 2; 10 | 11 | #define MAX_DELAY 40000 12 | uint16_t sDelayBuffer0[MAX_DELAY]; 13 | unsigned int Delay_Depth, DelayCounter = 0; 14 | 15 | void setup() 16 | { 17 | //turn on the timer clock in the power management controller 18 | pmc_set_writeprotect(false); 19 | pmc_enable_periph_clk(ID_TC4); 20 | 21 | //we want wavesel 01 with RC 22 | TC_Configure(TC1,1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2); 23 | TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate 24 | TC_Start(TC1, 1); 25 | 26 | // enable timer interrupts on the timer 27 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 28 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 29 | 30 | //Enable the interrupt in the nested vector interrupt controller 31 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 32 | //(=(1*3)+1) for timer1 channel1 33 | NVIC_EnableIRQ(TC4_IRQn); 34 | 35 | //ADC Configuration 36 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 37 | ADC->ADC_CR=2; // Starts ADC conversion. 38 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 39 | 40 | //DAC Configuration 41 | analogWrite(DAC0,0); // Enables DAC0 42 | analogWrite(DAC1,0); // Enables DAC0 43 | } 44 | 45 | void loop() 46 | { 47 | //Read the ADCs 48 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 49 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 50 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 51 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 52 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 53 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 54 | } 55 | 56 | void TC4_Handler() //Interrupt at 44.1KHz rate (every 22.6us) 57 | { 58 | //Clear status allowing the interrupt to be fired again. 59 | TC_GetStatus(TC1, 1); 60 | 61 | //Store current readings 62 | sDelayBuffer0[DelayCounter] = (in_ADC0 + (sDelayBuffer0[DelayCounter]))>>1; 63 | 64 | //Adjust Delay Depth based in pot0 position. 65 | Delay_Depth =map(POT0>>2,0,2047,1,MAX_DELAY); 66 | 67 | //Increse/reset delay counter. 68 | DelayCounter++; 69 | if(DelayCounter >= Delay_Depth) DelayCounter = 0; 70 | out_DAC0 = ((sDelayBuffer0[DelayCounter])); 71 | 72 | //Add volume feature based in POT2 position. 73 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 74 | 75 | //Write the DACs 76 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 77 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 78 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 79 | dacc_write_conversion_data(DACC_INTERFACE, 0); //write on DAC 80 | } 81 | -------------------------------------------------------------------------------- /delay_long/delay_long.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | /* delay_long.ino buffers the input signal up to 3s (MAX_DELAY/16000). 6 | HARDWARE config: the Mix Potentiometer should be ON (down) in order to enable the output 7 | mixer which blends original and delayed signals. 8 | - Main Loop: Both ADCs and potentiometers are read. 9 | - TC4_Handler (sampling function): buffer the input signal to be delayed adjusting the 10 | volume and writes de DACs. 11 | The DSP works like: input --> [0][1][2][3][...][][][][][][][MAX_DELAY] -->output */ 12 | 13 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 14 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 15 | const int LED = 3; 16 | const int FOOTSWITCH = 7; 17 | const int TOGGLE = 2; 18 | 19 | #define MAX_DELAY 47000 20 | uint16_t sDelayBuffer0[MAX_DELAY]; 21 | unsigned int DelayCounter = 0; 22 | unsigned int Delay_Depth; 23 | 24 | void setup() 25 | { 26 | //turn on the timer clock in the power management controller 27 | pmc_set_writeprotect(false); 28 | pmc_enable_periph_clk(ID_TC4); 29 | 30 | //we want wavesel 01 with RC 31 | TC_Configure(TC1,1, TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK2); 32 | TC_SetRC(TC1, 1, 656); // sets 16 Khz interrupt rate (10.5MHz/656=16KHz) 33 | TC_Start(TC1, 1); 34 | 35 | // enable timer interrupts on the timer 36 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 37 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 38 | 39 | //Enable the interrupt in the nested vector interrupt controller 40 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 41 | //(=(1*3)+1) for timer1 channel1 42 | NVIC_EnableIRQ(TC4_IRQn); 43 | 44 | //ADC Configuration 45 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 46 | ADC->ADC_CR=2; // Starts ADC conversion. 47 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 48 | 49 | //DAC Configuration 50 | analogWrite(DAC0,0); // Enables DAC0 51 | analogWrite(DAC1,0); // Enables DAC0 52 | } 53 | 54 | void loop() 55 | { 56 | //Read the ADCs 57 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 58 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 59 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 60 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 61 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 62 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 63 | } 64 | 65 | //Interrupt at 44.1KHz rate (every 22.6us) 66 | void TC4_Handler() 67 | { 68 | //Clear status allowing the interrupt to be fired again. 69 | TC_GetStatus(TC1, 1); 70 | 71 | //Store current readings 72 | sDelayBuffer0[DelayCounter] = in_ADC0; 73 | 74 | //Adjust Delay Depth based in pot0 position. 75 | Delay_Depth=map(POT0>>2,0,2097,1,MAX_DELAY); 76 | 77 | //Increase/reset delay counter. 78 | DelayCounter++; 79 | if(DelayCounter >= Delay_Depth) DelayCounter = 0; 80 | 81 | out_DAC0 = ((sDelayBuffer0[DelayCounter])); 82 | 83 | //Add volume feature based in pot2 position. 84 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 85 | 86 | //Write the DACs 87 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 88 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 89 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 90 | dacc_write_conversion_data(DACC_INTERFACE, 0); //write on DAC 91 | } 92 | -------------------------------------------------------------------------------- /sinewave/sinewave.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | // sinewave.ino program creates a sinusoidal waveform adjustable in amplitude and frequency. 6 | // potentiometer 0 controls the frequency. 7 | // potentiometer 2 controls the amplitude. 8 | 9 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 10 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 11 | const int LED = 3; 12 | const int FOOTSWITCH = 7; 13 | const int TOGGLE = 2; 14 | int accumulator, sample; 15 | 16 | // Create a table to hold pre computed sinewave, the table has a resolution of 600 samples 17 | #define no_samples 44100 // 44100 samples at 44.1KHz takes 1 second to be read. 18 | uint16_t nSineTable[no_samples]; // storing 12 bit samples in 16 bit variable. 19 | 20 | void createSineTable() 21 | { 22 | for(uint32_t nIndex=0; nIndex 44.1 Khz interrupt rate 40 | TC_Start(TC1, 1); 41 | 42 | //enable timer interrupts on the timer 43 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 44 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 45 | 46 | //Enable the interrupt in the nested vector interrupt controller 47 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 48 | //(=(1*3)+1) for timer1 channel1 49 | NVIC_EnableIRQ(TC4_IRQn); 50 | 51 | //ADC Configuration 52 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 53 | ADC->ADC_CR=2; // Starts ADC conversion. 54 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 55 | 56 | //DAC Configuration 57 | analogWrite(DAC0,0); // Enables DAC0 58 | analogWrite(DAC1,0); // Enables DAC1 59 | } 60 | 61 | void loop() 62 | { 63 | //Read the ADCs. 64 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0); // wait for ADC 0, 1, 8, 9, 10 conversion complete. 65 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 66 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 67 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 68 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 69 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 70 | } 71 | 72 | //Interrupt at 44.1KHz rate (every 22.6us) 73 | void TC4_Handler() 74 | { 75 | //Clear status allowing the interrupt to be fired again. 76 | TC_GetStatus(TC1, 1); 77 | 78 | //update the accumulator, from 0 to 511 79 | accumulator=POT0>>3; 80 | 81 | //calculate the sample 82 | if(sample>=(no_samples-accumulator)) sample=0; 83 | sample=sample+accumulator; 84 | 85 | //Generate the DAC output 86 | out_DAC0 = nSineTable[sample]; 87 | out_DAC1 = 4095 - nSineTable[sample]; 88 | 89 | //Add volume feature 90 | out_DAC0=map(out_DAC0,0,4095,0,POT2); 91 | out_DAC1=map(out_DAC1,0,4095,0,POT2); 92 | 93 | //Write the DACs. 94 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 95 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 96 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 97 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 98 | } 99 | -------------------------------------------------------------------------------- /delay/delay.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | /* delay.ino buffers the input signal up to 450 ms (MAX_DELAY/44100). 6 | HARDWARE config: the Mix Potentiometer should be ON (down) in order to enable the output 7 | mixer which blends original and delayed signals. 8 | - Main Loop: Both ADCs and potentiometes are read. 9 | - TC4_Handler (sampling funtion): buffer the input signal to be delayed adjusting the 10 | volume and writes de DACs. 11 | The DSP is like: input --> [0][1][2][3][...][][][][][][][MAX_DELAY] -->output */ 12 | 13 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 14 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 15 | int LED = 3; 16 | int FOOTSWITCH = 7; 17 | int TOGGLE = 2; 18 | 19 | #define MAX_DELAY 20000 20 | uint16_t sDelayBuffer0[MAX_DELAY]; 21 | uint16_t sDelayBuffer1[MAX_DELAY]; 22 | unsigned int DelayCounter = 0; 23 | unsigned int Delay_Depth = MAX_DELAY; 24 | 25 | void setup() 26 | { 27 | //turn on the timer clock in the power management controller 28 | pmc_set_writeprotect(false); 29 | pmc_enable_periph_clk(ID_TC4); 30 | 31 | //we want wavesel 01 with RC 32 | TC_Configure(TC1,1,TC_CMR_WAVE|TC_CMR_WAVSEL_UP_RC|TC_CMR_TCCLKS_TIMER_CLOCK2); 33 | TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate 34 | TC_Start(TC1, 1); 35 | 36 | // enable timer interrupts on the timer 37 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 38 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 39 | 40 | //Enable the interrupt in the nested vector interrupt controller 41 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 42 | //(=(1*3)+1) for timer1 channel1 43 | NVIC_EnableIRQ(TC4_IRQn); 44 | 45 | //ADC Configuration 46 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 47 | ADC->ADC_CR=2; // Starts ADC conversion. 48 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 49 | 50 | //DAC Configuration 51 | analogWrite(DAC0,0); // Enables DAC0 52 | analogWrite(DAC1,0); // Enables DAC0 53 | } 54 | 55 | void loop() 56 | { 57 | //Read the ADCs 58 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 59 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 60 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 61 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 62 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 63 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 64 | } 65 | 66 | //Interrupt at 44.1KHz rate (every 22.6us) 67 | void TC4_Handler() 68 | { 69 | //Store current readings 70 | sDelayBuffer0[DelayCounter] = in_ADC0; 71 | sDelayBuffer1[DelayCounter] = in_ADC1; 72 | 73 | //Adjust Delay Depth based in pot2 position. 74 | Delay_Depth=map(POT0>>2,0,2097,1,MAX_DELAY); 75 | 76 | //Increse/reset delay counter. 77 | DelayCounter++; 78 | if(DelayCounter >= Delay_Depth) DelayCounter = 0; 79 | 80 | out_DAC0 = ((sDelayBuffer0[DelayCounter])); 81 | out_DAC1 = ((sDelayBuffer1[DelayCounter])); 82 | 83 | //Add volume feature 84 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 85 | out_DAC1=map(out_DAC1,0,4095,1,POT2); 86 | 87 | //Write the DACs 88 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 89 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 90 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 91 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 92 | 93 | //Clear status allowing the interrupt to be fired again. 94 | TC_GetStatus(TC1, 1); 95 | } 96 | -------------------------------------------------------------------------------- /octaver/octaver.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | /*octaver.ino creates an octave-up or octave-down signal from the original one.*/ 6 | 7 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 8 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 9 | int LED = 3; 10 | int FOOTSWITCH = 7; 11 | int TOGGLE = 2; 12 | 13 | #define MAX_DELAY 10000 14 | uint16_t sDelayBuffer0[MAX_DELAY-1]; 15 | uint16_t sDelayBuffer1[MAX_DELAY-1]; 16 | unsigned int write_pt=0; 17 | unsigned int read_pt_A=0, read_pt_B= MAX_DELAY/2; 18 | unsigned int Delay_Depth, increment, divider=0, buffer0, buffer1; 19 | 20 | void setup() 21 | { 22 | //turn on the timer clock in the power management controller 23 | pmc_set_writeprotect(false); 24 | pmc_enable_periph_clk(ID_TC4); 25 | 26 | //we want wavesel 01 with RC 27 | TC_Configure(TC1, 1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2); 28 | TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate 109 29 | TC_Start(TC1, 1); 30 | 31 | // enable timer interrupts on the timer 32 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 33 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 34 | 35 | //Enable the interrupt in the nested vector interrupt controller 36 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 37 | //(=(1*3)+1) for timer1 channel1 38 | NVIC_EnableIRQ(TC4_IRQn); 39 | 40 | //ADC Configuration 41 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 42 | ADC->ADC_CR=2; // Starts ADC conversion. 43 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 44 | 45 | //DAC Configuration 46 | analogWrite(DAC0,0); // Enables DAC0 47 | analogWrite(DAC1,0); // Enables DAC0 48 | } 49 | 50 | void loop() 51 | { 52 | //Read the ADCs 53 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0,1,8,9,10 conversion complete. 54 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 55 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 56 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 57 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 58 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 59 | } 60 | 61 | void TC4_Handler() //Interrupt at 44.1KHz rate (every 22.6us) 62 | { 63 | TC_GetStatus(TC1, 1); //Clear status interrupt to be fired again. 64 | 65 | //Store current readings 66 | sDelayBuffer0[write_pt] = in_ADC0; 67 | sDelayBuffer1[write_pt] = in_ADC1; 68 | 69 | //Adjust Delay Depth based in pot2 position. 70 | Delay_Depth = MAX_DELAY-1; 71 | 72 | //Increse/reset delay counter. 73 | write_pt++; 74 | if(write_pt >= Delay_Depth) write_pt = 0; 75 | 76 | out_DAC0 = ((sDelayBuffer0[read_pt_A])); 77 | out_DAC1 = ((sDelayBuffer1[read_pt_B])); 78 | 79 | if (POT0>2700) 80 | { 81 | read_pt_A = read_pt_A + 2; 82 | read_pt_B = read_pt_B + 2; 83 | } 84 | else if (POT0>1350) 85 | { 86 | read_pt_A = read_pt_A + 1; 87 | read_pt_B = read_pt_B + 1; 88 | } 89 | else 90 | { 91 | divider++; 92 | if (divider>=2) 93 | { 94 | read_pt_A = read_pt_A + 1; 95 | read_pt_B = read_pt_B + 1; 96 | divider=0; 97 | } 98 | } 99 | 100 | if(read_pt_A >= Delay_Depth) read_pt_A = 0; 101 | if(read_pt_B >= Delay_Depth) read_pt_B = 0; 102 | 103 | //Add volume control with POT2 104 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 105 | out_DAC1=map(out_DAC1,0,4095,1,POT2); 106 | 107 | //Write the DACs 108 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 109 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 110 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 111 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 112 | } 113 | -------------------------------------------------------------------------------- /sinewave_j0uni/sinewave_j0uni.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | // sinewave.ino program creates a sinusoidal waveform adjustable in amplitude and frequency. 6 | // potentiometer 0 controls the frequency. 7 | // potentiometer 2 controls the amplitude. 8 | 9 | // VERSION HISTORY: 10 | // 5.1.2014 - j0uni : This version uses bitwise AND to get the "rolling" pointer to sinewave table. 11 | 12 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 13 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 14 | const int LED = 3; 15 | const int FOOTSWITCH = 7; 16 | const int TOGGLE = 2; 17 | int accumulator, sample; 18 | 19 | // Create a table to hold pre computed sinewave, the table has a resolution of 600 samples 20 | #define no_samples 4096 // must be two's complement! 21 | uint16_t nSineTable[no_samples]; // storing 12 bit samples in 16 bit variable. 22 | 23 | void createSineTable() 24 | { 25 | for(uint32_t nIndex=0; nIndex 44.1 Khz interrupt rate 43 | TC_Start(TC1, 1); 44 | 45 | //enable timer interrupts on the timer 46 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 47 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 48 | 49 | //Enable the interrupt in the nested vector interrupt controller 50 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 51 | //(=(1*3)+1) for timer1 channel1 52 | NVIC_EnableIRQ(TC4_IRQn); 53 | 54 | //ADC Configuration 55 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 56 | ADC->ADC_CR=2; // Starts ADC conversion. 57 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 58 | 59 | //DAC Configuration 60 | analogWrite(DAC0,0); // Enables DAC0 61 | analogWrite(DAC1,0); // Enables DAC1 62 | } 63 | 64 | float pot = 0; 65 | 66 | void loop() 67 | { 68 | //Read the ADCs. 69 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0); // wait for ADC 0, 1, 8, 9, 10 conversion complete. 70 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 71 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 72 | 73 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 74 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 75 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 76 | 77 | 78 | } 79 | 80 | //Interrupt at 44.1KHz rate (every 22.6us) 81 | void TC4_Handler() 82 | { 83 | //Clear status allowing the interrupt to be fired again. 84 | TC_GetStatus(TC1, 1); 85 | 86 | //update the accumulator, from 0 to 511 87 | accumulator=POT0>>3; 88 | sample=sample+accumulator; 89 | 90 | // Generate the DAC output 91 | // AND with TWO'S COMPLEMENT value to get the bits we really want to use 92 | out_DAC0 = nSineTable[sample & (no_samples-1)]; 93 | out_DAC1 = 4095 - nSineTable[sample & (no_samples-1)]; 94 | 95 | //Add volume feature 96 | out_DAC0=map(out_DAC0,0,4095,0,POT2); 97 | out_DAC1=map(out_DAC1,0,4095,0,POT2); 98 | 99 | //Write the DACs. 100 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 101 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 102 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 103 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 104 | } 105 | -------------------------------------------------------------------------------- /chorus_vibrato/chorus_vibrato.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | /*chorus_vibrato.ino creates a chorus guitar effect by delaying the signal and 6 | modulating this delay with a triangular waveform.*/ 7 | 8 | int in_ADC0, in_ADC1, out_DAC0, out_DAC1; //variables for 2 ADCs values (ADC0, ADC1) 9 | int POT0, POT1, POT2; //variables for 3 pots (ADC8, ADC9, ADC10) 10 | int LED = 3; 11 | int FOOTSWITCH = 7; 12 | int TOGGLE = 2; 13 | #define MAX_DELAY 500 14 | #define MIN_DELAY 200 15 | 16 | uint16_t sDelayBuffer0[MAX_DELAY+500]; 17 | uint16_t sDelayBuffer1[MAX_DELAY+500]; 18 | unsigned int DelayCounter = 0; 19 | unsigned int Delay_Depth = 300; 20 | unsigned int count_up=1; 21 | int p; 22 | 23 | void setup() 24 | { 25 | //turn on the timer clock in the power management controller 26 | pmc_set_writeprotect(false); 27 | pmc_enable_periph_clk(ID_TC4); 28 | 29 | //we want wavesel 01 with RC 30 | TC_Configure(TC1,1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2); 31 | TC_SetRC(TC1, 1, 109); // sets <> 44.1 Khz interrupt rate 32 | TC_Start(TC1, 1); 33 | 34 | // enable timer interrupts on the timer 35 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 36 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 37 | 38 | //Enable the interrupt in the nested vector interrupt controller 39 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 40 | //(=(1*3)+1) for timer1 channel1 41 | NVIC_EnableIRQ(TC4_IRQn); 42 | 43 | //ADC Configuration 44 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 45 | ADC->ADC_CR=2; // Starts ADC conversion. 46 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 47 | 48 | //DAC Configuration 49 | analogWrite(DAC0,0); // Enables DAC0 50 | analogWrite(DAC1,0); // Enables DAC0 51 | 52 | //pedalSHIELD pin configuration 53 | pinMode(LED, OUTPUT); 54 | pinMode(FOOTSWITCH, INPUT); 55 | pinMode(TOGGLE, INPUT); 56 | } 57 | 58 | void loop() 59 | { 60 | //Read the ADCs 61 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 62 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 63 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 64 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 65 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 66 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 67 | } 68 | 69 | //Interrupt at 44.1KHz rate (every 22.6us) 70 | void TC4_Handler() 71 | { 72 | //Clear status allowing the interrupt to be fired again. 73 | TC_GetStatus(TC1, 1); 74 | 75 | //Store current readings 76 | sDelayBuffer0[DelayCounter] = in_ADC0; 77 | 78 | //Adjust Delay Depth based in pot0 position. 79 | POT0=map(POT0>>2,0,1024,1,25); //25 empirically chosen 80 | 81 | DelayCounter++; 82 | if(DelayCounter >= Delay_Depth) 83 | { 84 | DelayCounter = 0; 85 | if(count_up) 86 | { 87 | digitalWrite(LED, HIGH); 88 | for(p=0;p=MAX_DELAY)count_up=0; 92 | } 93 | else 94 | { 95 | digitalWrite(LED, LOW); 96 | Delay_Depth=Delay_Depth-POT0; 97 | if (Delay_Depth<=MIN_DELAY)count_up=1; 98 | } 99 | } 100 | 101 | out_DAC0 = sDelayBuffer0[DelayCounter]; 102 | 103 | //Add volume control based in POT2 104 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 105 | 106 | //Write the DACs 107 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 108 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 109 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 110 | dacc_write_conversion_data(DACC_INTERFACE, 0); //write on DAC 111 | } 112 | -------------------------------------------------------------------------------- /tremolo/tremolo.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on RCArduino.Blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | // tremolo effect produces a variation in the volume of the signal, by mixing the guitar with a sinusoidal waveform. 6 | // potentiometer 0: controls the speed. 7 | // potentiometer 1: controls the deph. 8 | // potentiometer 2: controls the volume level. 9 | 10 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 11 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 12 | const int LED = 3; 13 | const int FOOTSWITCH = 7; 14 | const int TOGGLE = 2; 15 | int sample, accumulator, count, LFO; 16 | 17 | // Create a table to hold pre computed sinewave, the table has a resolution of 600 samples 18 | #define no_samples 44100 19 | #define MAX_COUNT 160 20 | uint16_t nSineTable[no_samples];//storing 12 bit samples in 16 bit variable. 21 | 22 | // create the individual samples for our sinewave table 23 | void createSineTable() 24 | { 25 | for(uint32_t nIndex=0; nIndex 44.1 Khz interrupt rate 43 | TC_Start(TC1, 1); 44 | 45 | // enable timer interrupts on the timer 46 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 47 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 48 | 49 | /* Enable the interrupt in the nested vector interrupt controller */ 50 | /* TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 51 | (=(1*3)+1) for timer1 channel1 */ 52 | NVIC_EnableIRQ(TC4_IRQn); 53 | 54 | //ADC Configuration 55 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 56 | ADC->ADC_CR=2; // Starts ADC conversion. 57 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 58 | 59 | //DAC Configuration 60 | analogWrite(DAC0,0); // Enables DAC0 61 | analogWrite(DAC1,0); // Enables DAC0 62 | } 63 | 64 | void loop() 65 | { 66 | //Read the ADCs 67 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 68 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 69 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 70 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 71 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 72 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 73 | } 74 | 75 | void TC4_Handler() 76 | { 77 | // Get the status to clear the interrupt to be fired again. 78 | TC_GetStatus(TC1, 1); 79 | 80 | //Increase the sinewave index and/or reset the value. 81 | POT0 = POT0>>1; //divide value by 2 (its too big) 82 | count++; 83 | if (count>=160) //160 chosen empirically 84 | { 85 | count=0; 86 | sample=sample+POT0; 87 | if(sample>=no_samples) sample=0; 88 | } 89 | 90 | //Create the Low Frequency Oscillator signal with depth control based in POT1. 91 | LFO=map(nSineTable[sample],0,4095,(4095-POT1),4095); 92 | 93 | //Modulate the output signals based on the sinetable. 94 | out_DAC0 =map(in_ADC0,1,4095,1, LFO); 95 | out_DAC1 =map(in_ADC1,1,4095,1, LFO); 96 | 97 | //Add volume feature with POT2 98 | out_DAC0 =map(out_DAC0,1,4095,1, POT2); 99 | out_DAC1 =map(out_DAC1,1,4095,1, POT2); 100 | 101 | //Write the DACs 102 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 103 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 104 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 105 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 106 | } 107 | -------------------------------------------------------------------------------- /reverb/reverb.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | /* reverb.ino creates two copies of the guitar signal to be delayed independently producing 6 | a reverb-like sound, the toggle switch selects between delaying or echoing the signals*/ 7 | 8 | int in_ADC0, in_ADC1; //variables for 2 ADCs values (ADC0, ADC1) 9 | int POT0, POT1, POT2, out_DAC0, out_DAC1; //variables for 3 pots (ADC8, ADC9, ADC10) 10 | int LED = 3; 11 | int FOOTSWITCH = 7; 12 | int TOGGLE = 2; 13 | 14 | #define MAX_DELAY_A 20000 15 | #define MAX_DELAY_B 20000 16 | uint16_t DelayBuffer_A[MAX_DELAY_A]; 17 | uint16_t DelayBuffer_B[MAX_DELAY_B]; 18 | unsigned int DelayCounter_A = 0; 19 | unsigned int DelayCounter_B = 0; 20 | unsigned int Delay_Depth_A, Delay_Depth_B; 21 | 22 | void setup() 23 | { 24 | //turn on the timer clock in the power management controller 25 | pmc_set_writeprotect(false); 26 | pmc_enable_periph_clk(ID_TC4); 27 | 28 | //we want wavesel 01 with RC 29 | TC_Configure(TC1,1, TC_CMR_WAVE | TC_CMR_WAVSEL_UP_RC | TC_CMR_TCCLKS_TIMER_CLOCK2); 30 | TC_SetRC(TC1, 1, 238); // sets <> 44.1 Khz interrupt rate 31 | TC_Start(TC1, 1); 32 | 33 | // enable timer interrupts on the timer 34 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 35 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 36 | 37 | //Enable the interrupt in the nested vector interrupt controller 38 | //TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 39 | //(=(1*3)+1) for timer1 channel1 40 | NVIC_EnableIRQ(TC4_IRQn); 41 | 42 | //ADC Configuration 43 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 44 | ADC->ADC_CR=2; // Starts ADC conversion. 45 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 46 | 47 | //DAC Configuration 48 | analogWrite(DAC0,0); // Enables DAC0 49 | analogWrite(DAC1,0); // Enables DAC0 50 | 51 | //Pin Configuration 52 | pinMode(LED, OUTPUT); 53 | pinMode(FOOTSWITCH, INPUT); 54 | pinMode(TOGGLE, INPUT); 55 | } 56 | 57 | void loop() 58 | { 59 | //Read the ADCs 60 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 61 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 62 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 63 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 64 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 65 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 66 | } 67 | 68 | void TC4_Handler() //Interrupt at 44.1KHz rate (every 22.6us) 69 | { 70 | //Clear status allowing the interrupt to be fired again. 71 | TC_GetStatus(TC1, 1); 72 | 73 | //Check the TOGGLE SWITCH and select between super-reverb and reverb. 74 | if (digitalRead(TOGGLE)) 75 | { 76 | //Store current readings in ECHO mode 77 | DelayBuffer_A[DelayCounter_A]=(in_ADC0 + (DelayBuffer_A[DelayCounter_A]))>>1; 78 | DelayBuffer_B[DelayCounter_B]=(in_ADC1 + (DelayBuffer_B[DelayCounter_B]))>>1; 79 | digitalWrite(LED, HIGH); 80 | } 81 | 82 | else 83 | { 84 | //Store current readings in DELAY mode 85 | DelayBuffer_A[DelayCounter_A] = in_ADC0 ; 86 | DelayBuffer_B[DelayCounter_B] = in_ADC1 ; 87 | digitalWrite(LED, LOW); 88 | } 89 | 90 | //Adjust Delay Depth based in POT0 and POT1 position. 91 | Delay_Depth_A =map(POT0>>3,0,512,1,MAX_DELAY_A); 92 | Delay_Depth_B =map(POT1>>3,0,512,1,MAX_DELAY_B); 93 | 94 | //Increse/reset delay counter. 95 | DelayCounter_A++; 96 | DelayCounter_B++; 97 | if(DelayCounter_A >= Delay_Depth_A) DelayCounter_A = 0; 98 | if(DelayCounter_B >= Delay_Depth_B) DelayCounter_B = 0; 99 | 100 | //Calculate the output as the sum of DelayBuffer_A + DelayBuffer_B 101 | out_DAC0 = (DelayBuffer_A[DelayCounter_A]); 102 | out_DAC1 = (DelayBuffer_B[DelayCounter_B]); 103 | 104 | //Add volume feature based in pot2 position. 105 | out_DAC0=map(out_DAC0,0,4095,1,POT2); 106 | out_DAC1=map(out_DAC1,0,4095,1,POT2); 107 | 108 | //Write the DACs 109 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 110 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 111 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 112 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC1);//write on DAC 113 | } 114 | -------------------------------------------------------------------------------- /metronome/metronome.ino: -------------------------------------------------------------------------------- 1 | // Licensed under a Creative Commons Attribution 3.0 Unported License. 2 | // Based on rcarduino.blogspot.com previous work. 3 | // www.electrosmash.com/pedalshield 4 | 5 | int in_ADC0, in_ADC1, out_DAC0, out_DAC1; //variables for ADCs and DACs 6 | int POT0, POT1, POT2; //variables for pots (ADC8, ADC9, ADC10) 7 | const int LED = 3; 8 | const int FOOTSWITCH = 7; 9 | const int TOGGLE = 2; 10 | 11 | int accumulator,sample,time_on, time_off; 12 | 13 | // Create a table to hold pre computed sinewave, the table has a resolution of 600 samples 14 | #define no_samples 44100 15 | // default int is 32 bit, in most cases its best to use uint32_t but for large arrays its better to use smaller 16 | // data types if possible, here we are storing 12 bit samples in 16 bit ints 17 | uint16_t nSineTable[no_samples]; 18 | 19 | // create the individual samples for our sinewave table 20 | void createSineTable() 21 | { 22 | for(uint32_t nIndex=0; nIndex 44.1 Khz interrupt rate 40 | TC_Start(TC1, 1); 41 | 42 | // enable timer interrupts on the timer 43 | TC1->TC_CHANNEL[1].TC_IER=TC_IER_CPCS; 44 | TC1->TC_CHANNEL[1].TC_IDR=~TC_IER_CPCS; 45 | 46 | /* Enable the interrupt in the nested vector interrupt controller */ 47 | /* TC4_IRQn where 4 is the timer number * timer channels (3) + the channel number 48 | (=(1*3)+1) for timer1 channel1 */ 49 | NVIC_EnableIRQ(TC4_IRQn); 50 | 51 | //ADC Configuration 52 | ADC->ADC_MR |= 0x80; // DAC in free running mode. 53 | ADC->ADC_CR=2; // Starts ADC conversion. 54 | ADC->ADC_CHER=0x1CC0; // Enable ADC channels 0,1,8,9 and 10 55 | 56 | //DAC Configuration 57 | analogWrite(DAC0,0); // Enables DAC0 58 | analogWrite(DAC1,0); // Enables DAC0 59 | 60 | //Pin Configuration 61 | pinMode(LED, OUTPUT); 62 | pinMode(FOOTSWITCH, INPUT); 63 | pinMode(TOGGLE, INPUT); 64 | } 65 | 66 | void loop() 67 | { 68 | //BEEP PART: Enable Interruption which makes the sinewave. 69 | if (digitalRead(TOGGLE)) digitalWrite(LED, HIGH); 70 | NVIC_EnableIRQ(TC4_IRQn); 71 | delay(50); //the beep has a constant time of 50ms. 72 | 73 | //SILENT PART: Disabling Interruption which makes the sinewave. 74 | digitalWrite(LED, LOW); 75 | NVIC_DisableIRQ(TC4_IRQn); 76 | 77 | sample=0; 78 | //adjusing metronome from (1000/1000)x60=60bpm to (1000/150)x60=400bpm 79 | time_on =map(POT0,0,4095,1000,150); 80 | delay(time_on); 81 | } 82 | 83 | void TC4_Handler() 84 | { 85 | // We need to get the status to clear it and allow the interrupt to fire again 86 | TC_GetStatus(TC1, 1); 87 | 88 | //Read ADCs. 89 | while((ADC->ADC_ISR & 0x1CC0)!=0x1CC0);// wait for ADC 0, 1, 8, 9, 10 conversion complete. 90 | in_ADC0=ADC->ADC_CDR[7]; // read data from ADC0 91 | in_ADC1=ADC->ADC_CDR[6]; // read data from ADC1 92 | POT0=ADC->ADC_CDR[10]; // read data from ADC8 93 | POT1=ADC->ADC_CDR[11]; // read data from ADC9 94 | POT2=ADC->ADC_CDR[12]; // read data from ADC10 95 | 96 | //Adjust frequency from 1Hz to 2.5KHz 97 | accumulator =map(POT1,0,4095,1,2500); 98 | sample=sample+accumulator; 99 | if(sample>=no_samples)sample=0; 100 | 101 | //calculate the samples 102 | out_DAC0 = nSineTable[sample]; 103 | //Output_DAC1 = 4095-nSineTable[sample]; 104 | 105 | //calculate the samples 106 | out_DAC0 = (nSineTable[sample]); 107 | //Output_DAC1 = (4095-nSineTable[sample]); 108 | 109 | //to add volume feature 110 | out_DAC0 =map(out_DAC0,0,4095,POT2,1); 111 | //Output_DAC1 =map(Output_DAC1,0,4095,pot2,1); 112 | 113 | //Write the DACs 114 | dacc_set_channel_selection(DACC_INTERFACE, 0); //select DAC channel 0 115 | dacc_write_conversion_data(DACC_INTERFACE, out_DAC0);//write on DAC 116 | dacc_set_channel_selection(DACC_INTERFACE, 1); //select DAC channel 1 117 | dacc_write_conversion_data(DACC_INTERFACE, 0);//write on DAC 118 | } 119 | 120 | 121 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU GENERAL PUBLIC LICENSE 2 | Version 2, June 1991 3 | 4 | Copyright (C) 1989, 1991 Free Software Foundation, Inc., 5 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA 6 | Everyone is permitted to copy and distribute verbatim copies 7 | of this license document, but changing it is not allowed. 8 | 9 | Preamble 10 | 11 | The licenses for most software are designed to take away your 12 | freedom to share and change it. By contrast, the GNU General Public 13 | License is intended to guarantee your freedom to share and change free 14 | software--to make sure the software is free for all its users. This 15 | General Public License applies to most of the Free Software 16 | Foundation's software and to any other program whose authors commit to 17 | using it. (Some other Free Software Foundation software is covered by 18 | the GNU Lesser General Public License instead.) You can apply it to 19 | your programs, too. 20 | 21 | When we speak of free software, we are referring to freedom, not 22 | price. Our General Public Licenses are designed to make sure that you 23 | have the freedom to distribute copies of free software (and charge for 24 | this service if you wish), that you receive source code or can get it 25 | if you want it, that you can change the software or use pieces of it 26 | in new free programs; and that you know you can do these things. 27 | 28 | To protect your rights, we need to make restrictions that forbid 29 | anyone to deny you these rights or to ask you to surrender the rights. 30 | These restrictions translate to certain responsibilities for you if you 31 | distribute copies of the software, or if you modify it. 32 | 33 | For example, if you distribute copies of such a program, whether 34 | gratis or for a fee, you must give the recipients all the rights that 35 | you have. You must make sure that they, too, receive or can get the 36 | source code. And you must show them these terms so they know their 37 | rights. 38 | 39 | We protect your rights with two steps: (1) copyright the software, and 40 | (2) offer you this license which gives you legal permission to copy, 41 | distribute and/or modify the software. 42 | 43 | Also, for each author's protection and ours, we want to make certain 44 | that everyone understands that there is no warranty for this free 45 | software. If the software is modified by someone else and passed on, we 46 | want its recipients to know that what they have is not the original, so 47 | that any problems introduced by others will not reflect on the original 48 | authors' reputations. 49 | 50 | Finally, any free program is threatened constantly by software 51 | patents. We wish to avoid the danger that redistributors of a free 52 | program will individually obtain patent licenses, in effect making the 53 | program proprietary. To prevent this, we have made it clear that any 54 | patent must be licensed for everyone's free use or not licensed at all. 55 | 56 | The precise terms and conditions for copying, distribution and 57 | modification follow. 58 | 59 | GNU GENERAL PUBLIC LICENSE 60 | TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION 61 | 62 | 0. This License applies to any program or other work which contains 63 | a notice placed by the copyright holder saying it may be distributed 64 | under the terms of this General Public License. The "Program", below, 65 | refers to any such program or work, and a "work based on the Program" 66 | means either the Program or any derivative work under copyright law: 67 | that is to say, a work containing the Program or a portion of it, 68 | either verbatim or with modifications and/or translated into another 69 | language. (Hereinafter, translation is included without limitation in 70 | the term "modification".) Each licensee is addressed as "you". 71 | 72 | Activities other than copying, distribution and modification are not 73 | covered by this License; they are outside its scope. The act of 74 | running the Program is not restricted, and the output from the Program 75 | is covered only if its contents constitute a work based on the 76 | Program (independent of having been made by running the Program). 77 | Whether that is true depends on what the Program does. 78 | 79 | 1. You may copy and distribute verbatim copies of the Program's 80 | source code as you receive it, in any medium, provided that you 81 | conspicuously and appropriately publish on each copy an appropriate 82 | copyright notice and disclaimer of warranty; keep intact all the 83 | notices that refer to this License and to the absence of any warranty; 84 | and give any other recipients of the Program a copy of this License 85 | along with the Program. 86 | 87 | You may charge a fee for the physical act of transferring a copy, and 88 | you may at your option offer warranty protection in exchange for a fee. 89 | 90 | 2. You may modify your copy or copies of the Program or any portion 91 | of it, thus forming a work based on the Program, and copy and 92 | distribute such modifications or work under the terms of Section 1 93 | above, provided that you also meet all of these conditions: 94 | 95 | a) You must cause the modified files to carry prominent notices 96 | stating that you changed the files and the date of any change. 97 | 98 | b) You must cause any work that you distribute or publish, that in 99 | whole or in part contains or is derived from the Program or any 100 | part thereof, to be licensed as a whole at no charge to all third 101 | parties under the terms of this License. 102 | 103 | c) If the modified program normally reads commands interactively 104 | when run, you must cause it, when started running for such 105 | interactive use in the most ordinary way, to print or display an 106 | announcement including an appropriate copyright notice and a 107 | notice that there is no warranty (or else, saying that you provide 108 | a warranty) and that users may redistribute the program under 109 | these conditions, and telling the user how to view a copy of this 110 | License. (Exception: if the Program itself is interactive but 111 | does not normally print such an announcement, your work based on 112 | the Program is not required to print an announcement.) 113 | 114 | These requirements apply to the modified work as a whole. If 115 | identifiable sections of that work are not derived from the Program, 116 | and can be reasonably considered independent and separate works in 117 | themselves, then this License, and its terms, do not apply to those 118 | sections when you distribute them as separate works. But when you 119 | distribute the same sections as part of a whole which is a work based 120 | on the Program, the distribution of the whole must be on the terms of 121 | this License, whose permissions for other licensees extend to the 122 | entire whole, and thus to each and every part regardless of who wrote it. 123 | 124 | Thus, it is not the intent of this section to claim rights or contest 125 | your rights to work written entirely by you; rather, the intent is to 126 | exercise the right to control the distribution of derivative or 127 | collective works based on the Program. 128 | 129 | In addition, mere aggregation of another work not based on the Program 130 | with the Program (or with a work based on the Program) on a volume of 131 | a storage or distribution medium does not bring the other work under 132 | the scope of this License. 133 | 134 | 3. You may copy and distribute the Program (or a work based on it, 135 | under Section 2) in object code or executable form under the terms of 136 | Sections 1 and 2 above provided that you also do one of the following: 137 | 138 | a) Accompany it with the complete corresponding machine-readable 139 | source code, which must be distributed under the terms of Sections 140 | 1 and 2 above on a medium customarily used for software interchange; or, 141 | 142 | b) Accompany it with a written offer, valid for at least three 143 | years, to give any third party, for a charge no more than your 144 | cost of physically performing source distribution, a complete 145 | machine-readable copy of the corresponding source code, to be 146 | distributed under the terms of Sections 1 and 2 above on a medium 147 | customarily used for software interchange; or, 148 | 149 | c) Accompany it with the information you received as to the offer 150 | to distribute corresponding source code. (This alternative is 151 | allowed only for noncommercial distribution and only if you 152 | received the program in object code or executable form with such 153 | an offer, in accord with Subsection b above.) 154 | 155 | The source code for a work means the preferred form of the work for 156 | making modifications to it. For an executable work, complete source 157 | code means all the source code for all modules it contains, plus any 158 | associated interface definition files, plus the scripts used to 159 | control compilation and installation of the executable. However, as a 160 | special exception, the source code distributed need not include 161 | anything that is normally distributed (in either source or binary 162 | form) with the major components (compiler, kernel, and so on) of the 163 | operating system on which the executable runs, unless that component 164 | itself accompanies the executable. 165 | 166 | If distribution of executable or object code is made by offering 167 | access to copy from a designated place, then offering equivalent 168 | access to copy the source code from the same place counts as 169 | distribution of the source code, even though third parties are not 170 | compelled to copy the source along with the object code. 171 | 172 | 4. You may not copy, modify, sublicense, or distribute the Program 173 | except as expressly provided under this License. Any attempt 174 | otherwise to copy, modify, sublicense or distribute the Program is 175 | void, and will automatically terminate your rights under this License. 176 | However, parties who have received copies, or rights, from you under 177 | this License will not have their licenses terminated so long as such 178 | parties remain in full compliance. 179 | 180 | 5. You are not required to accept this License, since you have not 181 | signed it. However, nothing else grants you permission to modify or 182 | distribute the Program or its derivative works. These actions are 183 | prohibited by law if you do not accept this License. Therefore, by 184 | modifying or distributing the Program (or any work based on the 185 | Program), you indicate your acceptance of this License to do so, and 186 | all its terms and conditions for copying, distributing or modifying 187 | the Program or works based on it. 188 | 189 | 6. Each time you redistribute the Program (or any work based on the 190 | Program), the recipient automatically receives a license from the 191 | original licensor to copy, distribute or modify the Program subject to 192 | these terms and conditions. You may not impose any further 193 | restrictions on the recipients' exercise of the rights granted herein. 194 | You are not responsible for enforcing compliance by third parties to 195 | this License. 196 | 197 | 7. If, as a consequence of a court judgment or allegation of patent 198 | infringement or for any other reason (not limited to patent issues), 199 | conditions are imposed on you (whether by court order, agreement or 200 | otherwise) that contradict the conditions of this License, they do not 201 | excuse you from the conditions of this License. If you cannot 202 | distribute so as to satisfy simultaneously your obligations under this 203 | License and any other pertinent obligations, then as a consequence you 204 | may not distribute the Program at all. For example, if a patent 205 | license would not permit royalty-free redistribution of the Program by 206 | all those who receive copies directly or indirectly through you, then 207 | the only way you could satisfy both it and this License would be to 208 | refrain entirely from distribution of the Program. 209 | 210 | If any portion of this section is held invalid or unenforceable under 211 | any particular circumstance, the balance of the section is intended to 212 | apply and the section as a whole is intended to apply in other 213 | circumstances. 214 | 215 | It is not the purpose of this section to induce you to infringe any 216 | patents or other property right claims or to contest validity of any 217 | such claims; this section has the sole purpose of protecting the 218 | integrity of the free software distribution system, which is 219 | implemented by public license practices. Many people have made 220 | generous contributions to the wide range of software distributed 221 | through that system in reliance on consistent application of that 222 | system; it is up to the author/donor to decide if he or she is willing 223 | to distribute software through any other system and a licensee cannot 224 | impose that choice. 225 | 226 | This section is intended to make thoroughly clear what is believed to 227 | be a consequence of the rest of this License. 228 | 229 | 8. If the distribution and/or use of the Program is restricted in 230 | certain countries either by patents or by copyrighted interfaces, the 231 | original copyright holder who places the Program under this License 232 | may add an explicit geographical distribution limitation excluding 233 | those countries, so that distribution is permitted only in or among 234 | countries not thus excluded. In such case, this License incorporates 235 | the limitation as if written in the body of this License. 236 | 237 | 9. The Free Software Foundation may publish revised and/or new versions 238 | of the General Public License from time to time. Such new versions will 239 | be similar in spirit to the present version, but may differ in detail to 240 | address new problems or concerns. 241 | 242 | Each version is given a distinguishing version number. If the Program 243 | specifies a version number of this License which applies to it and "any 244 | later version", you have the option of following the terms and conditions 245 | either of that version or of any later version published by the Free 246 | Software Foundation. If the Program does not specify a version number of 247 | this License, you may choose any version ever published by the Free Software 248 | Foundation. 249 | 250 | 10. If you wish to incorporate parts of the Program into other free 251 | programs whose distribution conditions are different, write to the author 252 | to ask for permission. For software which is copyrighted by the Free 253 | Software Foundation, write to the Free Software Foundation; we sometimes 254 | make exceptions for this. Our decision will be guided by the two goals 255 | of preserving the free status of all derivatives of our free software and 256 | of promoting the sharing and reuse of software generally. 257 | 258 | NO WARRANTY 259 | 260 | 11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY 261 | FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW. EXCEPT WHEN 262 | OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES 263 | PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED 264 | OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 265 | MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. THE ENTIRE RISK AS 266 | TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU. SHOULD THE 267 | PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING, 268 | REPAIR OR CORRECTION. 269 | 270 | 12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING 271 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR 272 | REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, 273 | INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING 274 | OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED 275 | TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY 276 | YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER 277 | PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE 278 | POSSIBILITY OF SUCH DAMAGES. 279 | 280 | END OF TERMS AND CONDITIONS 281 | 282 | How to Apply These Terms to Your New Programs 283 | 284 | If you develop a new program, and you want it to be of the greatest 285 | possible use to the public, the best way to achieve this is to make it 286 | free software which everyone can redistribute and change under these terms. 287 | 288 | To do so, attach the following notices to the program. It is safest 289 | to attach them to the start of each source file to most effectively 290 | convey the exclusion of warranty; and each file should have at least 291 | the "copyright" line and a pointer to where the full notice is found. 292 | 293 | {description} 294 | Copyright (C) {year} {fullname} 295 | 296 | This program is free software; you can redistribute it and/or modify 297 | it under the terms of the GNU General Public License as published by 298 | the Free Software Foundation; either version 2 of the License, or 299 | (at your option) any later version. 300 | 301 | This program is distributed in the hope that it will be useful, 302 | but WITHOUT ANY WARRANTY; without even the implied warranty of 303 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 304 | GNU General Public License for more details. 305 | 306 | You should have received a copy of the GNU General Public License along 307 | with this program; if not, write to the Free Software Foundation, Inc., 308 | 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA. 309 | 310 | Also add information on how to contact you by electronic and paper mail. 311 | 312 | If the program is interactive, make it output a short notice like this 313 | when it starts in an interactive mode: 314 | 315 | Gnomovision version 69, Copyright (C) year name of author 316 | Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'. 317 | This is free software, and you are welcome to redistribute it 318 | under certain conditions; type `show c' for details. 319 | 320 | The hypothetical commands `show w' and `show c' should show the appropriate 321 | parts of the General Public License. Of course, the commands you use may 322 | be called something other than `show w' and `show c'; they could even be 323 | mouse-clicks or menu items--whatever suits your program. 324 | 325 | You should also get your employer (if you work as a programmer) or your 326 | school, if any, to sign a "copyright disclaimer" for the program, if 327 | necessary. Here is a sample; alter the names: 328 | 329 | Yoyodyne, Inc., hereby disclaims all copyright interest in the program 330 | `Gnomovision' (which makes passes at compilers) written by James Hacker. 331 | 332 | {signature of Ty Coon}, 1 April 1989 333 | Ty Coon, President of Vice 334 | 335 | This General Public License does not permit incorporating your program into 336 | proprietary programs. If your program is a subroutine library, you may 337 | consider it more useful to permit linking proprietary applications with the 338 | library. If this is what you want to do, use the GNU Lesser General 339 | Public License instead of this License. 340 | --------------------------------------------------------------------------------