|
|
@ -23,6 +23,7 @@ |
|
|
|
#include "exp2.h" |
|
|
|
#include "exp2.h" |
|
|
|
#include "controllers.h" |
|
|
|
#include "controllers.h" |
|
|
|
#include "dx7note.h" |
|
|
|
#include "dx7note.h" |
|
|
|
|
|
|
|
#include "dexed.h" |
|
|
|
|
|
|
|
|
|
|
|
const int FEEDBACK_BITDEPTH = 8; |
|
|
|
const int FEEDBACK_BITDEPTH = 8; |
|
|
|
|
|
|
|
|
|
|
@ -33,6 +34,13 @@ int32_t midinote_to_logfreq(int midinote) { |
|
|
|
return base + step * midinote; |
|
|
|
return base + step * midinote; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int32_t logfreq_round2semi(int freq) { |
|
|
|
|
|
|
|
const int base = 50857777; // (1 << 24) * (log(440) / log(2) - 69/12)
|
|
|
|
|
|
|
|
const int step = (1 << 24) / 12; |
|
|
|
|
|
|
|
const int rem = (freq - base) % step; |
|
|
|
|
|
|
|
return freq - rem; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
const int32_t coarsemul[] = { |
|
|
|
const int32_t coarsemul[] = { |
|
|
|
-16777216, 0, 16777216, 26591258, 33554432, 38955489, 43368474, 47099600, |
|
|
|
-16777216, 0, 16777216, 26591258, 33554432, 38955489, 43368474, 47099600, |
|
|
|
50331648, 53182516, 55732705, 58039632, 60145690, 62083076, 63876816, |
|
|
|
50331648, 53182516, 55732705, 58039632, 60145690, 62083076, 63876816, |
|
|
@ -176,6 +184,7 @@ void Dx7Note::init(const uint8_t patch[173], int midinote, int velocity, int src |
|
|
|
int32_t freq = osc_freq(midinote, mode, coarse, fine, detune); |
|
|
|
int32_t freq = osc_freq(midinote, mode, coarse, fine, detune); |
|
|
|
opMode[op] = mode; |
|
|
|
opMode[op] = mode; |
|
|
|
basepitch_[op] = freq; |
|
|
|
basepitch_[op] = freq; |
|
|
|
|
|
|
|
porta_curpitch_[op] = freq; |
|
|
|
ampmodsens_[op] = ampmodsenstab[patch[off + 14] & 3]; |
|
|
|
ampmodsens_[op] = ampmodsenstab[patch[off + 14] & 3]; |
|
|
|
|
|
|
|
|
|
|
|
if (porta >= 0) |
|
|
|
if (porta >= 0) |
|
|
@ -193,6 +202,7 @@ void Dx7Note::init(const uint8_t patch[173], int midinote, int velocity, int src |
|
|
|
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; |
|
|
|
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; |
|
|
|
ampmoddepth_ = (patch[140] * 165) >> 6; |
|
|
|
ampmoddepth_ = (patch[140] * 165) >> 6; |
|
|
|
porta_rateindex_ = (porta < 128) ? porta : 127; |
|
|
|
porta_rateindex_ = (porta < 128) ? porta : 127; |
|
|
|
|
|
|
|
porta_gliss_ = patch[68]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Controllers *ctrls) { |
|
|
|
void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Controllers *ctrls) { |
|
|
@ -246,8 +256,11 @@ void Dx7Note::compute(int32_t *buf, int32_t lfo_val, int32_t lfo_delay, const Co |
|
|
|
if ( opMode[op] ) |
|
|
|
if ( opMode[op] ) |
|
|
|
params_[op].freq = Freqlut::lookup(basepitch + pitch_base); |
|
|
|
params_[op].freq = Freqlut::lookup(basepitch + pitch_base); |
|
|
|
else { |
|
|
|
else { |
|
|
|
if ( porta_rateindex_ >= 0 ) |
|
|
|
if ( porta_rateindex_ >= 0 ) { |
|
|
|
basepitch = porta_curpitch_[op]; |
|
|
|
basepitch = porta_curpitch_[op]; |
|
|
|
|
|
|
|
if ( porta_gliss_ ) |
|
|
|
|
|
|
|
basepitch = logfreq_round2semi(basepitch); |
|
|
|
|
|
|
|
} |
|
|
|
params_[op].freq = Freqlut::lookup(basepitch + pitch_mod); |
|
|
|
params_[op].freq = Freqlut::lookup(basepitch + pitch_mod); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -293,7 +306,7 @@ void Dx7Note::keyup() { |
|
|
|
pitchenv_.keydown(false); |
|
|
|
pitchenv_.keydown(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Dx7Note::update(const uint8_t patch[156], int midinote, int velocity) { |
|
|
|
void Dx7Note::update(const uint8_t patch[156], int midinote, int velocity, int porta) { |
|
|
|
int rates[4]; |
|
|
|
int rates[4]; |
|
|
|
int levels[4]; |
|
|
|
int levels[4]; |
|
|
|
for (int op = 0; op < 6; op++) { |
|
|
|
for (int op = 0; op < 6; op++) { |
|
|
@ -302,7 +315,9 @@ void Dx7Note::update(const uint8_t patch[156], int midinote, int velocity) { |
|
|
|
int coarse = patch[off + 18]; |
|
|
|
int coarse = patch[off + 18]; |
|
|
|
int fine = patch[off + 19]; |
|
|
|
int fine = patch[off + 19]; |
|
|
|
int detune = patch[off + 20]; |
|
|
|
int detune = patch[off + 20]; |
|
|
|
basepitch_[op] = osc_freq(midinote, mode, coarse, fine, detune); |
|
|
|
int32_t freq = osc_freq(midinote, mode, coarse, fine, detune); |
|
|
|
|
|
|
|
basepitch_[op] = freq; |
|
|
|
|
|
|
|
porta_curpitch_[op] = freq; |
|
|
|
ampmodsens_[op] = ampmodsenstab[patch[off + 14] & 3]; |
|
|
|
ampmodsens_[op] = ampmodsenstab[patch[off + 14] & 3]; |
|
|
|
opMode[op] = mode; |
|
|
|
opMode[op] = mode; |
|
|
|
|
|
|
|
|
|
|
@ -328,6 +343,8 @@ void Dx7Note::update(const uint8_t patch[156], int midinote, int velocity) { |
|
|
|
pitchmoddepth_ = (patch[139] * 165) >> 6; |
|
|
|
pitchmoddepth_ = (patch[139] * 165) >> 6; |
|
|
|
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; |
|
|
|
pitchmodsens_ = pitchmodsenstab[patch[143] & 7]; |
|
|
|
ampmoddepth_ = (patch[140] * 165) >> 6; |
|
|
|
ampmoddepth_ = (patch[140] * 165) >> 6; |
|
|
|
|
|
|
|
porta_rateindex_ = (porta < 128) ? porta : 127; |
|
|
|
|
|
|
|
porta_gliss_ = patch[68]; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Dx7Note::peekVoiceStatus(VoiceStatus &status) { |
|
|
|
void Dx7Note::peekVoiceStatus(VoiceStatus &status) { |
|
|
@ -356,6 +373,12 @@ void Dx7Note::transferSignal(Dx7Note &src) { |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void Dx7Note::transferPortamento(Dx7Note &src) { |
|
|
|
|
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
|
|
|
|
porta_curpitch_[i] = src.porta_curpitch_[i]; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
void Dx7Note::oscSync() { |
|
|
|
void Dx7Note::oscSync() { |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
for (int i = 0; i < 6; i++) { |
|
|
|
params_[i].gain_out = 0; |
|
|
|
params_[i].gain_out = 0; |
|
|
|