Browse Source

Update zynaddsubfx, closes #517

tags/1.9.8
falkTX 7 years ago
parent
commit
6318983a20
2 changed files with 40 additions and 5 deletions
  1. +39
    -4
      source/native-plugins/zynaddsubfx/Synth/ADnote.cpp
  2. +1
    -1
      source/native-plugins/zynaddsubfx/Synth/ADnote.h

+ 39
- 4
source/native-plugins/zynaddsubfx/Synth/ADnote.cpp View File

@@ -77,9 +77,8 @@ ADnote::ADnote(ADnoteParameters *pars_, SynthParams &spars,
else
NoteGlobalPar.Punch.Enabled = 0;

for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice) {
for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
setupVoice(nvoice);
}

max_unison = 1;
for(int nvoice = 0; nvoice < NUM_VOICES; ++nvoice)
@@ -414,7 +413,7 @@ void ADnote::setupVoiceDetune(int nvoice)
pars.VoicePar[nvoice].PFMDetune);
}

void ADnote::setupVoiceMod(int nvoice)
void ADnote::setupVoiceMod(int nvoice, bool first_run)
{
auto &param = pars.VoicePar[nvoice];
auto &voice = NoteVoicePar[nvoice];
@@ -443,6 +442,42 @@ void ADnote::setupVoiceMod(int nvoice)

voice.FMFreqFixed = param.PFMFixedFreq;

//Triggers when a user enables modulation on a running voice
if(!first_run && voice.FMEnabled != NONE && voice.FMSmp == NULL && voice.FMVoice < 0) {
param.FMSmp->newrandseed(prng());
voice.FMSmp = memory.valloc<float>(synth.oscilsize + OSCIL_SMP_EXTRA_SAMPLES);
memset(voice.FMSmp, 0, sizeof(float)*(synth.oscilsize + OSCIL_SMP_EXTRA_SAMPLES));
int vc = nvoice;
if(param.PextFMoscil != -1)
vc = param.PextFMoscil;

float tmp = 1.0f;
if((pars.VoicePar[vc].FMSmp->Padaptiveharmonics != 0)
|| (voice.FMEnabled == MORPH)
|| (voice.FMEnabled == RING_MOD))
tmp = getFMvoicebasefreq(nvoice);

if(!pars.GlobalPar.Hrandgrouping)
pars.VoicePar[vc].FMSmp->newrandseed(prng());

for(int k = 0; k < unison_size[nvoice]; ++k)
oscposhiFM[nvoice][k] = (oscposhi[nvoice][k]
+ pars.VoicePar[vc].FMSmp->get(
voice.FMSmp, tmp))
% synth.oscilsize;

for(int i = 0; i < OSCIL_SMP_EXTRA_SAMPLES; ++i)
voice.FMSmp[synth.oscilsize + i] = voice.FMSmp[i];
int oscposhiFM_add =
(int)((param.PFMoscilphase
- 64.0f) / 128.0f * synth.oscilsize
+ synth.oscilsize * 4);
for(int k = 0; k < unison_size[nvoice]; ++k) {
oscposhiFM[nvoice][k] += oscposhiFM_add;
oscposhiFM[nvoice][k] %= synth.oscilsize;
}
}


//Compute the Voice's modulator volume (incl. damping)
float fmvoldamp = powf(440.0f / getvoicebasefreq(nvoice),
@@ -1574,7 +1609,7 @@ int ADnote::noteout(float *outl, float *outr)
|| (NoteVoicePar[nvoice].DelayTicks > 0))
continue;
setupVoiceDetune(nvoice);
setupVoiceMod(nvoice);
setupVoiceMod(nvoice, false);
}

computecurrentparameters();


+ 1
- 1
source/native-plugins/zynaddsubfx/Synth/ADnote.h View File

@@ -56,7 +56,7 @@ class ADnote:public SynthNote
void setupVoice(int nvoice);
int setupVoiceUnison(int nvoice);
void setupVoiceDetune(int nvoice);
void setupVoiceMod(int nvoice);
void setupVoiceMod(int nvoice, bool first_run = true);

/**Changes the frequency of an oscillator.
* @param nvoice voice to run computations on


Loading…
Cancel
Save