Simplified audio calculation function.

Small fixes.
pull/4/head
Holger Wirtz 7 years ago
parent ba27df8a81
commit 7cbb2608ec
  1. 2
      MicroDexed.ino
  2. 73
      dexed.cpp
  3. 2
      dexed.h
  4. 6
      synth.h

@ -21,7 +21,7 @@
//#define SHOW_DEXED_TIMING 1 //#define SHOW_DEXED_TIMING 1
#define SHOW_XRUN 1 #define SHOW_XRUN 1
#define SHOW_CPU_LOAD_MSEC 5000 #define SHOW_CPU_LOAD_MSEC 5000
#define MAX_NOTES 10 #define MAX_NOTES 11
#define TEST_MIDI 1 #define TEST_MIDI 1
#define TEST_NOTE 40 #define TEST_NOTE 40
#define TEST_VEL 60 #define TEST_VEL 60

@ -71,11 +71,6 @@ Dexed::Dexed(int rate)
voices[i].live = false; voices[i].live = false;
} }
/* for(i=0;i<sizeof(data);++i)
{
data_float[i]=static_cast<float>(data[i]);
}*/
max_notes = 16; max_notes = 16;
currentNote = 0; currentNote = 0;
controllers.values_[kControllerPitch] = 0x2000; controllers.values_[kControllerPitch] = 0x2000;
@ -95,11 +90,11 @@ Dexed::Dexed(int rate)
sustain = false; sustain = false;
extra_buf_size_ = 0;
memset(&voiceStatus, 0, sizeof(VoiceStatus)); memset(&voiceStatus, 0, sizeof(VoiceStatus));
setEngineType(DEXED_ENGINE_MODERN); setEngineType(DEXED_ENGINE_MODERN);
//setEngineType(DEXED_ENGINE_MARKI);
//setEngineType(DEXED_ENGINE_OPL);
} }
Dexed::~Dexed() Dexed::~Dexed()
@ -140,21 +135,7 @@ void Dexed::GetSamples(uint16_t n_samples, int16_t* buffer)
refreshVoice = false; refreshVoice = false;
} }
// flush first events for (i = 0; i < n_samples; i += _N_) {
for (i = 0; i < n_samples && i < extra_buf_size_; i++) {
buffer[i] = extra_buf_[i];
}
// remaining buffer is still to be processed
if (extra_buf_size_ > n_samples) {
for (uint16_t j = 0; j < extra_buf_size_ - n_samples; j++) {
extra_buf_[j] = extra_buf_[j + n_samples];
}
extra_buf_size_ -= n_samples;
}
else
{
for (; i < n_samples; i += _N_) {
AlignedBuf<int32_t, _N_> audiobuf; AlignedBuf<int32_t, _N_> audiobuf;
float sumbuf[_N_]; float sumbuf[_N_];
@ -182,58 +163,10 @@ void Dexed::GetSamples(uint16_t n_samples, int16_t* buffer)
} }
} }
uint16_t jmax = n_samples - i;
for (uint8_t j = 0; j < _N_; ++j) { for (uint8_t j = 0; j < _N_; ++j) {
if (j < jmax)
{
buffer[i + j] = static_cast<int16_t>(sumbuf[j] * 0x8000); buffer[i + j] = static_cast<int16_t>(sumbuf[j] * 0x8000);
} }
else
extra_buf_[j - jmax] = static_cast<int16_t>(sumbuf[j] * 0x8000);
}
}
extra_buf_size_ = i - n_samples;
}
/* if (++_k_rate_counter == 0 && !monoMode)
{
uint8_t op_carrier = controllers.core->get_carrier_operators(data[134]); // look for carriers
for (i = 0; i < max_notes; i++)
{
if (voices[i].live == true)
{
uint8_t op_amp = 0;
uint8_t op_carrier_num = 0;
voices[i].dx7_note->peekVoiceStatus(voiceStatus);
for (uint8_t op = 0; op < 6; op++)
{
uint8_t op_bit = static_cast<uint8_t>(pow(2, op));
if ((op_carrier & op_bit) > 0)
{
// this voice is a carrier!
op_carrier_num++;
//TRACE("Voice[%2d] OP [%d] amp=%ld,amp_step=%d,pitch_step=%d",i,op,voiceStatus.amp[op],voiceStatus.ampStep[op],voiceStatus.pitchStep);
if (voiceStatus.amp[op] <= 1069 && voiceStatus.ampStep[op] == 4) // this voice produces no audio output
op_amp++;
}
}
if (op_amp == op_carrier_num)
{
// all carrier-operators are silent -> disable the voice
voices[i].live = false;
voices[i].sustained = false;
voices[i].keydown = false;
TRACE("Shutted down Voice[%2d]", i);
}
}
} }
} */
} }
bool Dexed::ProcessMidiMessage(uint8_t type, uint8_t data1, uint8_t data2) bool Dexed::ProcessMidiMessage(uint8_t type, uint8_t data1, uint8_t data2)

@ -90,8 +90,6 @@ class Dexed
FmCore* engineMsfa; FmCore* engineMsfa;
EngineMkI* engineMkI; EngineMkI* engineMkI;
EngineOpl* engineOpl; EngineOpl* engineOpl;
int16_t extra_buf_[_N_];
uint32_t extra_buf_size_;
private: private:
uint8_t _k_rate_counter; uint8_t _k_rate_counter;

@ -17,8 +17,8 @@
#ifndef __SYNTH_H #ifndef __SYNTH_H
#define __SYNTH_H #define __SYNTH_H
#include <Arduino.h> //#include <Arduino.h>
#define SUPER_PRECISE //#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
@ -50,7 +50,6 @@ typedef __int16 SInt16;
#define SynthMemoryBarrier() #define SynthMemoryBarrier()
#endif #endif
/*
template<typename T> template<typename T>
inline static T min(const T& a, const T& b) { inline static T min(const T& a, const T& b) {
return a < b ? a : b; return a < b ? a : b;
@ -60,7 +59,6 @@ template<typename T>
inline static T max(const T& a, const T& b) { inline static T max(const T& a, const T& b) {
return a > b ? a : b; return a > b ? a : b;
} }
*/
#define QER(n,b) ( ((float)n)/(1<<b) ) #define QER(n,b) ( ((float)n)/(1<<b) )

Loading…
Cancel
Save