You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
92 lines
3.6 KiB
92 lines
3.6 KiB
7 years ago
|
/*************************************************************************
|
||
6 years ago
|
* This demo uses the BALibrary library to provide enhanced control of
|
||
7 years ago
|
* the TGA Pro board.
|
||
|
*
|
||
|
* The latest copy of the BA Guitar library can be obtained from
|
||
6 years ago
|
* https://github.com/Blackaddr/BALibrary
|
||
7 years ago
|
*
|
||
|
* This demo provides an example guitar tone consisting of some slap-back delay,
|
||
|
* followed by a reverb and a low-pass cabinet filter.
|
||
4 years ago
|
*
|
||
|
* This example uses very simple versions of these effects in the PJRC Audio
|
||
|
* Library to make it a bit easier to learn how all this stuff works. More advanced
|
||
|
* and better sounding effects are available from the Teensy Audio community.
|
||
7 years ago
|
*
|
||
4 years ago
|
* A mild cab filter is used in case you are using headphones.
|
||
7 years ago
|
*/
|
||
|
#include <Wire.h>
|
||
|
#include <Audio.h>
|
||
|
#include <MIDI.h>
|
||
6 years ago
|
#include "BALibrary.h"
|
||
7 years ago
|
|
||
6 years ago
|
using namespace BALibrary;
|
||
7 years ago
|
|
||
|
BAAudioControlWM8731 codecControl;
|
||
|
|
||
|
AudioInputI2S i2sIn;
|
||
|
AudioOutputI2S i2sOut;
|
||
|
|
||
|
AudioMixer4 gainModule; // This will be used simply to reduce the gain before the reverb
|
||
|
AudioEffectDelay delayModule; // we'll add a little slapback echo
|
||
|
AudioEffectReverb reverb; // Add a bit of 'verb to our tone
|
||
|
AudioMixer4 mixer; // Used to mix the original dry with the wet (effects) path.
|
||
|
AudioFilterBiquad cabFilter; // We'll want something to cut out the highs and smooth the tone, just like a guitar cab.
|
||
|
|
||
|
|
||
4 years ago
|
// Audio Connections: name(channel)
|
||
|
// - Setup a mono signal chain, send the mono signal to both output channels
|
||
|
// - The reverb effect doesn't mix the dry signal, so we'll do that ourselves with the mixer effect.
|
||
|
// - We need to reduce the gain into the reverb to prevent it's filters clipping
|
||
|
// - mix the wet and the dry together, then send to a cabFilter then to the output.
|
||
|
// i2sIn(0) --> mixer(0)
|
||
|
// i2sIn(0) --> delayModule(0) --> gainModule(0) --> reverb(0) --> mixer(1)
|
||
|
// mixer(0) --> cabFilter(0) --> i2sOut(1)
|
||
7 years ago
|
AudioConnection patchIn(i2sIn,0, delayModule, 0); // route the input to the delay
|
||
|
|
||
|
AudioConnection patch2(delayModule,0, gainModule, 0); // send the delay to the gain module
|
||
4 years ago
|
AudioConnection patch2b(gainModule, 0, reverb, 0); // then to the reverb
|
||
7 years ago
|
|
||
|
|
||
4 years ago
|
AudioConnection patch1(i2sIn,0, mixer,0); // mixer input 0 is our original dry signal
|
||
7 years ago
|
AudioConnection patch3(reverb, 0, mixer, 1); // mixer input 1 is our wet
|
||
|
|
||
|
AudioConnection patch4(mixer, 0, cabFilter, 0); // mixer outpt to the cabinet filter
|
||
|
|
||
|
|
||
4 years ago
|
AudioConnection patch5(cabFilter, 0, i2sOut, 0); // connect the cab filter to the output.
|
||
7 years ago
|
AudioConnection patch5b(cabFilter, 0, i2sOut, 1); // connect the cab filter to the output.
|
||
7 years ago
|
|
||
|
void setup() {
|
||
|
|
||
4 years ago
|
TGA_PRO_MKII_REV1(); // Declare the version of the TGA Pro you are using.
|
||
|
//TGA_PRO_REVB(x);
|
||
|
//TGA_PRO_REVA(x);
|
||
|
|
||
7 years ago
|
delay(5); // wait a few ms to make sure the GTA Pro is fully powered up
|
||
4 years ago
|
AudioMemory(48); // Provide an arbitrarily large number of audio buffers (48 blocks) for the effects (delays use a lot more than others)
|
||
7 years ago
|
|
||
4 years ago
|
// If the codec was already powered up (due to reboot) power it down first
|
||
7 years ago
|
codecControl.disable();
|
||
|
delay(100);
|
||
|
codecControl.enable();
|
||
|
delay(100);
|
||
|
|
||
|
// Configure our effects
|
||
|
delayModule.delay(0, 50.0f); // 50 ms slapback delay
|
||
|
gainModule.gain(0, 0.25); // the reverb unit clips easily if the input is too high
|
||
|
mixer.gain(0, 1.0f); // unity gain on the dry
|
||
|
mixer.gain(1, 1.0f); // unity gain on the wet
|
||
|
|
||
|
// Setup 2-stages of LPF, cutoff 4500 Hz, Q-factor 0.7071 (a 'normal' Q-factor)
|
||
|
cabFilter.setLowpass(0, 4500, .7071);
|
||
|
cabFilter.setLowpass(1, 4500, .7071);
|
||
|
|
||
|
|
||
|
}
|
||
|
|
||
|
void loop() {
|
||
|
|
||
|
// The audio flows automatically through the Teensy Audio Library
|
||
|
|
||
|
}
|