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.
326 lines
8.7 KiB
326 lines
8.7 KiB
/*
|
|
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 <wirtz@parasitstudio.de>
|
|
|
|
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 CONFIG_H_INCLUDED
|
|
#define CONFIG_H_INCLUDED
|
|
|
|
#include "midinotes.h"
|
|
#include <Arduino.h>
|
|
|
|
// ATTENTION! For better latency you have to redefine AUDIO_BLOCK_SAMPLES from
|
|
// 128 to 64 in <ARDUINO-IDE-DIR>/cores/teensy3/AudioStream.h
|
|
|
|
//*************************************************************************************************
|
|
//* DEVICE SETTINGS
|
|
//*************************************************************************************************
|
|
|
|
// MIDI
|
|
#define MIDI_DEVICE_DIN Serial1
|
|
#define MIDI_DEVICE_USB 1
|
|
#define MIDI_DEVICE_USB_HOST 1
|
|
|
|
// AUDIO
|
|
// If nothing is defined PT8211 is used as audio output device!
|
|
#define TEENSY_AUDIO_BOARD 1
|
|
//#define TGA_AUDIO_BOARD 1
|
|
|
|
//*************************************************************************************************
|
|
//* MIDI SETTINGS
|
|
//*************************************************************************************************
|
|
|
|
#define DEFAULT_MIDI_CHANNEL MIDI_CHANNEL_OMNI
|
|
#define MIDI_MERGE_THRU 1
|
|
|
|
//*************************************************************************************************
|
|
//* AUDIO SETTINGS
|
|
//*************************************************************************************************
|
|
|
|
#define VOLUME 0.8
|
|
#define VOLUME_CURVE 0.07
|
|
#define AUDIO_MEM 128
|
|
#define SAMPLE_RATE 44100
|
|
#define REDUCE_LOUDNESS 0
|
|
#define USE_XFADE_DATA 1
|
|
|
|
//*************************************************************************************************
|
|
//* DEBUG OUTPUT SETTINGS
|
|
//*************************************************************************************************
|
|
|
|
#define DEBUG 1
|
|
#define SERIAL_SPEED 38400
|
|
#define SHOW_XRUN 1
|
|
#define SHOW_CPU_LOAD_MSEC 5000
|
|
|
|
//*************************************************************************************************
|
|
//* HARDWARE SETTINGS
|
|
//*************************************************************************************************
|
|
|
|
// Teensy Audio Shield:
|
|
#define SGTL5000_LINEOUT_LEVEL 29
|
|
//#define SDCARD_CS_PIN 10
|
|
//#define SDCARD_MOSI_PIN 7
|
|
//#define SDCARD_SCK_PIN 14
|
|
// Teensy 3.5 & 3.6 SD card
|
|
#define SDCARD_CS_PIN BUILTIN_SDCARD
|
|
#define SDCARD_MOSI_PIN 11 // not actually used
|
|
#define SDCARD_SCK_PIN 13 // not actually used
|
|
|
|
// Encoder with button
|
|
#define NUM_ENCODER 2
|
|
#define ENC_L_PIN_A 3
|
|
#define ENC_L_PIN_B 2
|
|
#define BUT_L_PIN 4
|
|
#define INITIAL_ENC_L_VALUE 0
|
|
#define ENC_R_PIN_A 28
|
|
#define ENC_R_PIN_B 29
|
|
#define BUT_R_PIN 30
|
|
#define INITIAL_ENC_R_VALUE 0
|
|
#define BUT_DEBOUNCE_MS 20
|
|
#define LONG_BUTTON_PRESS 500
|
|
|
|
// LCD display (I2C)
|
|
// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html)
|
|
#define LCD_I2C_ADDRESS 0x27
|
|
#define LCD_CHARS 16
|
|
#define LCD_LINES 2
|
|
|
|
// EEPROM address
|
|
#define EEPROM_START_ADDRESS 0
|
|
|
|
//*************************************************************************************************
|
|
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
|
|
//*************************************************************************************************
|
|
|
|
#define CONTROL_RATE_MS 100
|
|
#define BACK_TO_MAIN_MS 800
|
|
|
|
// Encoder min/max values
|
|
#define ENC_DECAY_MIN 0
|
|
#define ENC_DECAY_MAX 99
|
|
#define ENC_DECAY_DEFAULT 49
|
|
//
|
|
#define ENC_RELEASE_MIN 0
|
|
#define ENC_RELEASE_MAX 99
|
|
#define ENC_RELEASE_DEFAULT 49
|
|
//
|
|
#define ENC_HARDNESS_MIN 0
|
|
#define ENC_HARDNESS_MAX 99
|
|
#define ENC_HARDNESS_DEFAULT 49
|
|
//
|
|
#define ENC_TREBLE_MIN 0
|
|
#define ENC_TREBLE_MAX 99
|
|
#define ENC_TREBLE_DEFAULT 49
|
|
//
|
|
#define ENC_STEREO_MIN 0
|
|
#define ENC_STEREO_MAX 99
|
|
#define ENC_STEREO_DEFAULT 64
|
|
//
|
|
#define ENC_TRANSPOSE_MIN -24
|
|
#define ENC_TRANSPOSE_MAX 24
|
|
#define ENC_TRANSPOSE_DEFAULT 0
|
|
//
|
|
#define ENC_TUNE_MIN 0
|
|
#define ENC_TUNE_MAX 99
|
|
#define ENC_TUNE_DEFAULT 49
|
|
//
|
|
#define ENC_DETUNE_MIN 0
|
|
#define ENC_DETUNE_MAX 99
|
|
#define ENC_DETUNE_DEFAULT 14
|
|
//
|
|
#define ENC_VELOCITY_SENSE_MIN 0
|
|
#define ENC_VELOCITY_SENSE_MAX 99
|
|
#define ENC_VELOCITY_SENSE_DEFAULT 24
|
|
//
|
|
#define ENC_PAN_TREM_FREQUENCY_MIN 0
|
|
#define ENC_PAN_TREM_FREQUENCY_MAX 99
|
|
#define ENC_PAN_TREM_FREQUENCY_DEFAULT 50
|
|
//
|
|
#define ENC_PAN_TREM_LEVEL_MIN 0
|
|
#define ENC_PAN_TREM_LEVEL_MAX 99
|
|
#define ENC_PAN_TREM_LEVEL_DEFAULT 50
|
|
//
|
|
#define ENC_OVERDRIVE_MIN 0
|
|
#define ENC_OVERDRIVE_MAX 99
|
|
#define ENC_OVERDRIVE_DEFAULT 50
|
|
//
|
|
#define ENC_COMP_GAIN_MIN 0
|
|
#define ENC_COMP_GAIN_MAX 99
|
|
#define ENC_COMP_GAIN_DEFAULT 50
|
|
//
|
|
#define ENC_COMP_RESPONSE_MIN 0
|
|
#define ENC_COMP_RESPONSE_MAX 99
|
|
#define ENC_COMP_RESPONSE_DEFAULT 50
|
|
//
|
|
#define ENC_COMP_LIMIT_MIN 0
|
|
#define ENC_COMP_LIMIT_MAX 99
|
|
#define ENC_COMP_LIMIT_DEFAULT 50
|
|
//
|
|
#define ENC_COMP_THRESHOLD_MIN 0
|
|
#define ENC_COMP_THRESHOLD_MAX 99
|
|
#define ENC_COMP_THRESHOLD_DEFAULT 50
|
|
//
|
|
#define ENC_COMP_ATTACK_MIN 0
|
|
#define ENC_COMP_ATTACK_MAX 99
|
|
#define ENC_COMP_ATTACK_DEFAULT 50
|
|
//
|
|
#define ENC_COMP_DECAY_MIN 0
|
|
#define ENC_COMP_DECAY_MAX 99
|
|
#define ENC_COMP_DECAY_DEFAULT 50
|
|
//
|
|
#define ENC_REVERB_ROOMSIZE_MIN 0
|
|
#define ENC_REVERB_ROOMSIZE_MAX 99
|
|
#define ENC_REVERB_ROOMSIZE_DEFAULT 50
|
|
//
|
|
#define ENC_REVERB_DAMPING_MIN 0
|
|
#define ENC_REVERB_DAMPING_MAX 99
|
|
#define ENC_REVERB_DAMPING_DEFAULT 50
|
|
//
|
|
#define ENC_REVERB_LEVEL_MIN 0
|
|
#define ENC_REVERB_LEVEL_MAX 99
|
|
#define ENC_REVERB_LEVEL_DEFAULT 50
|
|
//
|
|
#define ENC_CHORUS_FREQUENCY_MIN 0
|
|
#define ENC_CHORUS_FREQUENCY_MAX 20
|
|
#define ENC_CHORUS_FREQUENCY_DEFAULT 3
|
|
//
|
|
#define ENC_CHORUS_DELAY_MIN 0
|
|
#define ENC_CHORUS_DELAY_MAX 20
|
|
#define ENC_CHORUS_DELAY_DEFAULT 15
|
|
//
|
|
#define ENC_CHORUS_LEVEL_MIN 0
|
|
#define ENC_CHORUS_LEVEL_MAX 99
|
|
#define ENC_CHORUS_LEVEL_DEFAULT 50
|
|
//
|
|
#define ENC_BASS_LR_LEVEL_MIN 0
|
|
#define ENC_BASS_LR_LEVEL_MAX 99
|
|
#define ENC_BASS_LR_LEVEL_DEFAULT 50
|
|
//
|
|
#define ENC_BASS_MONO_LEVEL_MIN 0
|
|
#define ENC_BASS_MONO_LEVEL_MAX 99
|
|
#define ENC_BASS_MONO_LEVEL_DEFAULT 50
|
|
//
|
|
#define ENC_EQ_BASS_MIN 0
|
|
#define ENC_EQ_BASS_MAX 99
|
|
#define ENC_EQ_BASS_DEFAULT 50
|
|
//
|
|
#define ENC_EQ_TREBLE_MIN 0
|
|
#define ENC_EQ_TREBLE_MAX 99
|
|
#define ENC_EQ_TREBLE_DEFAULT 50
|
|
//
|
|
#define ENC_LOUDNESS_MIN 0
|
|
#define ENC_LOUDNESS_MAX 99
|
|
#define ENC_LOUDNESS_DEFAULT 80
|
|
//
|
|
#define ENC_MIDI_CHANNEL_MIN 0
|
|
#define ENC_MIDI_CHANNEL_MAX 16
|
|
#define ENC_MIDI_CHANNEL_DEFAULT DEFAULT_MIDI_CHANNEL
|
|
//
|
|
#define ENC_MIDI_SOFT_THRU_MIN 0
|
|
#define ENC_MIDI_SOFT_THRU_MAX 1
|
|
#define ENC_MIDI_SOFT_THRU_DEFAULT 1
|
|
//
|
|
#define ENC_MAX_POLY_MIN 1
|
|
#define ENC_MAX_POLY_MAX 32
|
|
#define ENC_MAX_POLY_DEFAULT 32
|
|
//
|
|
#define ENC_MASTER_VOLUME_MIN 0
|
|
#define ENC_MASTER_VOLUME_MAX 99
|
|
#define ENC_MASTER_VOLUME_DEFAULT 80
|
|
//
|
|
#define ENC_MASTER_PAN_MIN -20
|
|
#define ENC_MASTER_PAN_MAX 20
|
|
#define ENC_MASTER_PAN_DEFAULT 0
|
|
|
|
// MDAEPiano parameter mapping
|
|
#define MDA_EP_DECAY 0
|
|
#define MDA_EP_RELEASE 1
|
|
#define MDA_EP_HARDNESS 2
|
|
#define MDA_EP_TREBLE 3
|
|
#define MDA_EP_PAN_TREM 4
|
|
#define MDA_EP_LFO_RATE 5
|
|
#define MDA_EP_VELOCITY_SENSE 6
|
|
#define MDA_EP_STEREO 7
|
|
#define MDA_EP_MAX_POLY 8
|
|
#define MDA_EP_TUNE 9
|
|
#define MDA_EP_DETUNE 10
|
|
#define MDA_EP_OVERDRIVE 11
|
|
|
|
// MIDI
|
|
#ifdef MIDI_DEVICE_USB
|
|
#define USBCON 1
|
|
#endif
|
|
#if defined(__MK66FX1M0__)
|
|
// Teensy-3.6 settings
|
|
#define MIDI_DEVICE_USB_HOST 1
|
|
#else
|
|
// Teensy-3.5 settings
|
|
#undef MIDI_DEVICE_USB_HOST
|
|
#endif
|
|
// Engine
|
|
#if defined(__MK66FX1M0__)
|
|
// Teensy-3.6 settings
|
|
#define NVOICES 64
|
|
#else
|
|
#define NVOICES 32
|
|
#endif
|
|
|
|
// struct for holding the current configuration
|
|
struct config_t {
|
|
uint32_t checksum;
|
|
uint8_t sound;
|
|
uint8_t decay;
|
|
uint8_t release;
|
|
uint8_t hardness;
|
|
uint8_t treble;
|
|
int8_t stereo;
|
|
int8_t transpose;
|
|
int8_t tune;
|
|
uint8_t detune;
|
|
uint8_t velocity_sense;
|
|
uint8_t pan_trem_frequency;
|
|
uint8_t pan_trem_level;
|
|
uint8_t overdrive;
|
|
uint8_t comp_gain;
|
|
uint8_t comp_response;
|
|
uint8_t comp_limit;
|
|
uint8_t comp_threshold;
|
|
uint8_t comp_attack;
|
|
uint8_t comp_decay;
|
|
uint8_t reverb_roomsize;
|
|
uint8_t reverb_damping;
|
|
uint8_t reverb_level;
|
|
uint8_t chorus_frequency;
|
|
uint8_t chorus_delay;
|
|
uint8_t chorus_level;
|
|
uint8_t bass_lr_level;
|
|
uint8_t bass_mono_level;
|
|
uint8_t eq_bass;
|
|
uint8_t eq_treble;
|
|
uint8_t loudness;
|
|
uint8_t midi_channel;
|
|
uint8_t midi_soft_thru;
|
|
uint8_t max_poly;
|
|
int8_t pan;
|
|
};
|
|
|
|
#endif
|
|
|