Modified mixer gain, and pre-filter gain, to avoid internal cliping.

master
Pierre-Loup Martin 5 years ago
parent 58eed4bb26
commit 4f7f79a9fb
  1. 108
      minimoog_teensy/audio_setup.h
  2. 29
      minimoog_teensy/minimoog_teensy.ino

@ -5,47 +5,50 @@
#include <SerialFlash.h> #include <SerialFlash.h>
// GUItool: begin automatically generated code // GUItool: begin automatically generated code
AudioSynthWaveformDc dcFilterEnvelope; //xy=101.75,518 AudioSynthWaveformDc dcFilterEnvelope; //xy=91,497
AudioSynthWaveformDc dcOscTune; //xy=160.75,127 AudioSynthWaveformDc dcOscTune; //xy=150,106
AudioSynthWaveformDc dcKeyTrack; //xy=163.75,91 AudioSynthWaveformDc dcKeyTrack; //xy=153,70
AudioSynthWaveformDc dcPitchBend; //xy=166.75,162 AudioSynthWaveformDc dcPitchBend; //xy=156,141
AudioSynthWaveformDc dcFilter; //xy=268.75,573 AudioSynthWaveformDc dcFilter; //xy=258,552
AudioSynthNoisePink pinkNoise; //xy=290.75,298 AudioSynthNoisePink pinkNoise; //xy=280,277
AudioSynthWaveformDc dcLfoFreq; //xy=292.75,347 AudioSynthWaveformDc dcLfoFreq; //xy=282,326
AudioSynthNoiseWhite whiteNoise; //xy=293.75,262 AudioSynthNoiseWhite whiteNoise; //xy=283,241
AudioEffectEnvelope filterEnvelope; //xy=299.75,518 AudioEffectEnvelope filterEnvelope; //xy=289,497
AudioSynthWaveformDc dcFilterKeyTrack; //xy=301.75,607 AudioSynthWaveformDc dcFilterKeyTrack; //xy=291,586
AudioAmplifier ampPitchBend; //xy=339.75,162 AudioAmplifier ampPitchBend; //xy=329,141
AudioMixer4 noiseMixer; //xy=476.75,295 AudioMixer4 noiseMixer; //xy=466,274
AudioSynthWaveformModulated lfoWaveform; //xy=481.75,347 AudioSynthWaveformModulated lfoWaveform; //xy=471,326
AudioAmplifier ampOsc3Mod; //xy=481.75,415 AudioAmplifier ampOsc3Mod; //xy=471,394
AudioAmplifier ampModEg; //xy=491.75,453 AudioAmplifier ampModEg; //xy=481,432
AudioMixer4 mainTuneMixer; //xy=563.75,111 AudioMixer4 mainTuneMixer; //xy=553,90
AudioMixer4 modMix2; //xy=687.75,448 AudioMixer4 modMix2; //xy=677,427
AudioMixer4 modMix1; //xy=688.75,377 AudioMixer4 modMix1; //xy=678,356
AudioSynthWaveformDc dcOsc3; //xy=690.75,171 AudioSynthWaveformDc dcOsc3; //xy=680,150
AudioMixer4 osc3ControlMixer; //xy=865.75,177 AudioMixer4 osc3ControlMixer; //xy=855,156
AudioMixer4 modMixer; //xy=877.75,426 AudioMixer4 modMixer; //xy=867,405
AudioSynthWaveformDc dcOsc2Tune; //xy=1037.75,133 AudioSynthWaveformDc dcOsc2Tune; //xy=1027,112
AudioSynthWaveformDc dcOsc3Tune; //xy=1038.75,199 AudioSynthWaveformDc dcOsc3Tune; //xy=1028,178
AudioAmplifier ampModWheel; //xy=1091.75,426 AudioAmplifier ampModWheel; //xy=1081,405
AudioMixer4 osc3TuneMixer; //xy=1221.75,195 AudioMixer4 osc3TuneMixer; //xy=1211,174
AudioMixer4 osc2TuneMixer; //xy=1222.75,131 AudioMixer4 osc2TuneMixer; //xy=1212,110
AudioSynthWaveformDc dcPulse; //xy=1238.75,43 AudioSynthWaveformDc dcPulse; //xy=1228,22
AudioSynthWaveformModulated osc1Waveform; //xy=1455.75,92 AudioSynthWaveformModulated osc1Waveform; //xy=1445,71
AudioSynthWaveformModulated osc2Waveform; //xy=1456.75,129 AudioSynthWaveformModulated osc2Waveform; //xy=1446,108
AudioSynthWaveformModulated osc3Waveform; //xy=1456.75,166 AudioSynthWaveformModulated osc3Waveform; //xy=1446,145
AudioMixer4 oscMixer; //xy=1642.75,135 AudioMixer4 oscMixer; //xy=1632,114
AudioMixer4 globalMixer; //xy=1851.75,182 AudioMixer4 globalMixer; //xy=1841,161
AudioAmplifier ampPreFilter; //xy=2015.75,181 AudioAmplifier ampPreFilter; //xy=2005,160
AudioMixer4 filterMixer; //xy=2033.75,424 AudioMixer4 filterMixer; //xy=2023,403
AudioFilterStateVariable vcf; //xy=2202.75,418 AudioFilterStateVariable vcf; //xy=2192,397
AudioMixer4 bandMixer; //xy=2373.75,413 AudioAnalyzePeak peakPreFilter; //xy=2254.7498779296875,147.75
AudioEffectEnvelope mainEnvelope; //xy=2552.75,414 AudioAnalyzePrint printPreFilter; //xy=2254.7498779296875,184.75001525878906
AudioEffectBitcrusher bitCrushOutput; //xy=2788.75,411 AudioMixer4 bandMixer; //xy=2363,392
AudioAmplifier masterVolume; //xy=2981.75,410.75 AudioEffectEnvelope mainEnvelope; //xy=2542,393
AudioOutputI2S i2s; //xy=3150.75,391 AudioAnalyzePrint printPostFilter; //xy=2542.75,427.75
//AudioOutputUSB usbOut; //xy=3153.75,429.75 AudioAnalyzePeak peakPostFilter; //xy=2542.75,462.75
AudioEffectBitcrusher bitCrushOutput; //xy=2778,390
AudioAmplifier masterVolume; //xy=2971,389
AudioOutputI2S i2s; //xy=3140,370
AudioConnection patchCord1(dcFilterEnvelope, filterEnvelope); AudioConnection patchCord1(dcFilterEnvelope, filterEnvelope);
AudioConnection patchCord2(dcOscTune, 0, mainTuneMixer, 1); AudioConnection patchCord2(dcOscTune, 0, mainTuneMixer, 1);
AudioConnection patchCord3(dcKeyTrack, 0, mainTuneMixer, 0); AudioConnection patchCord3(dcKeyTrack, 0, mainTuneMixer, 0);
@ -87,16 +90,15 @@ AudioConnection patchCord38(osc3Waveform, ampOsc3Mod);
AudioConnection patchCord39(oscMixer, 0, globalMixer, 0); AudioConnection patchCord39(oscMixer, 0, globalMixer, 0);
AudioConnection patchCord40(globalMixer, ampPreFilter); AudioConnection patchCord40(globalMixer, ampPreFilter);
AudioConnection patchCord41(ampPreFilter, 0, vcf, 0); AudioConnection patchCord41(ampPreFilter, 0, vcf, 0);
AudioConnection patchCord42(filterMixer, 0, vcf, 1); AudioConnection patchCord42(ampPreFilter, printPreFilter);
AudioConnection patchCord43(vcf, 0, bandMixer, 0); AudioConnection patchCord43(filterMixer, 0, vcf, 1);
AudioConnection patchCord44(vcf, 1, bandMixer, 1); AudioConnection patchCord44(vcf, 0, bandMixer, 0);
AudioConnection patchCord45(vcf, 2, bandMixer, 2); AudioConnection patchCord45(vcf, 1, bandMixer, 1);
AudioConnection patchCord46(bandMixer, mainEnvelope); AudioConnection patchCord46(vcf, 2, bandMixer, 2);
AudioConnection patchCord47(mainEnvelope, bitCrushOutput); AudioConnection patchCord47(bandMixer, mainEnvelope);
AudioConnection patchCord48(mainEnvelope, 0, globalMixer, 1); AudioConnection patchCord48(bandMixer, 0, globalMixer, 1);
AudioConnection patchCord49(bitCrushOutput, masterVolume); AudioConnection patchCord49(mainEnvelope, bitCrushOutput);
AudioConnection patchCord50(masterVolume, 0, i2s, 0); AudioConnection patchCord50(bitCrushOutput, masterVolume);
AudioConnection patchCord51(masterVolume, 0, i2s, 1); AudioConnection patchCord51(masterVolume, 0, i2s, 0);
//AudioConnection patchCord52(masterVolume, 0, usbOut, 0); AudioConnection patchCord52(masterVolume, 0, i2s, 1);
//AudioConnection patchCord53(masterVolume, 0, usbOut, 1);
// GUItool: end automatically generated code // GUItool: end automatically generated code

@ -76,7 +76,7 @@ const float FILTER_HALFTONE_TO_DC = (float)1 / (FILTER_MAX_OCTAVE * 12);
const float FILTER_BASE_FREQUENCY = 440.0; const float FILTER_BASE_FREQUENCY = 440.0;
const float FILTER_BASE_NOTE = (log(FILTER_BASE_FREQUENCY / NOTE_MIDI_0)) / (log(NOTE_RATIO)); const float FILTER_BASE_NOTE = (log(FILTER_BASE_FREQUENCY / NOTE_MIDI_0)) / (log(NOTE_RATIO));
const float MAX_MIX = 1.0; const float MAX_MIX = 0.32;
// pots never go full clockwise... :/ // pots never go full clockwise... :/
const uint16_t RESO = 1010; const uint16_t RESO = 1010;
@ -214,6 +214,7 @@ MIDI_CREATE_CUSTOM_INSTANCE(HardwareSerial, Serial4, midi2, midiSettings);
// for debug purpose, to send to serial the CPU used by audio library. // for debug purpose, to send to serial the CPU used by audio library.
// Timer timerCPU; // Timer timerCPU;
// Timer timerGraph;
void setup() { void setup() {
pinMode(13, OUTPUT); pinMode(13, OUTPUT);
@ -258,7 +259,7 @@ void setup() {
// TODO : check how to receive and transmit on different channels. // TODO : check how to receive and transmit on different channels.
usbMIDI.setHandleNoteOn(handleNoteOn); usbMIDI.setHandleNoteOn(handleNoteOn);
usbMIDI.setHandleNoteOff(handleNoteOff); usbMIDI.setHandleNoteOff(handleNoteOff);
// usbMIDI.setHandlePitchBend(handlePitchBend); usbMIDI.setHandlePitchChange(handlePitchBend);
usbMIDI.begin(); usbMIDI.begin();
@ -281,7 +282,7 @@ void setup() {
// amp // amp
ampPitchBend.gain(pitchBendRange * HALFTONE_TO_DC * 2); ampPitchBend.gain(pitchBendRange * HALFTONE_TO_DC * 2);
ampModWheel.gain(0.0); ampModWheel.gain(0.0);
ampPreFilter.gain(1.0); ampPreFilter.gain(0.55);
ampModEg.gain(0.1); ampModEg.gain(0.1);
ampOsc3Mod.gain(1); ampOsc3Mod.gain(1);
masterVolume.gain(1.0); masterVolume.gain(1.0);
@ -381,6 +382,7 @@ void setup() {
midi1.sendControlChange(CC_ASK_FOR_DATA, 127, 1); midi1.sendControlChange(CC_ASK_FOR_DATA, 127, 1);
midi2.sendControlChange(CC_ASK_FOR_DATA, 127, 1); midi2.sendControlChange(CC_ASK_FOR_DATA, 127, 1);
/* /*
timerCPU.init(); timerCPU.init();
timerCPU.setDelay(500); timerCPU.setDelay(500);
@ -388,7 +390,12 @@ void setup() {
Serial.print("max CPU usage"); Serial.print("max CPU usage");
Serial.println(AudioProcessorUsageMax()); Serial.println(AudioProcessorUsageMax());
*/ */
/*
timerGraph.init();
timerGraph.setDelay(2);
timerGraph.start(Timer::LOOP);
printPreFilter.length(1);
*/
} }
void loop() { void loop() {
@ -401,6 +408,18 @@ void loop() {
Serial.println(AudioProcessorUsage()); Serial.println(AudioProcessorUsage());
} }
*/ */
/*
if(peakPreFilter.available()){
Serial.print("pre filter :\t");
Serial.println(peakPreFilter.read());
}
if(peakPostFilter.available()){
Serial.print("post filter :\t");
Serial.println(peakPostFilter.read());
}
*/
// if(timerGraph.update()) printPreFilter.trigger();
} }
void noteOn(uint8_t note, uint8_t velocity, bool trigger = 1){ void noteOn(uint8_t note, uint8_t velocity, bool trigger = 1){
@ -683,7 +702,7 @@ void handleInternalPitchBend(uint8_t channel, int16_t bend){
if(function) handlePitchBendFunction(); if(function) handlePitchBendFunction();
int16_t bendAmount = (bend - PITCH_BEND_NEUTRAL) * PITCH_BEND_INTERNAL_TO_MIDI; int16_t bendAmount = (bend - PITCH_BEND_NEUTRAL) * PITCH_BEND_INTERNAL_TO_MIDI;
handlePitchBend(channel, bendAmount); handlePitchBend(channel, bendAmount);
MIDI.sendPitchBend(bendAmount, 0); usbMIDI.sendPitchBend(bendAmount, midiOutChannel);
/* /*
Serial.print("pitch bend :"); Serial.print("pitch bend :");
Serial.println(bend); Serial.println(bend);

Loading…
Cancel
Save