Added MIDI-CC for the rest of the params.

Several small fixes.
Identation fixed for several files.
master
Holger Wirtz 5 years ago
parent 2621f21e1f
commit ae8d72d513
  1. 26
      EEPROMAnything.h
  2. 8
      Encoder4.h
  3. 98
      MicroMDAEPiano.ino
  4. 12
      UI.hpp
  5. 41
      config.h
  6. 6
      effect_modulated_delay.cpp
  7. 2
      effect_modulated_delay.h
  8. 42244
      mdaEPianoData.h
  9. 42244
      mdaEPianoDataXfade.h
  10. 6
      midinotes.h
  11. 6
      name.c

@ -21,7 +21,7 @@
Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
*/
// Idea from: https://playground.arduino.cc/Code/EEPROMWriteAnything/
// Idea from: https://playground.arduino.cc/Code/EEPROMWriteAnything/
#include <EEPROM.h>
#include <Arduino.h> // for type definitions
@ -30,22 +30,22 @@ uint32_t crc32(uint8_t* calc_start, uint16_t calc_bytes);
template <class T> int EEPROM_writeAnything(int ee, const T& value)
{
uint8_t* p = (uint8_t*)(const void*)&value;
uint16_t i;
uint32_t checksum=crc32(p+4,sizeof(value)-4);
uint8_t* p = (uint8_t*)(const void*)&value;
uint16_t i;
uint32_t checksum = crc32(p + 4, sizeof(value) - 4);
*p=checksum;
*p = checksum;
for (i = 0; i < sizeof(value); i++)
EEPROM.update(ee++, *p++);
return i;
for (i = 0; i < sizeof(value); i++)
EEPROM.update(ee++, *p++);
return i;
}
template <class T> int EEPROM_readAnything(int ee, T& value)
{
uint8_t* p = (uint8_t*)(void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
uint8_t* p = (uint8_t*)(void*)&value;
unsigned int i;
for (i = 0; i < sizeof(value); i++)
*p++ = EEPROM.read(ee++);
return i;
}

@ -61,11 +61,11 @@ class Encoder4 : public Encoder
{
Encoder::write(p * 4);
}
void write(int32_t p, int32_t min, int32_t max, bool wrap_around=false)
void write(int32_t p, int32_t min, int32_t max, bool wrap_around = false)
{
_wrap_around=wrap_around;
_wrap_around = wrap_around;
if (max < min)
{
_min = max;

@ -402,21 +402,101 @@ void handleControlChange(byte inChannel, byte inData1, byte inData2)
{
switch (inData1)
{
case 10: // Panorama
configuration.pan = mapfloat(float(inData2), 0, 127, 0.0, 1.0);
// Standard MIDI-CC
case MIDI_CC_PANORAMA: // Panorama
configuration.pan = map(inData2, 0, 127, ENC_MASTER_PAN_MIN, ENC_MASTER_PAN_MAX);
break;
case 91: // Reverb level
case MIDI_CC_REVERB_SEND: // Reverb level
set_reverb_level(map(inData2, 0, 127, ENC_REVERB_LEVEL_MIN, ENC_REVERB_LEVEL_MAX));
break;
case 92: // Tremolo level (same as modwheel)
case MIDI_CC_TREMOLO_DEPTH: // Tremolo level (same as modwheel)
inData1 = 1; // now it's modwheel and can be processd by ep->processMidiController :-)
break;
case 93: // Chorus level
case MIDI_CC_CHORUS_SEND: // Chorus level
set_chorus_level(map(inData2, 0, 127, ENC_CHORUS_LEVEL_MIN, ENC_CHORUS_LEVEL_MAX));
break;
case 94: // Detune level
case MIDI_CC_DETUNE_DEPTH: // Detune level
ep->setDetune(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
// Own MIDI-CC mapping
case MIDI_CC_EP_DECAY:
ep->setDecay(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_RELEASE:
ep->setRelease(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_HARDNESS:
ep->setHardness(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_TREBLE:
ep->setTreble(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_STEREO:
ep->setStereo(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_TUNE:
ep->setTune(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_VELOCITY_SENSE:
ep->setVelocitySense(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_TREM_FRQ:
ep->setPanLFO(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_EP_OVERDRIVE:
ep->setOverdrive(mapfloat(float(inData2), 0, 127, 0.0, 1.0));
break;
case MIDI_CC_COMP_GAIN:
set_comp_gain(map(inData2, 0, 127, ENC_COMP_GAIN_MIN, ENC_COMP_GAIN_MAX));
break;
case MIDI_CC_COMP_REPOSNE:
set_comp_response(map(inData2, 0, 127, ENC_COMP_RESPONSE_MIN, ENC_COMP_RESPONSE_MAX));
break;
case MIDI_CC_COMP_LIMIT:
set_comp_limit(map(inData2, 0, 127, ENC_COMP_LIMIT_MIN, ENC_COMP_LIMIT_MAX));
break;
case MIDI_CC_COMP_THRESHOLD:
set_comp_threshold(map(inData2, 0, 127, ENC_COMP_THRESHOLD_MIN, ENC_COMP_THRESHOLD_MAX));
break;
case MIDI_CC_COMP_ATTACK:
set_comp_attack(map(inData2, 0, 127, ENC_COMP_ATTACK_MIN, ENC_COMP_ATTACK_MAX));
break;
case MIDI_CC_COMP_DECAY:
set_comp_decay(map(inData2, 0, 127, ENC_COMP_DECAY_MIN, ENC_COMP_DECAY_MAX));
break;
case MIDI_CC_REVERB_ROOMSIZE:
set_reverb_roomsize(map(inData2, 0, 127, ENC_REVERB_ROOMSIZE_MIN, ENC_REVERB_ROOMSIZE_MAX));
break;
case MIDI_CC_REVERB_DAMPING:
set_reverb_damping(map(inData2, 0, 127, ENC_REVERB_DAMPING_MIN, ENC_REVERB_DAMPING_MAX));
break;
case MIDI_CC_CHORUS_FREQUENCY:
set_chorus_frequency(map(inData2, 0, 127, ENC_CHORUS_FREQUENCY_MIN, ENC_CHORUS_FREQUENCY_MAX));
break;
case MIDI_CC_CHORUS_INTENSITY:
set_chorus_intensity(map(inData2, 0, 127, ENC_CHORUS_INTENSITY_MIN, ENC_CHORUS_INTENSITY_MAX));
break;
case MIDI_CC_CHORUS_WAVEFORM:
set_chorus_waveform(map(inData2, 0, 127, ENC_CHORUS_WAVEFORM_MIN, ENC_CHORUS_WAVEFORM_MAX));
break;
case MIDI_CC_BASS_LR_LEVEL:
set_bass_lr_level(map(inData2, 0, 127, ENC_BASS_LR_LEVEL_MIN, ENC_BASS_LR_LEVEL_MAX));
break;
case MIDI_CC_BASS_MONO_LEVEL:
set_bass_mono_level(map(inData2, 0, 127, ENC_BASS_MONO_LEVEL_MIN, ENC_BASS_MONO_LEVEL_MAX));
break;
case MIDI_CC_EQ_BASS:
set_eq_bass(map(inData2, 0, 127, ENC_EQ_BASS_MIN, ENC_EQ_BASS_MAX));
break;
case MIDI_CC_EQ_TREBLE:
set_eq_treble(map(inData2, 0, 127, ENC_EQ_TREBLE_MIN, ENC_EQ_TREBLE_MAX));
break;
case MIDI_CC_MIDI_SOFT_THRU:
set_midi_soft_thru(map(inData2, 0, 127, ENC_MIDI_SOFT_THRU_MIN, ENC_MIDI_SOFT_THRU_MAX));
break;
case MIDI_CC_MONO:
set_mono(map(inData2, 0, 127, ENC_MONO_MIN, ENC_MONO_MAX));
break;
default:
ep->processMidiController(inData1, inData2);
break;
@ -556,6 +636,10 @@ void set_master_volume(uint8_t value)
// http://files.csound-tutorial.net/floss_manual/Release03/Cs_FM_03_ScrapBook/b-panning-and-spatialization.html
volume_r.gain(tmp3 * sinf(tmp2 * PI / 2));
volume_l.gain(tmp3 * cosf(tmp2 * PI / 2));
if (configuration.mono == 2)
volume_l.gain(0.0);
else if (configuration.mono == 3)
volume_r.gain(0.0);
eeprom_master_volume_update_flag = true;
eeprom_master_volume_update_timer = 0;
@ -777,6 +861,6 @@ void show_sound(void)
Serial.println(configuration.mono, DEC);
Serial.print(F("Panorama: "));
Serial.println(configuration.pan, DEC);
Serial.println(F("======END=SOUND=CONFIGURATION======="));
Serial.println(F("======END=OF=SOUND=CONFIGURATION======="));
}
#endif

@ -280,8 +280,12 @@ char* get_mono_value_text(void)
{
if (configuration.mono == 0)
sprintf(mono_value_text1, "Stereo");
else
else if (configuration.mono == 1)
sprintf(mono_value_text1, "Mono ");
else if (configuration.mono == 2)
sprintf(mono_value_text1, "Mono R");
else
sprintf(mono_value_text1, "Mono L");
return (mono_value_text1);
}
@ -2305,17 +2309,19 @@ void set_mono(uint8_t mode)
Serial.print(F("Set MONO "));
Serial.println(mode);
#endif
configuration.mono = mode;
if (mode == 0)
{
// stereo
ep->setStereo(mapfloat(float(configuration.stereo), ENC_STEREO_MIN, ENC_STEREO_MAX, 0.0, 1.0));
inverter.gain(-1.0); // change phase for second modulated delay (faked stereo mode)
configuration.mono = 0;
}
else
{
// mono
ep->setStereo(0.0);
inverter.gain(1.0);
configuration.mono = 1;
set_master_volume(master_volume);
}
}

@ -140,6 +140,41 @@
#define EEPROM_SOUND EEPROM_START_ADDRESS+1
#define EEPROM_CONFIGURATIONS EEPROM_SOUND+1
// MIDI-CC mapping
// free CCs: 102-119 / 85-90 / 52-63
#define MIDI_CC_PANORAMA 10
#define MIDI_CC_REVERB_SEND 91
#define MIDI_CC_TREMOLO_DEPTH 92
#define MIDI_CC_CHORUS_SEND 93
#define MIDI_CC_DETUNE_DEPTH 94
#define MIDI_CC_EP_DECAY 52
#define MIDI_CC_EP_RELEASE 53
#define MIDI_CC_EP_HARDNESS 54
#define MIDI_CC_EP_TREBLE 55
#define MIDI_CC_EP_STEREO 56
#define MIDI_CC_EP_TRANSPOSE 57
#define MIDI_CC_EP_TUNE 58
#define MIDI_CC_EP_VELOCITY_SENSE 59
#define MIDI_CC_EP_TREM_FRQ 60
#define MIDI_CC_EP_OVERDRIVE 61
#define MIDI_CC_COMP_GAIN 102
#define MIDI_CC_COMP_REPOSNE 103
#define MIDI_CC_COMP_LIMIT 104
#define MIDI_CC_COMP_THRESHOLD 105
#define MIDI_CC_COMP_ATTACK 106
#define MIDI_CC_COMP_DECAY 107
#define MIDI_CC_REVERB_ROOMSIZE 108
#define MIDI_CC_REVERB_DAMPING 109
#define MIDI_CC_CHORUS_FREQUENCY 111
#define MIDI_CC_CHORUS_INTENSITY 112
#define MIDI_CC_CHORUS_WAVEFORM 113
#define MIDI_CC_BASS_LR_LEVEL 114
#define MIDI_CC_BASS_MONO_LEVEL 115
#define MIDI_CC_EQ_BASS 116
#define MIDI_CC_EQ_TREBLE 117
#define MIDI_CC_MIDI_SOFT_THRU 118
#define MIDI_CC_MONO 119
//*************************************************************************************************
//* DO NO CHANGE ANYTHING BEYOND IF YOU DON'T KNOW WHAT YOU ARE DOING !!!
//*************************************************************************************************
@ -292,9 +327,9 @@
#define ENC_MAX_POLY_MAX NVOICES
#define ENC_MAX_POLY_DEFAULT NVOICES
//
#define ENC_MONO_MIN 0 // stereo
#define ENC_MONO_MAX 1 // mono
#define ENC_MONO_DEFAULT 1
#define ENC_MONO_MIN 0 // 0=stereo
#define ENC_MONO_MAX 3 // 1=mono(r/l) 2=mono(r) 3=mono(l)
#define ENC_MONO_DEFAULT 0
//
#define ENC_MASTER_VOLUME_MIN 0
#define ENC_MASTER_VOLUME_MAX 99

@ -48,6 +48,7 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, uint16_t d_length)
_delayline = NULL;
_delay_length = 0;
_cb_index = 0;
_delay_offset = 0;
if (delayline == NULL) {
return (false);
@ -58,7 +59,8 @@ boolean AudioEffectModulatedDelay::begin(short *delayline, uint16_t d_length)
_delayline = delayline;
_delay_length = d_length;
memset(_delayline, 0, d_length);
memset(_delayline, 0, _delay_length);
_delay_offset = (_delay_length - 1) >> 1;
return (true);
}
@ -101,7 +103,7 @@ void AudioEffectModulatedDelay::update(void)
_delayline[_cb_index] = *bp;
// calculate the modulation-index as a floating point number for interpolation
mod_index = *mp * (_delay_length >> 1);
mod_index = *mp * _delay_offset;
mod_fraction = modff(mod_index, &mod_number); // split float of mod_index into integer (= mod_number) and fraction part
// calculate modulation index into circular buffer

@ -47,12 +47,12 @@ class AudioEffectModulatedDelay :
virtual uint16_t get_delay_length(void);
private:
void set_modulator_filter_coeffs(void);
audio_block_t *inputQueueArray[2];
int16_t *_delayline; // pointer for the circular buffer
uint16_t _cb_index; // current write pointer of the circular buffer
uint16_t _delay_length; // calculated number of samples of the delay
int16_t cb_mod_index; // current read pointer with modulation for the circular buffer
uint16_t _delay_offset;
};
#endif

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

@ -22,7 +22,7 @@
*/
/*************************************************
* MIDI note values
MIDI note values
*************************************************/
#ifndef _MIDINOTES_H
@ -37,7 +37,7 @@
#define MIDI_DIS1 27
#define MIDI_E1 28
#define MIDI_F1 29
#define MIDI_FIS1 30
#define MIDI_FIS1 30
#define MIDI_G1 31
#define MIDI_GIS1 32
#define MIDI_A1 33
@ -54,7 +54,7 @@
#define MIDI_GIS2 44
#define MIDI_A2 45
#define MIDI_AIS2 46
#define MIDI_B2 47
#define MIDI_B2 47
#define MIDI_C3 48
#define MIDI_CIS3 49
#define MIDI_D3 50

@ -5,7 +5,7 @@
// Do not change this part. This exact format is required by USB.
struct usb_string_descriptor_struct usb_string_product_name = {
2 + MIDI_NAME_LEN * 2,
3,
MIDI_NAME
2 + MIDI_NAME_LEN * 2,
3,
MIDI_NAME
};

Loading…
Cancel
Save