|
|
|
@ -28,6 +28,8 @@ |
|
|
|
|
#include <MIDI.h> |
|
|
|
|
#include <EEPROM.h> |
|
|
|
|
#include <limits.h> |
|
|
|
|
#include <BALibrary.h> |
|
|
|
|
#include <BAEffects.h> |
|
|
|
|
#include "mdaEPiano.h" |
|
|
|
|
#ifdef USE_XFADE_DATA |
|
|
|
|
#include "mdaEPianoDataXfade.h" |
|
|
|
@ -40,11 +42,9 @@ |
|
|
|
|
#ifdef MIDI_DEVICE_USB_HOST |
|
|
|
|
#include <USBHost_t36.h> |
|
|
|
|
#endif |
|
|
|
|
#include <Bounce.h> |
|
|
|
|
#include "Encoder4.h" |
|
|
|
|
#include "LiquidCrystalPlus_I2C.h" |
|
|
|
|
#include "UI.h" |
|
|
|
|
|
|
|
|
|
using namespace BALibrary; |
|
|
|
|
using namespace BAEffects; |
|
|
|
|
|
|
|
|
|
//*************************************************************************************************
|
|
|
|
|
//* GLOBAL VARIABLES
|
|
|
|
@ -55,14 +55,18 @@ AudioPlayQueue queue_r; |
|
|
|
|
AudioPlayQueue queue_l; |
|
|
|
|
AudioAnalyzePeak peak_r; |
|
|
|
|
AudioAnalyzePeak peak_l; |
|
|
|
|
AudioEffectAnalogChorus analogChorus_r; |
|
|
|
|
AudioEffectAnalogChorus analogChorus_l; |
|
|
|
|
AudioEffectFreeverb freeverb_r; |
|
|
|
|
AudioEffectFreeverb freeverb_l; |
|
|
|
|
AudioMixer4 mixer_r; |
|
|
|
|
AudioMixer4 mixer_l; |
|
|
|
|
AudioConnection patchCord0(queue_r, peak_r); |
|
|
|
|
AudioConnection patchCord1(queue_l, peak_l); |
|
|
|
|
AudioConnection patchCord4(queue_r, freeverb_r); |
|
|
|
|
AudioConnection patchCord5(queue_l, freeverb_l); |
|
|
|
|
AudioConnection patchCord2(queue_r, analogChorus_r); |
|
|
|
|
AudioConnection patchCord3(queue_l, analogChorus_l); |
|
|
|
|
AudioConnection patchCord4(analogChorus_r, freeverb_r); |
|
|
|
|
AudioConnection patchCord5(analogChorus_l, freeverb_l); |
|
|
|
|
AudioConnection patchCord6(queue_r, 0, mixer_r, 0); |
|
|
|
|
AudioConnection patchCord7(queue_l, 0, mixer_l, 0); |
|
|
|
|
AudioConnection patchCord8(freeverb_r, 0, mixer_r, 1); |
|
|
|
@ -72,6 +76,15 @@ AudioOutputI2S i2s1; |
|
|
|
|
AudioConnection patchCord110(mixer_r, 0, i2s1, 0); |
|
|
|
|
AudioConnection patchCord111(mixer_l, 0, i2s1, 1); |
|
|
|
|
AudioControlSGTL5000 sgtl5000_1; |
|
|
|
|
#elif defined(TGA_BOARD) |
|
|
|
|
BAAudioControlWM8731 codecControl; |
|
|
|
|
AudioOutputI2S i2sOut; |
|
|
|
|
AudioAmplifier volume_r; |
|
|
|
|
AudioAmplifier volume_l; |
|
|
|
|
AudioConnection patchCord10(mixer_r, volume_r); |
|
|
|
|
AudioConnection patchCord11(mixer_l, volume_l); |
|
|
|
|
AudioConnection patchCord12(volume_r, 0, i2sOut, 1); |
|
|
|
|
AudioConnection patchCord13(volume_l, 0, i2sOut, 0); |
|
|
|
|
#else |
|
|
|
|
AudioOutputPT8211 pt8211_1; |
|
|
|
|
AudioAmplifier volume_r; |
|
|
|
@ -105,7 +118,7 @@ uint32_t xrun = 0; |
|
|
|
|
uint32_t overload = 0; |
|
|
|
|
uint32_t peak = 0; |
|
|
|
|
uint16_t render_time_max = 0; |
|
|
|
|
float vol = VOLUME; |
|
|
|
|
float vol = XVOLUME; |
|
|
|
|
float vol_right = 1.0; |
|
|
|
|
float vol_left = 1.0; |
|
|
|
|
elapsedMicros fill_audio_buffer; |
|
|
|
@ -127,26 +140,26 @@ void setup() |
|
|
|
|
Serial.begin(SERIAL_SPEED); |
|
|
|
|
delay(220); |
|
|
|
|
|
|
|
|
|
/*
|
|
|
|
|
// LCD display setup
|
|
|
|
|
lcd.init(); |
|
|
|
|
lcd.blink_off(); |
|
|
|
|
lcd.cursor_off(); |
|
|
|
|
lcd.backlight(); |
|
|
|
|
lcd.noAutoscroll(); |
|
|
|
|
lcd.clear(); |
|
|
|
|
lcd.display(); |
|
|
|
|
lcd.show(0, 0, 20, " MicroMDAEPiano"); |
|
|
|
|
lcd.show(1, 0, 16, "(c)parasiTstudio"); |
|
|
|
|
|
|
|
|
|
// Encoder setup
|
|
|
|
|
enc[0].write(INITIAL_ENC_L_VALUE); |
|
|
|
|
enc_val[0] = enc[0].read(); |
|
|
|
|
enc[1].write(INITIAL_ENC_R_VALUE); |
|
|
|
|
enc_val[1] = enc[1].read(); |
|
|
|
|
but[0].update(); |
|
|
|
|
but[1].update(); |
|
|
|
|
*/ |
|
|
|
|
/*
|
|
|
|
|
// LCD display setup
|
|
|
|
|
lcd.init(); |
|
|
|
|
lcd.blink_off(); |
|
|
|
|
lcd.cursor_off(); |
|
|
|
|
lcd.backlight(); |
|
|
|
|
lcd.noAutoscroll(); |
|
|
|
|
lcd.clear(); |
|
|
|
|
lcd.display(); |
|
|
|
|
lcd.show(0, 0, 20, " MicroMDAEPiano"); |
|
|
|
|
lcd.show(1, 0, 16, "(c)parasiTstudio"); |
|
|
|
|
|
|
|
|
|
// Encoder setup
|
|
|
|
|
enc[0].write(INITIAL_ENC_L_VALUE); |
|
|
|
|
enc_val[0] = enc[0].read(); |
|
|
|
|
enc[1].write(INITIAL_ENC_R_VALUE); |
|
|
|
|
enc_val[1] = enc[1].read(); |
|
|
|
|
but[0].update(); |
|
|
|
|
but[1].update(); |
|
|
|
|
*/ |
|
|
|
|
|
|
|
|
|
// Debug output
|
|
|
|
|
Serial.println(F("MicroMDAEPiano based on https://sourceforge.net/projects/mda-vst")); |
|
|
|
@ -183,6 +196,14 @@ void setup() |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
// start audio card
|
|
|
|
|
AudioNoInterrupts(); |
|
|
|
|
#ifdef TGA_BOARD |
|
|
|
|
codecControl.disable(); |
|
|
|
|
delay(100); |
|
|
|
|
codecControl.enable(); |
|
|
|
|
delay(100); |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
|
|
|
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
@ -223,10 +244,24 @@ void setup() |
|
|
|
|
freeverb_l.roomsize(0.2); |
|
|
|
|
freeverb_r.damping(0.5); |
|
|
|
|
freeverb_l.damping(0.5); |
|
|
|
|
|
|
|
|
|
analogChorus_r.enable();
|
|
|
|
|
analogChorus_r.bypass(true); |
|
|
|
|
analogChorus_r.rate(0.2f); |
|
|
|
|
analogChorus_r.mix(0.5f); |
|
|
|
|
analogChorus_r.depth(0.4f); |
|
|
|
|
analogChorus_l.enable();
|
|
|
|
|
analogChorus_l.bypass(true); |
|
|
|
|
analogChorus_l.rate(0.2f); |
|
|
|
|
analogChorus_l.mix(0.5f); |
|
|
|
|
analogChorus_l.depth(0.4f); |
|
|
|
|
|
|
|
|
|
mixer_r.gain(0, 0.7); |
|
|
|
|
mixer_l.gain(0, 0.7); |
|
|
|
|
mixer_r.gain(1, 0.3); |
|
|
|
|
mixer_l.gain(1, 0.3); |
|
|
|
|
|
|
|
|
|
AudioInterrupts(); |
|
|
|
|
|
|
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
|
|