FIRST WORKING VERSION!
pull/4/head
Holger Wirtz 7 years ago
parent 4660200948
commit fd755727b5
  1. 23
      MicroDexed.ino
  2. 7
      dexed.cpp
  3. 3
      dexed.h
  4. 35
      dx7note.cpp
  5. 1
      synth.h

@ -4,6 +4,7 @@
#include "dexed.h" #include "dexed.h"
#define RATE 128 #define RATE 128
#define SAMPLERATE 44100
#define TEENSY 1 #define TEENSY 1
#define TEST_MIDI 1 #define TEST_MIDI 1
#define TEST_NOTE1 59 #define TEST_NOTE1 59
@ -18,11 +19,13 @@
// GUItool: begin automatically generated code // GUItool: begin automatically generated code
AudioPlayQueue queue1; //xy=266,484 AudioPlayQueue queue1; //xy=266,484
AudioEffectReverb reverb1; //xy=486,545 //AudioEffectReverb reverb1; //xy=486,545
AudioOutputI2S i2s1; //xy=739,486 AudioOutputI2S i2s1; //xy=739,486
AudioConnection patchCord1(queue1, reverb1); //AudioConnection patchCord1(queue1, reverb1);
AudioConnection patchCord2(reverb1, 0, i2s1, 0); //AudioConnection patchCord2(reverb1, 0, i2s1, 0);
AudioConnection patchCord3(reverb1, 0, i2s1, 1); //AudioConnection patchCord3(reverb1, 0, i2s1, 1);
AudioConnection patchCord2(queue1, 0, i2s1, 0);
AudioConnection patchCord3(queue1, 0, i2s1, 1);
AudioControlSGTL5000 sgtl5000_1; //xy=384,610 AudioControlSGTL5000 sgtl5000_1; //xy=384,610
// GUItool: end automatically generated code // GUItool: end automatically generated code
@ -40,7 +43,7 @@ AudioControlSGTL5000 sgtl5000_1; //xy=384,610
MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI); MIDI_CREATE_INSTANCE(HardwareSerial, Serial1, MIDI);
Dexed* dexed = new Dexed(RATE); Dexed* dexed = new Dexed(SAMPLERATE);
void setup() void setup()
{ {
@ -57,7 +60,7 @@ void setup()
AudioMemory(16); AudioMemory(16);
sgtl5000_1.enable(); sgtl5000_1.enable();
sgtl5000_1.volume(0.6); sgtl5000_1.volume(0.3);
// Initialize processor and memory measurements // Initialize processor and memory measurements
//AudioProcessorUsageMaxReset(); //AudioProcessorUsageMaxReset();
@ -82,7 +85,7 @@ void setup()
dexed->ProcessMidiMessage(0x90, TEST_NOTE2, 60); dexed->ProcessMidiMessage(0x90, TEST_NOTE2, 60);
#endif #endif
reverb1.reverbTime(5.0); //reverb1.reverbTime(5.0);
Serial.println("Go"); Serial.println("Go");
} }
@ -110,16 +113,14 @@ void loop()
// process midi->audio // process midi->audio
if (MIDI.read()) if (MIDI.read())
{ {
Serial.print("Type: "); /* Serial.print("Type: ");
Serial.print(MIDI.getType(), DEC); Serial.print(MIDI.getType(), DEC);
Serial.print(" Data1: "); Serial.print(" Data1: ");
Serial.print(MIDI.getData1(), DEC); Serial.print(MIDI.getData1(), DEC);
Serial.print(" Data2: "); Serial.print(" Data2: ");
Serial.println(MIDI.getData2(), DEC); Serial.println(MIDI.getData2(), DEC); */
dexed->ProcessMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2()); dexed->ProcessMidiMessage(MIDI.getType(), MIDI.getData1(), MIDI.getData2());
} }
else
dexed->GetSamples(RATE, audio_buffer); dexed->GetSamples(RATE, audio_buffer);
/* uint8_t i = 0; /* uint8_t i = 0;

@ -31,7 +31,7 @@
#include <unistd.h> #include <unistd.h>
#include <limits.h> #include <limits.h>
Dexed::Dexed(uint8_t rate) Dexed::Dexed(int rate)
{ {
uint8_t i; uint8_t i;
@ -177,12 +177,11 @@ void Dexed::GetSamples(uint16_t n_samples, int16_t* buffer)
voices[note].dx7_note->compute(audiobuf.get(), lfovalue, lfodelay, &controllers); voices[note].dx7_note->compute(audiobuf.get(), lfovalue, lfodelay, &controllers);
for (uint8_t j = 0; j < _N_; ++j) { for (uint8_t j = 0; j < _N_; ++j) {
int32_t val = audiobuf.get()[j]; int32_t val = audiobuf.get()[j];
//val = val >> 4; val = val >> 4;
int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9; int32_t clip_val = val < -(1 << 24) ? 0x8000 : val >= (1 << 24) ? 0x7fff : val >> 9;
/* float f = static_cast<float>(clip_val >> 1) / static_cast<float>(0x8000); float f = static_cast<float>(clip_val >> 1) / static_cast<float>(0x8000);
if (f > 1) f = 1; if (f > 1) f = 1;
if (f < -1) f = -1; if (f < -1) f = -1;
sumbuf[j] += f;*/
sumbuf[j] += clip_val; sumbuf[j] += clip_val;
audiobuf.get()[j] = 0; audiobuf.get()[j] = 0;
} }

@ -55,7 +55,7 @@ enum DexedEngineResolution {
class Dexed class Dexed
{ {
public: public:
Dexed(uint8_t rate); Dexed(int rate);
~Dexed(); ~Dexed();
void activate(void); void activate(void);
void deactivate(void); void deactivate(void);
@ -96,7 +96,6 @@ class Dexed
uint32_t extra_buf_size_; uint32_t extra_buf_size_;
private: private:
uint16_t _rate;
uint8_t _k_rate_counter; uint8_t _k_rate_counter;
uint8_t _param_change_counter; uint8_t _param_change_counter;

@ -1,18 +1,18 @@
/* /*
* Copyright 2016-2017 Pascal Gauthier. Copyright 2016-2017 Pascal Gauthier.
* Copyright 2012 Google Inc. Copyright 2012 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License"); Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. you may not use this file except in compliance with the License.
* You may obtain a copy of the License at You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0 http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS, distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and See the License for the specific language governing permissions and
* limitations under the License. limitations under the License.
*/ */
#include <math.h> #include <math.h>
@ -26,8 +26,8 @@
const int FEEDBACK_BITDEPTH = 8; const int FEEDBACK_BITDEPTH = 8;
int32_t midinote_to_logfreq(int midinote) { int32_t midinote_to_logfreq(int midinote) {
const int base = 50857777; // (1 << 24) * (log(440) / log(2) - 69/12) const int32_t base = 50857777; // (1 << 24) * (log(440) / log(2) - 69/12)
const int step = (1 << 24) / 12; const int32_t step = (1 << 24) / 12;
return base + step * midinote; return base + step * midinote;
} }
@ -44,7 +44,6 @@ int32_t osc_freq(int midinote, int mode, int coarse, int fine, int detune) {
int32_t logfreq; int32_t logfreq;
if (mode == 0) { if (mode == 0) {
logfreq = midinote_to_logfreq(midinote); logfreq = midinote_to_logfreq(midinote);
// could use more precision, closer enough for now. those numbers comes from my DX7 // could use more precision, closer enough for now. those numbers comes from my DX7
double detuneRatio = 0.0209 * exp(-0.396 * (((float)logfreq) / (1 << 24))) / 7; double detuneRatio = 0.0209 * exp(-0.396 * (((float)logfreq) / (1 << 24))) / 7;
logfreq += detuneRatio * logfreq * (detune - 7); logfreq += detuneRatio * logfreq * (detune - 7);
@ -307,7 +306,7 @@ void Dx7Note::peekVoiceStatus(VoiceStatus &status) {
} }
/** /**
* Used in monophonic mode to transfert voice state from different notes Used in monophonic mode to transfert voice state from different notes
*/ */
void Dx7Note::transferState(Dx7Note &src) { void Dx7Note::transferState(Dx7Note &src) {
for (int i = 0; i < 6; i++) { for (int i = 0; i < 6; i++) {

@ -18,6 +18,7 @@
#define __SYNTH_H #define __SYNTH_H
#include <Arduino.h> #include <Arduino.h>
#define SUPER_PRECISE
// This IS not be present on MSVC. // This IS not be present on MSVC.
// See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio // See http://stackoverflow.com/questions/126279/c99-stdint-h-header-and-ms-visual-studio

Loading…
Cancel
Save