Aulas e o jogo de aprendizado

Construa um pedal de efeitos digital

Um pedal de efeitos para guitarra em um Uno, com um gerador de funções para a guitarra.

O pedal pronto

Construa um pedal de efeitos digital usa a mesma placa em todas as aulas:

  • The guitar: a gerador de funções, uma senoide de 220 Hz, 2 V de pico, centrada em 0 V como o sinal de um captador.
  • The input: a 1 uF capacitor into A0, held at 2.5 V by two 10 k resistors: o bias.
  • The brain: an Arduino Uno, seu ADC rodando livre em A0 e o Timer 2 interrompendo 15.625 vezes por segundo.
  • A saída: PWM de 8 bits a 62,5 kHz no pino 9, suavizado por 1 k e 100 nF, depois 1 uF para um piezo que mostra o tom que ele ouve.
  • Controls: a potentiometer on A1, and two footswitches: MUTE on pin 2 stops the strings, FX on pin 3 switches the effect.

Este é um pedal de guitarra digital. É uma coisa diferente dos pedais de simulador de corrida em Construa pedais de célula de carga.

Como funciona

In and out. The capacitor blocks DC and the divider puts the swing in the middle of the ADC's 0 to 5 V; the code subtracts 128 to take the bias off. Each interrupt takes the latest sample, runs the effect and writes OCR1A. The knob is read eight times a second by borrowing the ADC for a sample.

Gain and clipping. Multiply, then limit: hard clipping cuts flat at the rails; soft clipping bends through y = 1.5t - 0.5t^3 first, from a 256-entry table.

Delay. A ring buffer of 1,280 bytes, all the Uno's 2 KB can spare beside the stack: 81 ms at most. Feedback writes some of the echo back for repeats, and MUTE measures the tail.

Tremolo. A slow phase accumulator, an LFO, scales every sample between 1 - depth and 1, as a triangle or a square.

Wah. Chamberlin's state-variable filter in fixed point, its band-pass output swept from 200 Hz to 2 kHz by the knob or by an LFO for auto-wah.

Latency. Sample by sample, the output follows the input within a tick. Working in blocks of 64 or 256 adds 4.1 or 16.4 ms, measured with MUTE.

O curso

  1. Áudio de entrada e saída: o bias, a variação, amostragem e Nyquist, e por que uma entrada real precisa de um buffer.
  2. Gain and clipping: clean gain, hard and soft clipping, and harmonics.
  3. Delay: a ring buffer, feedback, the tail, and the 2 KB limit.
  4. Tremolo: taxa, profundidade e forma de um LFO.
  5. Wah: um passa-faixa varrido, auto-wah e Q.
  6. Latência: amostra por amostra contra processamento em blocos.
  7. Projeto: um pedal de dois efeitos: drive e tremolo em cadeia, bypass, e a ordem trocada.

Cada passo marcado é testado no circuito em execução.