|
|
@ -3,7 +3,7 @@ |
|
|
|
|
|
|
|
|
|
|
|
MicroMDAEPiano is a port of the MDA-EPiano sound engine |
|
|
|
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.
|
|
|
|
(https://sourceforge.net/projects/mda-vst/) for the Teensy-3.5/3.6 with audio shield.
|
|
|
|
|
|
|
|
|
|
|
|
(c)2019 H. Wirtz <wirtz@parasitstudio.de> |
|
|
|
(c)2019 H. Wirtz <wirtz@parasitstudio.de> |
|
|
|
|
|
|
|
|
|
|
|
This program is free software; you can redistribute it and/or modify |
|
|
|
This program is free software; you can redistribute it and/or modify |
|
|
@ -43,6 +43,7 @@ |
|
|
|
#include <Bounce.h> |
|
|
|
#include <Bounce.h> |
|
|
|
#include <Encoder.h> |
|
|
|
#include <Encoder.h> |
|
|
|
#include "LiquidCrystalPlus_I2C.h" |
|
|
|
#include "LiquidCrystalPlus_I2C.h" |
|
|
|
|
|
|
|
#include <OpenAudio_ArduinoLibrary.h> //for AudioConvert_I16toF32, AudioConvert_F32toI16, and AudioEffectGain_F32 |
|
|
|
|
|
|
|
|
|
|
|
// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html)
|
|
|
|
// [I2C] SCL: Pin 19, SDA: Pin 18 (https://www.pjrc.com/teensy/td_libs_Wire.html)
|
|
|
|
#define LCD_I2C_ADDRESS 0x27 |
|
|
|
#define LCD_I2C_ADDRESS 0x27 |
|
|
@ -53,27 +54,35 @@ Encoder enc1(ENC1_PIN_A, ENC1_PIN_B); |
|
|
|
Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
|
|
|
|
Bounce but1 = Bounce(BUT1_PIN, 10); // 10 ms debounce
|
|
|
|
|
|
|
|
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
// GUItool: begin automatically generated code
|
|
|
|
AudioPlayQueue queue_r; //xy=494,404
|
|
|
|
AudioPlayQueue_F32 queue_r; //xy=494,404
|
|
|
|
AudioPlayQueue queue_l; //xy=494,404
|
|
|
|
AudioPlayQueue_F32 queue_l; //xy=494,404
|
|
|
|
|
|
|
|
AudioEffectCompressor_F32 comp_r; |
|
|
|
|
|
|
|
AudioEffectCompressor_F32 comp_l; |
|
|
|
|
|
|
|
AudioConvert_F32toI16 float2Int_r; |
|
|
|
|
|
|
|
AudioConvert_F32toI16 float2Int_l; |
|
|
|
AudioAnalyzePeak peak_r; //xy=695,491
|
|
|
|
AudioAnalyzePeak peak_r; //xy=695,491
|
|
|
|
AudioAnalyzePeak peak_l; //xy=695,491
|
|
|
|
AudioAnalyzePeak peak_l; //xy=695,491
|
|
|
|
AudioConnection patchCord0(queue_l, peak_l); |
|
|
|
AudioConnection_F32 patchCord0(queue_r, comp_r); |
|
|
|
AudioConnection patchCord1(queue_r, peak_r); |
|
|
|
AudioConnection_F32 patchCord1(queue_l, comp_l); |
|
|
|
|
|
|
|
AudioConnection_F32 patchCord2(comp_r, float2Int_r); |
|
|
|
|
|
|
|
AudioConnection_F32 patchCord3(comp_l, float2Int_l); |
|
|
|
|
|
|
|
AudioConnection patchCord4(float2Int_r, peak_r); |
|
|
|
|
|
|
|
AudioConnection patchCord5(float2Int_l, peak_l); |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
AudioOutputI2S i2s1; //xy=1072,364
|
|
|
|
AudioOutputI2S i2s1; //xy=1072,364
|
|
|
|
AudioConnection patchCord2(queue_l, 0, i2s1, 0); |
|
|
|
AudioConnection patchCord6(float2Int_r, 0, i2s1, 0); |
|
|
|
AudioConnection patchCord3(queue_r, 0, i2s1, 1); |
|
|
|
AudioConnection patchCord7(float2Int_l, 0, i2s1, 1); |
|
|
|
AudioControlSGTL5000 sgtl5000_1; //xy=700,536
|
|
|
|
AudioControlSGTL5000 sgtl5000_1; //xy=700,536
|
|
|
|
#else |
|
|
|
#else |
|
|
|
AudioOutputPT8211 pt8211_1; //xy=1079,320
|
|
|
|
AudioOutputPT8211 pt8211_1; //xy=1079,320
|
|
|
|
AudioAmplifier volume_r; //xy=818,370
|
|
|
|
AudioAmplifier volume_r; //xy=818,370
|
|
|
|
AudioAmplifier volume_l; //xy=818,411
|
|
|
|
AudioAmplifier volume_l; //xy=818,411
|
|
|
|
AudioConnection patchCord2(queue_l, volume_r); |
|
|
|
AudioConnection patchCord6(float2Int_r, volume_r); |
|
|
|
AudioConnection patchCord3(queue_r, volume_l); |
|
|
|
AudioConnection patchCord7(float2Int_l, volume_l); |
|
|
|
AudioConnection patchCord4(volume_r, peak_r); |
|
|
|
AudioConnection patchCord8(volume_r, peak_r); |
|
|
|
AudioConnection patchCord5(volume_l, peak_l); |
|
|
|
AudioConnection patchCord9(volume_l, peak_l); |
|
|
|
AudioConnection patchCord6(volume_r, 0, pt8211_1, 1); |
|
|
|
AudioConnection patchCord10(volume_r, 0, pt8211_1, 1); |
|
|
|
AudioConnection patchCord7(volume_l, 0, pt8211_1, 0); |
|
|
|
AudioConnection patchCord11(volume_l, 0, pt8211_1, 0); |
|
|
|
#endif |
|
|
|
#endif |
|
|
|
// GUItool: end automatically generated code
|
|
|
|
// GUItool: end automatically generated code
|
|
|
|
|
|
|
|
|
|
|
@ -164,6 +173,7 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
// start audio card
|
|
|
|
// start audio card
|
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
AudioMemory(AUDIO_MEM); |
|
|
|
|
|
|
|
AudioMemory_F32(AUDIO_MEM_F32); |
|
|
|
|
|
|
|
|
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
#ifdef TEENSY_AUDIO_BOARD |
|
|
|
sgtl5000_1.enable(); |
|
|
|
sgtl5000_1.enable(); |
|
|
@ -205,6 +215,11 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
// DECAY,RELEASE,HARDNESS,TREBLE,PAN_TREM,LFO_RATE,VELOCITY_SENSE,STEREO,MAX_POLY,TUNE,DETUNE,OVERDRIVE
|
|
|
|
// DECAY,RELEASE,HARDNESS,TREBLE,PAN_TREM,LFO_RATE,VELOCITY_SENSE,STEREO,MAX_POLY,TUNE,DETUNE,OVERDRIVE
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
// setup compressor as limiter
|
|
|
|
|
|
|
|
setup_compressor(true, -15.0f, 5.0f, 0.005f, 0.200f); |
|
|
|
|
|
|
|
// setup compressor like an automatic volume control
|
|
|
|
|
|
|
|
//setup_compressor(true,-50.0,5.0,1.0,2.0);
|
|
|
|
|
|
|
|
|
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
Serial.println(F("<setup end>")); |
|
|
|
|
|
|
|
|
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
|
#if defined (DEBUG) && defined (SHOW_CPU_LOAD_MSEC) |
|
|
@ -215,8 +230,8 @@ void setup() |
|
|
|
|
|
|
|
|
|
|
|
void loop() |
|
|
|
void loop() |
|
|
|
{ |
|
|
|
{ |
|
|
|
int16_t* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(int16_t)
|
|
|
|
float* audio_buffer_r; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(float)
|
|
|
|
int16_t* audio_buffer_l; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(int16_t)
|
|
|
|
float* audio_buffer_l; // pointer to AUDIO_BLOCK_SAMPLES * sizeof(float)
|
|
|
|
const uint16_t audio_block_time_ms = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); |
|
|
|
const uint16_t audio_block_time_ms = 1000000 / (SAMPLE_RATE / AUDIO_BLOCK_SAMPLES); |
|
|
|
|
|
|
|
|
|
|
|
// Main sound calculation
|
|
|
|
// Main sound calculation
|
|
|
@ -255,12 +270,12 @@ void loop() |
|
|
|
render_time_max = t2; |
|
|
|
render_time_max = t2; |
|
|
|
if (peak_r.available()) |
|
|
|
if (peak_r.available()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (peak_r.read() > 0.99) |
|
|
|
if (peak_r.read() > 1.00) |
|
|
|
peak++; |
|
|
|
peak++; |
|
|
|
} |
|
|
|
} |
|
|
|
if (peak_l.available()) |
|
|
|
if (peak_l.available()) |
|
|
|
{ |
|
|
|
{ |
|
|
|
if (peak_l.read() > 0.99) |
|
|
|
if (peak_l.read() > 1.00) |
|
|
|
peak++; |
|
|
|
peak++; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -278,6 +293,17 @@ void loop() |
|
|
|
handle_input(); |
|
|
|
handle_input(); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void setup_compressor(boolean use_HP_filter, float knee_dBFS, float comp_ratio, float attack_sec, float release_sec) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
comp_r.enableHPFilter(use_HP_filter); comp_l.enableHPFilter(use_HP_filter); |
|
|
|
|
|
|
|
comp_r.setThresh_dBFS(knee_dBFS); comp_l.setThresh_dBFS(knee_dBFS); |
|
|
|
|
|
|
|
comp_r.setCompressionRatio(comp_ratio); comp_l.setCompressionRatio(comp_ratio); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
float fs_Hz = AUDIO_SAMPLE_RATE; |
|
|
|
|
|
|
|
comp_r.setAttack_sec(attack_sec, fs_Hz); comp_l.setAttack_sec(attack_sec, fs_Hz); |
|
|
|
|
|
|
|
comp_r.setRelease_sec(release_sec, fs_Hz); comp_l.setRelease_sec(release_sec, fs_Hz); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void handle_input(void) |
|
|
|
void handle_input(void) |
|
|
|
{ |
|
|
|
{ |
|
|
|
#ifdef USE_ONBOARD_USB_HOST |
|
|
|
#ifdef USE_ONBOARD_USB_HOST |
|
|
@ -315,7 +341,7 @@ void handle_input(void) |
|
|
|
if (but1.update()) |
|
|
|
if (but1.update()) |
|
|
|
; |
|
|
|
; |
|
|
|
// place handling of encoder and showing values on lcd here
|
|
|
|
// place handling of encoder and showing values on lcd here
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
#ifdef DEBUG |
|
|
|
#ifdef DEBUG |
|
|
|