Fixed some stupid type errors.

pull/1/head
Holger Wirtz 8 years ago
parent 71c81732e4
commit c2574f7d2d
  1. 1531
      src/Dexed.ttl.O
  2. 66
      src/dexed.cpp
  3. 6
      src/dexed.h

File diff suppressed because it is too large Load Diff

@ -39,6 +39,8 @@ Dexed::Dexed(double rate) : lvtk::Synth<DexedVoice, Dexed>(p_n_ports, p_midi_in)
voices[note].live = false; voices[note].live = false;
} }
refreshVoice=false;
currentNote = 0; currentNote = 0;
controllers.values_[kControllerPitch] = 0x2000; controllers.values_[kControllerPitch] = 0x2000;
controllers.modwheel_cc = 0; controllers.modwheel_cc = 0;
@ -91,7 +93,10 @@ void Dexed::set_params(void)
// Dexed-Engine // Dexed-Engine
if(getEngineType()!=int(*p(p_engine))-1) if(getEngineType()!=int(*p(p_engine))-1)
{
setEngineType(int(*p(p_engine))-1); setEngineType(int(*p(p_engine))-1);
refreshVoice=true;
}
// Dexed-Filter // Dexed-Filter
if(fx.uiCutoff!=*p(p_cutoff)) if(fx.uiCutoff!=*p(p_cutoff))
@ -323,30 +328,9 @@ void Dexed::run (uint32_t sample_count)
fx.process(output, sample_count); fx.process(output, sample_count);
} }
void Dexed::GetSamples(int n_samples, float *buffer) void Dexed::GetSamples(uint n_samples, float* buffer)
{ {
int i; uint i;
for(i=0;i < MAX_ACTIVE_NOTES;i++) {
if(voices[i].live==true &&voices[i].keydown==false)
{
uint8_t op_amp=0;
voices[i].dx7_note->peekVoiceStatus(voiceStatus);
for(int op=0;op<6;op++)
{
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)
op_amp++;
}
if(op_amp==6)
voices[i].live=false;
}
TRACE("Voice[%2d] live=%d keydown=%d",i,voices[i].live,voices[i].keydown);
}
if(refreshVoice) { if(refreshVoice) {
for(i=0;i < MAX_ACTIVE_NOTES;i++) { for(i=0;i < MAX_ACTIVE_NOTES;i++) {
@ -356,6 +340,7 @@ void Dexed::GetSamples(int n_samples, float *buffer)
lfo.reset(data + 137); lfo.reset(data + 137);
refreshVoice = false; refreshVoice = false;
} }
// flush first events // flush first events
for (i=0; i < n_samples && i < extra_buf_size_; i++) { for (i=0; i < n_samples && i < extra_buf_size_; i++) {
buffer[i] = extra_buf_[i]; buffer[i] = extra_buf_[i];
@ -363,7 +348,7 @@ void Dexed::GetSamples(int n_samples, float *buffer)
// remaining buffer is still to be processed // remaining buffer is still to be processed
if (extra_buf_size_ > n_samples) { if (extra_buf_size_ > n_samples) {
for (int j = 0; j < extra_buf_size_ - n_samples; j++) { for (uint j = 0; j < extra_buf_size_ - n_samples; j++) {
extra_buf_[j] = extra_buf_[j + n_samples]; extra_buf_[j] = extra_buf_[j + n_samples];
} }
extra_buf_size_ -= n_samples; extra_buf_size_ -= n_samples;
@ -385,12 +370,12 @@ void Dexed::GetSamples(int n_samples, float *buffer)
for (int note = 0; note < MAX_ACTIVE_NOTES; ++note) { for (int note = 0; note < MAX_ACTIVE_NOTES; ++note) {
if (voices[note].live) { if (voices[note].live) {
voices[note].dx7_note->compute(audiobuf.get(), lfovalue, lfodelay, &controllers); voices[note].dx7_note->compute(audiobuf.get(), lfovalue, lfodelay, &controllers);
for (int j=0; j < N; ++j) { for (uint j=0; j < N; ++j) {
int32_t val = audiobuf.get()[j]; int32_t val = audiobuf.get()[j];
val = val >> 4; //val = val >> 4;
int 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 = ((float) clip_val) / (float) 0x8000; float f = float(clip_val) / float(0x8000);
if(f>1.0) if(f>1.0)
f=1.0; f=1.0;
if(f<-1.0) if(f<-1.0)
@ -401,8 +386,8 @@ void Dexed::GetSamples(int n_samples, float *buffer)
} }
} }
int jmax = n_samples - i; uint jmax = n_samples - i;
for (int j = 0; j < N; ++j) { for (uint j = 0; j < N; ++j) {
if (j < jmax) { if (j < jmax) {
buffer[i + j] = sumbuf[j]; buffer[i + j] = sumbuf[j];
} else { } else {
@ -412,6 +397,27 @@ void Dexed::GetSamples(int n_samples, float *buffer)
} }
extra_buf_size_ = i - n_samples; extra_buf_size_ = i - n_samples;
} }
for(i=0;i < MAX_ACTIVE_NOTES;i++) {
if(voices[i].live==true && voices[i].keydown==false)
{
uint8_t op_amp=0;
voices[i].dx7_note->peekVoiceStatus(voiceStatus);
for(int op=0;op<6;op++)
{
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)
op_amp++;
}
if(op_amp==6)
voices[i].live=false;
}
TRACE("Voice[%2d] live=%d keydown=%d",i,voices[i].live,voices[i].keydown);
}
} }
bool Dexed::ProcessMidiMessage(const uint8_t *buf, int buf_size) { bool Dexed::ProcessMidiMessage(const uint8_t *buf, int buf_size) {

@ -81,7 +81,7 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
bool isMonoMode(void); bool isMonoMode(void);
void setMonoMode(bool mode); void setMonoMode(bool mode);
void set_params(void); void set_params(void);
void GetSamples(int n_samples, float *buffer); void GetSamples(uint n_samples, float *buffer);
uint8_t data[161]; uint8_t data[161];
Controllers controllers; Controllers controllers;
@ -111,8 +111,8 @@ class Dexed : public lvtk::Synth<DexedVoice, Dexed>
EngineOpl engineOpl; EngineOpl engineOpl;
float* outbuf_; float* outbuf_;
uint32_t bufsize_; uint32_t bufsize_;
int16_t extra_buf_[N]; float extra_buf_[N];
int extra_buf_size_; uint32_t extra_buf_size_;
private: private:
}; };

Loading…
Cancel
Save