From ad8f6bd7810d5da1b7e8b7eba24e15933e7e984c Mon Sep 17 00:00:00 2001 From: Holger Wirtz Date: Tue, 29 Jan 2019 09:20:54 +0100 Subject: [PATCH] Added BALibrary. --- MicroMDAEPiano.ino => BA_MicroMDAEPiano.ino | 65 ++++++++++------ Encoder4.h | 47 ----------- LiquidCrystalPlus_I2C.h | 86 --------------------- config.h | 1 + 4 files changed, 42 insertions(+), 157 deletions(-) rename MicroMDAEPiano.ino => BA_MicroMDAEPiano.ino (93%) delete mode 100644 Encoder4.h delete mode 100644 LiquidCrystalPlus_I2C.h diff --git a/MicroMDAEPiano.ino b/BA_MicroMDAEPiano.ino similarity index 93% rename from MicroMDAEPiano.ino rename to BA_MicroMDAEPiano.ino index 5dc7013..aa8eea9 100644 --- a/MicroMDAEPiano.ino +++ b/BA_MicroMDAEPiano.ino @@ -28,6 +28,7 @@ #include #include #include +#include #include "mdaEPiano.h" #ifdef USE_XFADE_DATA #include "mdaEPianoDataXfade.h" @@ -40,11 +41,8 @@ #ifdef MIDI_DEVICE_USB_HOST #include #endif -#include -#include "Encoder4.h" -#include "LiquidCrystalPlus_I2C.h" -#include "UI.h" +using namespace BALibrary; //************************************************************************************************* //* GLOBAL VARIABLES @@ -72,6 +70,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; @@ -127,26 +134,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 +190,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 @@ -228,6 +243,8 @@ void setup() mixer_r.gain(1, 0.3); mixer_l.gain(1, 0.3); + AudioInterrupts(); + Serial.println(F("")); #if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) diff --git a/Encoder4.h b/Encoder4.h deleted file mode 100644 index d9053f8..0000000 --- a/Encoder4.h +++ /dev/null @@ -1,47 +0,0 @@ -/* - MicroMDAEPiano - - MicroMDAEPiano is a port of the MDA-EPiano sound engine - (https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield. - - (c)2019 H. Wirtz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA - -*/ - -#include - -#ifndef ENCODER4_H_INCLUDED -#define ENCODER4_H_INCLUDED - -class Encoder4 : public Encoder -{ - public: - - using Encoder::Encoder; - - int32_t read() - { - return (Encoder::read() / 4); - } - - void write(int32_t p) - { - Encoder::write(p * 4); - } -}; - -#endif diff --git a/LiquidCrystalPlus_I2C.h b/LiquidCrystalPlus_I2C.h deleted file mode 100644 index 9aea0d0..0000000 --- a/LiquidCrystalPlus_I2C.h +++ /dev/null @@ -1,86 +0,0 @@ -/* - MicroMDAEPiano - - MicroMDAEPiano is a port of the MDA-EPiano sound engine - (https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield. - - (c)2019 H. Wirtz - - This program is free software; you can redistribute it and/or modify - it under the terms of the GNU General Public License as published by - the Free Software Foundation; either version 3 of the License, or - (at your option) any later version. - - This program is distributed in the hope that it will be useful, - but WITHOUT ANY WARRANTY; without even the implied warranty of - MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - GNU General Public License for more details. - - You should have received a copy of the GNU General Public License - along with this program; if not, write to the Free Software Foundation, - Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef LIQUIDCRYSTALPLUS_I2C_H_INCLUDED -#define LIQUIDCRYSTALPLUS_I2C_H_INCLUDED - -#include // https://www.arduinolibraries.info/libraries/liquid-crystal-i2-c - -#define STRING_BUF_SIZE 21 - -class LiquidCrystalPlus_I2C : public LiquidCrystal_I2C -{ - public: - - using LiquidCrystal_I2C::LiquidCrystal_I2C; - - void show(uint8_t y, uint8_t x, uint8_t fs, char *str) - { - _show(y, x, fs, str, false, false); - } - - void show(uint8_t y, uint8_t x, uint8_t fs, long num) - { - char _buf10[STRING_BUF_SIZE]; - - _show(y, x, fs, itoa(num, _buf10, 10), true, true); - } - - private: - void _show(uint8_t pos_y, uint8_t pos_x, uint8_t field_size, char *str, bool justify_right, bool fill_zero) - { - { - char tmp[STRING_BUF_SIZE]; - char *s = tmp; - uint8_t l = strlen(str); - - memset(tmp, 0, sizeof(tmp)); - if (fill_zero == true) - memset(tmp, '0', field_size); - else - memset(tmp, 0x20, field_size - 1); // blank - - if (l > field_size) - l = field_size; - - if (justify_right == true) - s += field_size - l; - - strncpy(s, str, l); - - setCursor(pos_x, pos_y); - print(tmp); - -#ifdef DEBUG - Serial.print(pos_y, DEC); - Serial.print(F("/")); - Serial.print(pos_x, DEC); - Serial.print(F(": [")); - Serial.print(tmp); - Serial.println(F("]")); -#endif - } - } -}; - -#endif diff --git a/config.h b/config.h index 3519c03..27cb999 100644 --- a/config.h +++ b/config.h @@ -40,6 +40,7 @@ // AUDIO //#define TEENSY_AUDIO_BOARD 1 +#define TGA_BOARD //************************************************************************************************* //* MIDI SETTINGS