summaryrefslogtreecommitdiff
path: root/attic/muse_qt4_evolution/synti/zynaddsubfx/Params
diff options
context:
space:
mode:
authorRobert Jonsson <spamatica@gmail.com>2011-03-07 19:01:11 +0000
committerRobert Jonsson <spamatica@gmail.com>2011-03-07 19:01:11 +0000
commite40fc849149dd97c248866a4a1d026dda5e57b62 (patch)
treeb12b358f3b3a0608001d30403358f8443118ec5f /attic/muse_qt4_evolution/synti/zynaddsubfx/Params
parent1bd4f2e8d9745cabb667b043171cad22c8577768 (diff)
clean3
Diffstat (limited to 'attic/muse_qt4_evolution/synti/zynaddsubfx/Params')
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.C637
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.h282
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.C300
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.h179
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.C227
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.h86
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.C344
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.h100
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.C91
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.h64
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.C742
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.h169
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.C129
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.h58
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C181
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.h63
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.C238
-rw-r--r--attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.h105
18 files changed, 3995 insertions, 0 deletions
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.C
new file mode 100644
index 00000000..fdbbbe83
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.C
@@ -0,0 +1,637 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ ADnoteParameters.C - Parameters for ADnote (ADsynth)
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <math.h>
+
+#include "ADnoteParameters.h"
+
+ADnoteParameters::ADnoteParameters(FFTwrapper *fft_):Presets(){
+ setpresettype("Padsyth");
+ fft=fft_;
+
+ GlobalPar.FreqEnvelope=new EnvelopeParams(0,0);
+ GlobalPar.FreqEnvelope->ASRinit(64,50,64,60);
+ GlobalPar.FreqLfo=new LFOParams(70,0,64,0,0,0,0,0);
+
+ GlobalPar.AmpEnvelope=new EnvelopeParams(64,1);
+ GlobalPar.AmpEnvelope->ADSRinit_dB(0,40,127,25);
+ GlobalPar.AmpLfo=new LFOParams(80,0,64,0,0,0,0,1);
+
+ GlobalPar.GlobalFilter=new FilterParams(2,94,40);
+ GlobalPar.FilterEnvelope=new EnvelopeParams(0,1);
+ GlobalPar.FilterEnvelope->ADSRinit_filter(64,40,64,70,60,64);
+ GlobalPar.FilterLfo=new LFOParams(80,0,64,0,0,0,0,2);
+ GlobalPar.Reson=new Resonance();
+
+ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++) EnableVoice(nvoice);
+
+ defaults();
+};
+
+void ADnoteParameters::defaults(){
+ //Default Parameters
+ /* Frequency Global Parameters */
+ GlobalPar.PStereo=1;//stereo
+ GlobalPar.PDetune=8192;//zero
+ GlobalPar.PCoarseDetune=0;
+ GlobalPar.PDetuneType=1;
+ GlobalPar.FreqEnvelope->defaults();
+ GlobalPar.FreqLfo->defaults();
+ GlobalPar.PBandwidth=64;
+
+ /* Amplitude Global Parameters */
+ GlobalPar.PVolume=90;
+ GlobalPar.PPanning=64;//center
+ GlobalPar.PAmpVelocityScaleFunction=64;
+ GlobalPar.AmpEnvelope->defaults();
+ GlobalPar.AmpLfo->defaults();
+ GlobalPar.PPunchStrength=0;
+ GlobalPar.PPunchTime=60;
+ GlobalPar.PPunchStretch=64;
+ GlobalPar.PPunchVelocitySensing=72;
+ GlobalPar.Hrandgrouping=0;
+
+ /* Filter Global Parameters*/
+ GlobalPar.PFilterVelocityScale=64;
+ GlobalPar.PFilterVelocityScaleFunction=64;
+ GlobalPar.GlobalFilter->defaults();
+ GlobalPar.FilterEnvelope->defaults();
+ GlobalPar.FilterLfo->defaults();
+ GlobalPar.Reson->defaults();
+
+
+ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
+ defaults(nvoice);
+ };
+ VoicePar[0].Enabled=1;
+};
+
+/*
+ * Defaults a voice
+ */
+void ADnoteParameters::defaults(int n){
+ int nvoice=n;
+ VoicePar[nvoice].Enabled=0;
+ VoicePar[nvoice].Type=0;
+ VoicePar[nvoice].Pfixedfreq=0;
+ VoicePar[nvoice].PfixedfreqET=0;
+ VoicePar[nvoice].Presonance=1;
+ VoicePar[nvoice].Pfilterbypass=0;
+ VoicePar[nvoice].Pextoscil=-1;
+ VoicePar[nvoice].PextFMoscil=-1;
+ VoicePar[nvoice].Poscilphase=64;
+ VoicePar[nvoice].PFMoscilphase=64;
+ VoicePar[nvoice].PDelay=0;
+ VoicePar[nvoice].PVolume=100;
+ VoicePar[nvoice].PVolumeminus=0;
+ VoicePar[nvoice].PPanning=64;//center
+ VoicePar[nvoice].PDetune=8192;//8192=0
+ VoicePar[nvoice].PCoarseDetune=0;
+ VoicePar[nvoice].PDetuneType=0;
+ VoicePar[nvoice].PFreqLfoEnabled=0;
+ VoicePar[nvoice].PFreqEnvelopeEnabled=0;
+ VoicePar[nvoice].PAmpEnvelopeEnabled=0;
+ VoicePar[nvoice].PAmpLfoEnabled=0;
+ VoicePar[nvoice].PAmpVelocityScaleFunction=127;
+ VoicePar[nvoice].PFilterEnabled=0;
+ VoicePar[nvoice].PFilterEnvelopeEnabled=0;
+ VoicePar[nvoice].PFilterLfoEnabled=0;
+ VoicePar[nvoice].PFMEnabled=0;
+
+ //I use the internal oscillator (-1)
+ VoicePar[nvoice].PFMVoice=-1;
+
+ VoicePar[nvoice].PFMVolume=90;
+ VoicePar[nvoice].PFMVolumeDamp=64;
+ VoicePar[nvoice].PFMDetune=8192;
+ VoicePar[nvoice].PFMCoarseDetune=0;
+ VoicePar[nvoice].PFMDetuneType=0;
+ VoicePar[nvoice].PFMFreqEnvelopeEnabled=0;
+ VoicePar[nvoice].PFMAmpEnvelopeEnabled=0;
+ VoicePar[nvoice].PFMVelocityScaleFunction=64;
+
+ VoicePar[nvoice].OscilSmp->defaults();
+ VoicePar[nvoice].FMSmp->defaults();
+
+ VoicePar[nvoice].AmpEnvelope->defaults();
+ VoicePar[nvoice].AmpLfo->defaults();
+
+ VoicePar[nvoice].FreqEnvelope->defaults();
+ VoicePar[nvoice].FreqLfo->defaults();
+
+ VoicePar[nvoice].VoiceFilter->defaults();
+ VoicePar[nvoice].FilterEnvelope->defaults();
+ VoicePar[nvoice].FilterLfo->defaults();
+
+ VoicePar[nvoice].FMFreqEnvelope->defaults();
+ VoicePar[nvoice].FMAmpEnvelope->defaults();
+};
+
+
+
+/*
+ * Init the voice parameters
+ */
+void ADnoteParameters::EnableVoice(int nvoice){
+ VoicePar[nvoice].OscilSmp=new OscilGen(fft,GlobalPar.Reson);
+ VoicePar[nvoice].FMSmp=new OscilGen(fft,NULL);
+
+ VoicePar[nvoice].AmpEnvelope=new EnvelopeParams(64,1);
+ VoicePar[nvoice].AmpEnvelope->ADSRinit_dB(0,100,127,100);
+ VoicePar[nvoice].AmpLfo=new LFOParams(90,32,64,0,0,30,0,1);
+
+ VoicePar[nvoice].FreqEnvelope=new EnvelopeParams(0,0);
+ VoicePar[nvoice].FreqEnvelope->ASRinit(30,40,64,60);
+ VoicePar[nvoice].FreqLfo=new LFOParams(50,40,0,0,0,0,0,0);
+
+ VoicePar[nvoice].VoiceFilter=new FilterParams(2,50,60);
+ VoicePar[nvoice].FilterEnvelope=new EnvelopeParams(0,0);
+ VoicePar[nvoice].FilterEnvelope->ADSRinit_filter(90,70,40,70,10,40);
+ VoicePar[nvoice].FilterLfo=new LFOParams(50,20,64,0,0,0,0,2);
+
+ VoicePar[nvoice].FMFreqEnvelope=new EnvelopeParams(0,0);
+ VoicePar[nvoice].FMFreqEnvelope->ASRinit(20,90,40,80);
+ VoicePar[nvoice].FMAmpEnvelope=new EnvelopeParams(64,1);
+ VoicePar[nvoice].FMAmpEnvelope->ADSRinit(80,90,127,100);
+};
+
+/*
+ * Get the Multiplier of the fine detunes of the voices
+ */
+REALTYPE ADnoteParameters::getBandwidthDetuneMultiplier(){
+ REALTYPE bw=(GlobalPar.PBandwidth-64.0)/64.0;
+ bw=pow(2.0,bw*pow(fabs(bw),0.2)*5.0);
+
+ return(bw);
+};
+
+
+/*
+ * Kill the voice
+ */
+void ADnoteParameters::KillVoice(int nvoice){
+ delete (VoicePar[nvoice].OscilSmp);
+ delete (VoicePar[nvoice].FMSmp);
+
+ delete (VoicePar[nvoice].AmpEnvelope);
+ delete (VoicePar[nvoice].AmpLfo);
+
+ delete (VoicePar[nvoice].FreqEnvelope);
+ delete (VoicePar[nvoice].FreqLfo);
+
+ delete (VoicePar[nvoice].VoiceFilter);
+ delete (VoicePar[nvoice].FilterEnvelope);
+ delete (VoicePar[nvoice].FilterLfo);
+
+ delete (VoicePar[nvoice].FMFreqEnvelope);
+ delete (VoicePar[nvoice].FMAmpEnvelope);
+};
+
+ADnoteParameters::~ADnoteParameters(){
+ delete(GlobalPar.FreqEnvelope);
+ delete(GlobalPar.FreqLfo);
+ delete(GlobalPar.AmpEnvelope);
+ delete(GlobalPar.AmpLfo);
+ delete(GlobalPar.GlobalFilter);
+ delete(GlobalPar.FilterEnvelope);
+ delete(GlobalPar.FilterLfo);
+ delete(GlobalPar.Reson);
+
+ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
+ KillVoice(nvoice);
+ };
+};
+
+
+
+
+void ADnoteParameters::add2XMLsection(XMLwrapper *xml,int n){
+ int nvoice=n;
+ if (nvoice>=NUM_VOICES) return;
+
+ int oscilused=0,fmoscilused=0;//if the oscil or fmoscil are used by another voice
+
+ for (int i=0;i<NUM_VOICES;i++){
+ if (VoicePar[i].Pextoscil==nvoice) oscilused=1;
+ if (VoicePar[i].PextFMoscil==nvoice) fmoscilused=1;
+ };
+
+ xml->addparbool("enabled",VoicePar[nvoice].Enabled);
+ if (((VoicePar[nvoice].Enabled==0)&&(oscilused==0)&&(fmoscilused==0))&&(xml->minimal)) return;
+
+ xml->addpar("type",VoicePar[nvoice].Type);
+ xml->addpar("delay",VoicePar[nvoice].PDelay);
+ xml->addparbool("resonance",VoicePar[nvoice].Presonance);
+
+ xml->addpar("ext_oscil",VoicePar[nvoice].Pextoscil);
+ xml->addpar("ext_fm_oscil",VoicePar[nvoice].PextFMoscil);
+
+ xml->addpar("oscil_phase",VoicePar[nvoice].Poscilphase);
+ xml->addpar("oscil_fm_phase",VoicePar[nvoice].PFMoscilphase);
+
+ xml->addparbool("filter_enabled",VoicePar[nvoice].PFilterEnabled);
+ xml->addparbool("filter_bypass",VoicePar[nvoice].Pfilterbypass);
+
+ xml->addpar("fm_enabled",VoicePar[nvoice].PFMEnabled);
+
+ xml->beginbranch("OSCIL");
+ VoicePar[nvoice].OscilSmp->add2XML(xml);
+ xml->endbranch();
+
+
+ xml->beginbranch("AMPLITUDE_PARAMETERS");
+ xml->addpar("panning",VoicePar[nvoice].PPanning);
+ xml->addpar("volume",VoicePar[nvoice].PVolume);
+ xml->addparbool("volume_minus",VoicePar[nvoice].PVolumeminus);
+ xml->addpar("velocity_sensing",VoicePar[nvoice].PAmpVelocityScaleFunction);
+
+ xml->addparbool("amp_envelope_enabled",VoicePar[nvoice].PAmpEnvelopeEnabled);
+ if ((VoicePar[nvoice].PAmpEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("AMPLITUDE_ENVELOPE");
+ VoicePar[nvoice].AmpEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->addparbool("amp_lfo_enabled",VoicePar[nvoice].PAmpLfoEnabled);
+ if ((VoicePar[nvoice].PAmpLfoEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("AMPLITUDE_LFO");
+ VoicePar[nvoice].AmpLfo->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->endbranch();
+
+ xml->beginbranch("FREQUENCY_PARAMETERS");
+ xml->addparbool("fixed_freq",VoicePar[nvoice].Pfixedfreq);
+ xml->addpar("fixed_freq_et",VoicePar[nvoice].PfixedfreqET);
+ xml->addpar("detune",VoicePar[nvoice].PDetune);
+ xml->addpar("coarse_detune",VoicePar[nvoice].PCoarseDetune);
+ xml->addpar("detune_type",VoicePar[nvoice].PDetuneType);
+
+ xml->addparbool("freq_envelope_enabled",VoicePar[nvoice].PFreqEnvelopeEnabled);
+ if ((VoicePar[nvoice].PFreqEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FREQUENCY_ENVELOPE");
+ VoicePar[nvoice].FreqEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->addparbool("freq_lfo_enabled",VoicePar[nvoice].PFreqLfoEnabled);
+ if ((VoicePar[nvoice].PFreqLfoEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FREQUENCY_LFO");
+ VoicePar[nvoice].FreqLfo->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->endbranch();
+
+
+ if ((VoicePar[nvoice].PFilterEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FILTER_PARAMETERS");
+ xml->beginbranch("FILTER");
+ VoicePar[nvoice].VoiceFilter->add2XML(xml);
+ xml->endbranch();
+
+ xml->addparbool("filter_envelope_enabled",VoicePar[nvoice].PFilterEnvelopeEnabled);
+ if ((VoicePar[nvoice].PFilterEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FILTER_ENVELOPE");
+ VoicePar[nvoice].FilterEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+
+ xml->addparbool("filter_lfo_enabled",VoicePar[nvoice].PFilterLfoEnabled);
+ if ((VoicePar[nvoice].PFilterLfoEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FILTER_LFO");
+ VoicePar[nvoice].FilterLfo->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->endbranch();
+ };
+
+ if ((VoicePar[nvoice].PFMEnabled!=0)||(fmoscilused!=0)||(!xml->minimal)){
+ xml->beginbranch("FM_PARAMETERS");
+ xml->addpar("input_voice",VoicePar[nvoice].PFMVoice);
+
+ xml->addpar("volume",VoicePar[nvoice].PFMVolume);
+ xml->addpar("volume_damp",VoicePar[nvoice].PFMVolumeDamp);
+ xml->addpar("velocity_sensing",VoicePar[nvoice].PFMVelocityScaleFunction);
+
+ xml->addparbool("amp_envelope_enabled",VoicePar[nvoice].PFMAmpEnvelopeEnabled);
+ if ((VoicePar[nvoice].PFMAmpEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("AMPLITUDE_ENVELOPE");
+ VoicePar[nvoice].FMAmpEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->beginbranch("MODULATOR");
+ xml->addpar("detune",VoicePar[nvoice].PFMDetune);
+ xml->addpar("coarse_detune",VoicePar[nvoice].PFMCoarseDetune);
+ xml->addpar("detune_type",VoicePar[nvoice].PFMDetuneType);
+
+ xml->addparbool("freq_envelope_enabled",VoicePar[nvoice].PFMFreqEnvelopeEnabled);
+ if ((VoicePar[nvoice].PFMFreqEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FREQUENCY_ENVELOPE");
+ VoicePar[nvoice].FMFreqEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+
+ xml->beginbranch("OSCIL");
+ VoicePar[nvoice].FMSmp->add2XML(xml);
+ xml->endbranch();
+
+ xml->endbranch();
+ xml->endbranch();
+ };
+};
+
+
+void ADnoteParameters::add2XML(XMLwrapper *xml){
+ xml->addparbool("stereo",GlobalPar.PStereo);
+
+ xml->beginbranch("AMPLITUDE_PARAMETERS");
+ xml->addpar("volume",GlobalPar.PVolume);
+ xml->addpar("panning",GlobalPar.PPanning);
+ xml->addpar("velocity_sensing",GlobalPar.PAmpVelocityScaleFunction);
+ xml->addpar("punch_strength",GlobalPar.PPunchStrength);
+ xml->addpar("punch_time",GlobalPar.PPunchTime);
+ xml->addpar("punch_stretch",GlobalPar.PPunchStretch);
+ xml->addpar("punch_velocity_sensing",GlobalPar.PPunchVelocitySensing);
+ xml->addpar("harmonic_randomness_grouping",GlobalPar.Hrandgrouping);
+
+ xml->beginbranch("AMPLITUDE_ENVELOPE");
+ GlobalPar.AmpEnvelope->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("AMPLITUDE_LFO");
+ GlobalPar.AmpLfo->add2XML(xml);
+ xml->endbranch();
+ xml->endbranch();
+
+ xml->beginbranch("FREQUENCY_PARAMETERS");
+ xml->addpar("detune",GlobalPar.PDetune);
+
+ xml->addpar("coarse_detune",GlobalPar.PCoarseDetune);
+ xml->addpar("detune_type",GlobalPar.PDetuneType);
+
+ xml->addpar("bandwidth",GlobalPar.PBandwidth);
+
+ xml->beginbranch("FREQUENCY_ENVELOPE");
+ GlobalPar.FreqEnvelope->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("FREQUENCY_LFO");
+ GlobalPar.FreqLfo->add2XML(xml);
+ xml->endbranch();
+ xml->endbranch();
+
+
+ xml->beginbranch("FILTER_PARAMETERS");
+ xml->addpar("velocity_sensing_amplitude",GlobalPar.PFilterVelocityScale);
+ xml->addpar("velocity_sensing",GlobalPar.PFilterVelocityScaleFunction);
+
+ xml->beginbranch("FILTER");
+ GlobalPar.GlobalFilter->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("FILTER_ENVELOPE");
+ GlobalPar.FilterEnvelope->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("FILTER_LFO");
+ GlobalPar.FilterLfo->add2XML(xml);
+ xml->endbranch();
+ xml->endbranch();
+
+ xml->beginbranch("RESONANCE");
+ GlobalPar.Reson->add2XML(xml);
+ xml->endbranch();
+
+ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
+ xml->beginbranch("VOICE",nvoice);
+ add2XMLsection(xml,nvoice);
+ xml->endbranch();
+ };
+};
+
+
+void ADnoteParameters::getfromXML(XMLwrapper *xml){
+ GlobalPar.PStereo=xml->getparbool("stereo",GlobalPar.PStereo);
+
+ if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
+ GlobalPar.PVolume=xml->getpar127("volume",GlobalPar.PVolume);
+ GlobalPar.PPanning=xml->getpar127("panning",GlobalPar.PPanning);
+ GlobalPar.PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",GlobalPar.PAmpVelocityScaleFunction);
+
+ GlobalPar.PPunchStrength=xml->getpar127("punch_strength",GlobalPar.PPunchStrength);
+ GlobalPar.PPunchTime=xml->getpar127("punch_time",GlobalPar.PPunchTime);
+ GlobalPar.PPunchStretch=xml->getpar127("punch_stretch",GlobalPar.PPunchStretch);
+ GlobalPar.PPunchVelocitySensing=xml->getpar127("punch_velocity_sensing",GlobalPar.PPunchVelocitySensing);
+ GlobalPar.Hrandgrouping=xml->getpar127("harmonic_randomness_grouping",GlobalPar.Hrandgrouping);
+
+ if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
+ GlobalPar.AmpEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("AMPLITUDE_LFO")){
+ GlobalPar.AmpLfo->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FREQUENCY_PARAMETERS")){
+ GlobalPar.PDetune=xml->getpar("detune",GlobalPar.PDetune,0,16383);
+ GlobalPar.PCoarseDetune=xml->getpar("coarse_detune",GlobalPar.PCoarseDetune,0,16383);
+ GlobalPar.PDetuneType=xml->getpar127("detune_type",GlobalPar.PDetuneType);
+
+ GlobalPar.PBandwidth=xml->getpar127("bandwidth",GlobalPar.PBandwidth);
+
+ xml->enterbranch("FREQUENCY_ENVELOPE");
+ GlobalPar.FreqEnvelope->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("FREQUENCY_LFO");
+ GlobalPar.FreqLfo->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->exitbranch();
+ };
+
+
+ if (xml->enterbranch("FILTER_PARAMETERS")){
+ GlobalPar.PFilterVelocityScale=xml->getpar127("velocity_sensing_amplitude",GlobalPar.PFilterVelocityScale);
+ GlobalPar.PFilterVelocityScaleFunction=xml->getpar127("velocity_sensing",GlobalPar.PFilterVelocityScaleFunction);
+
+ xml->enterbranch("FILTER");
+ GlobalPar.GlobalFilter->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("FILTER_ENVELOPE");
+ GlobalPar.FilterEnvelope->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("FILTER_LFO");
+ GlobalPar.FilterLfo->getfromXML(xml);
+ xml->exitbranch();
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("RESONANCE")){
+ GlobalPar.Reson->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
+ VoicePar[nvoice].Enabled=0;
+ if (xml->enterbranch("VOICE",nvoice)==0) continue;
+ getfromXMLsection(xml,nvoice);
+ xml->exitbranch();
+ };
+
+
+};
+
+void ADnoteParameters::getfromXMLsection(XMLwrapper *xml,int n){
+ int nvoice=n;
+ if (nvoice>=NUM_VOICES) return;
+
+ VoicePar[nvoice].Enabled=xml->getparbool("enabled",0);
+
+ VoicePar[nvoice].Type=xml->getpar127("type",VoicePar[nvoice].Type);
+ VoicePar[nvoice].PDelay=xml->getpar127("delay",VoicePar[nvoice].PDelay);
+ VoicePar[nvoice].Presonance=xml->getparbool("resonance",VoicePar[nvoice].Presonance);
+
+ VoicePar[nvoice].Pextoscil=xml->getpar("ext_oscil",-1,-1,nvoice-1);
+ VoicePar[nvoice].PextFMoscil=xml->getpar("ext_fm_oscil",-1,-1,nvoice-1);
+
+ VoicePar[nvoice].Poscilphase=xml->getpar127("oscil_phase",VoicePar[nvoice].Poscilphase);
+ VoicePar[nvoice].PFMoscilphase=xml->getpar127("oscil_fm_phase",VoicePar[nvoice].PFMoscilphase);
+
+ VoicePar[nvoice].PFilterEnabled=xml->getparbool("filter_enabled",VoicePar[nvoice].PFilterEnabled);
+ VoicePar[nvoice].Pfilterbypass=xml->getparbool("filter_bypass",VoicePar[nvoice].Pfilterbypass);
+
+ VoicePar[nvoice].PFMEnabled=xml->getpar127("fm_enabled",VoicePar[nvoice].PFMEnabled);
+
+ if (xml->enterbranch("OSCIL")){
+ VoicePar[nvoice].OscilSmp->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+
+ if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
+ VoicePar[nvoice].PPanning=xml->getpar127("panning",VoicePar[nvoice].PPanning);
+ VoicePar[nvoice].PVolume=xml->getpar127("volume",VoicePar[nvoice].PVolume);
+ VoicePar[nvoice].PVolumeminus=xml->getparbool("volume_minus",VoicePar[nvoice].PVolumeminus);
+ VoicePar[nvoice].PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",VoicePar[nvoice].PAmpVelocityScaleFunction);
+
+ VoicePar[nvoice].PAmpEnvelopeEnabled=xml->getparbool("amp_envelope_enabled",VoicePar[nvoice].PAmpEnvelopeEnabled);
+ if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
+ VoicePar[nvoice].AmpEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ VoicePar[nvoice].PAmpLfoEnabled=xml->getparbool("amp_lfo_enabled",VoicePar[nvoice].PAmpLfoEnabled);
+ if (xml->enterbranch("AMPLITUDE_LFO")){
+ VoicePar[nvoice].AmpLfo->getfromXML(xml);
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FREQUENCY_PARAMETERS")){
+ VoicePar[nvoice].Pfixedfreq=xml->getparbool("fixed_freq",VoicePar[nvoice].Pfixedfreq);
+ VoicePar[nvoice].PfixedfreqET=xml->getpar127("fixed_freq_et",VoicePar[nvoice].PfixedfreqET);
+
+
+ VoicePar[nvoice].PDetune=xml->getpar("detune",VoicePar[nvoice].PDetune,0,16383);
+
+ VoicePar[nvoice].PCoarseDetune=xml->getpar("coarse_detune",VoicePar[nvoice].PCoarseDetune,0,16383);
+ VoicePar[nvoice].PDetuneType=xml->getpar127("detune_type",VoicePar[nvoice].PDetuneType);
+
+ VoicePar[nvoice].PFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",VoicePar[nvoice].PFreqEnvelopeEnabled);
+ if (xml->enterbranch("FREQUENCY_ENVELOPE")){
+ VoicePar[nvoice].FreqEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ VoicePar[nvoice].PFreqLfoEnabled=xml->getparbool("freq_lfo_enabled",VoicePar[nvoice].PFreqLfoEnabled);
+ if (xml->enterbranch("FREQUENCY_LFO")){
+ VoicePar[nvoice].FreqLfo->getfromXML(xml);
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FILTER_PARAMETERS")){
+ if (xml->enterbranch("FILTER")){
+ VoicePar[nvoice].VoiceFilter->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ VoicePar[nvoice].PFilterEnvelopeEnabled=xml->getparbool("filter_envelope_enabled",VoicePar[nvoice].PFilterEnvelopeEnabled);
+ if (xml->enterbranch("FILTER_ENVELOPE")){
+ VoicePar[nvoice].FilterEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ VoicePar[nvoice].PFilterLfoEnabled=xml->getparbool("filter_lfo_enabled",VoicePar[nvoice].PFilterLfoEnabled);
+ if (xml->enterbranch("FILTER_LFO")){
+ VoicePar[nvoice].FilterLfo->getfromXML(xml);
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FM_PARAMETERS")){
+ VoicePar[nvoice].PFMVoice=xml->getpar("input_voice",VoicePar[nvoice].PFMVoice,-1,nvoice-1);
+
+ VoicePar[nvoice].PFMVolume=xml->getpar127("volume",VoicePar[nvoice].PFMVolume);
+ VoicePar[nvoice].PFMVolumeDamp=xml->getpar127("volume_damp",VoicePar[nvoice].PFMVolumeDamp);
+ VoicePar[nvoice].PFMVelocityScaleFunction=xml->getpar127("velocity_sensing",VoicePar[nvoice].PFMVelocityScaleFunction);
+
+ VoicePar[nvoice].PFMAmpEnvelopeEnabled=xml->getparbool("amp_envelope_enabled",VoicePar[nvoice].PFMAmpEnvelopeEnabled);
+ if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
+ VoicePar[nvoice].FMAmpEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("MODULATOR")){
+ VoicePar[nvoice].PFMDetune=xml->getpar("detune",VoicePar[nvoice].PFMDetune,0,16383);
+ VoicePar[nvoice].PFMCoarseDetune=xml->getpar("coarse_detune",VoicePar[nvoice].PFMCoarseDetune,0,16383);
+ VoicePar[nvoice].PFMDetuneType=xml->getpar127("detune_type",VoicePar[nvoice].PFMDetuneType);
+
+ VoicePar[nvoice].PFMFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",VoicePar[nvoice].PFMFreqEnvelopeEnabled);
+ if (xml->enterbranch("FREQUENCY_ENVELOPE")){
+ VoicePar[nvoice].FMFreqEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("OSCIL")){
+ VoicePar[nvoice].FMSmp->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+};
+
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.h
new file mode 100644
index 00000000..1773f2cd
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/ADnoteParameters.h
@@ -0,0 +1,282 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ ADnoteParameters.h - Parameters for ADnote (ADsynth)
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef AD_NOTE_PARAMETERS_H
+#define AD_NOTE_PARAMETERS_H
+
+
+#include "../globals.h"
+#include "EnvelopeParams.h"
+#include "LFOParams.h"
+#include "FilterParams.h"
+#include "../Synth/OscilGen.h"
+#include "../Synth/Resonance.h"
+#include "../Misc/Util.h"
+#include "../Misc/XMLwrapper.h"
+#include "../DSP/FFTwrapper.h"
+#include "Presets.h"
+
+ enum FMTYPE{NONE,MORPH,RING_MOD,PHASE_MOD,FREQ_MOD,PITCH_MOD};
+
+ /*****************************************************************/
+ /* GLOBAL PARAMETERS */
+ /*****************************************************************/
+
+ struct ADnoteGlobalParam{
+
+ /* The instrument type - MONO/STEREO
+ If the mode is MONO, the panning of voices are not used
+ Stereo=1, Mono=0. */
+
+ unsigned char PStereo;
+
+
+ /******************************************
+ * FREQUENCY GLOBAL PARAMETERS *
+ ******************************************/
+ unsigned short int PDetune;//fine detune
+ unsigned short int PCoarseDetune;//coarse detune+octave
+ unsigned char PDetuneType;//detune type
+
+ unsigned char PBandwidth;//how much the relative fine detunes of the voices are changed
+
+ EnvelopeParams *FreqEnvelope; //Frequency Envelope
+
+ LFOParams *FreqLfo;//Frequency LFO
+
+ /********************************************
+ * AMPLITUDE GLOBAL PARAMETERS *
+ ********************************************/
+
+ /* Panning - 0 - random
+ 1 - left
+ 64 - center
+ 127 - right */
+ unsigned char PPanning;
+
+ unsigned char PVolume;
+
+ unsigned char PAmpVelocityScaleFunction;
+
+ EnvelopeParams *AmpEnvelope;
+
+ LFOParams *AmpLfo;
+
+ unsigned char PPunchStrength,PPunchTime,PPunchStretch,PPunchVelocitySensing;
+
+ /******************************************
+ * FILTER GLOBAL PARAMETERS *
+ ******************************************/
+ FilterParams *GlobalFilter;
+
+ // filter velocity sensing
+ unsigned char PFilterVelocityScale;
+
+ // filter velocity sensing
+ unsigned char PFilterVelocityScaleFunction;
+
+ EnvelopeParams *FilterEnvelope;
+
+ LFOParams *FilterLfo;
+
+ // RESONANCE
+ Resonance *Reson;
+
+ //how the randomness is applied to the harmonics on more voices using the same oscillator
+ unsigned char Hrandgrouping;
+ };
+
+
+
+ /***********************************************************/
+ /* VOICE PARAMETERS */
+ /***********************************************************/
+ struct ADnoteVoiceParam{
+
+ /* If the voice is enabled */
+ unsigned char Enabled;
+
+ /* Type of the voice (0=Sound,1=Noise)*/
+ unsigned char Type;
+
+ /* Voice Delay */
+ unsigned char PDelay;
+
+ /* If the resonance is enabled for this voice */
+ unsigned char Presonance;
+
+ // What external oscil should I use, -1 for internal OscilSmp&FMSmp
+ short int Pextoscil,PextFMoscil;
+ // it is not allowed that the externoscil,externFMoscil => current voice
+
+ // oscillator phases
+ unsigned char Poscilphase,PFMoscilphase;
+
+ // filter bypass
+ unsigned char Pfilterbypass;
+
+ /* Voice oscillator */
+ OscilGen *OscilSmp;
+
+ /**********************************
+ * FREQUENCY PARAMETERS *
+ **********************************/
+
+ /* If the base frequency is fixed to 440 Hz*/
+ unsigned char Pfixedfreq;
+
+ /* Equal temperate (this is used only if the Pfixedfreq is enabled)
+ If this parameter is 0, the frequency is fixed (to 440 Hz);
+ if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
+ unsigned char PfixedfreqET;
+
+ /* Fine detune */
+ unsigned short int PDetune;
+
+ /* Coarse detune + octave */
+ unsigned short int PCoarseDetune;
+
+ /* Detune type */
+ unsigned char PDetuneType;
+
+ /* Frequency Envelope */
+ unsigned char PFreqEnvelopeEnabled;
+ EnvelopeParams *FreqEnvelope;
+
+ /* Frequency LFO */
+ unsigned char PFreqLfoEnabled;
+ LFOParams *FreqLfo;
+
+
+ /***************************
+ * AMPLITUDE PARAMETERS *
+ ***************************/
+
+ /* Panning 0 - random
+ 1 - left
+ 64 - center
+ 127 - right
+ The Panning is ignored if the instrument is mono */
+ unsigned char PPanning;
+
+ /* Voice Volume */
+ unsigned char PVolume;
+
+ /* If the Volume negative */
+ unsigned char PVolumeminus;
+
+ /* Velocity sensing */
+ unsigned char PAmpVelocityScaleFunction;
+
+ /* Amplitude Envelope */
+ unsigned char PAmpEnvelopeEnabled;
+ EnvelopeParams *AmpEnvelope;
+
+ /* Amplitude LFO */
+ unsigned char PAmpLfoEnabled;
+ LFOParams *AmpLfo;
+
+
+
+ /*************************
+ * FILTER PARAMETERS *
+ *************************/
+
+ /* Voice Filter */
+ unsigned char PFilterEnabled;
+ FilterParams *VoiceFilter;
+
+ /* Filter Envelope */
+ unsigned char PFilterEnvelopeEnabled;
+ EnvelopeParams *FilterEnvelope;
+
+ /* LFO Envelope */
+ unsigned char PFilterLfoEnabled;
+ LFOParams *FilterLfo;
+
+ /****************************
+ * MODULLATOR PARAMETERS *
+ ****************************/
+
+ /* Modullator Parameters (0=off,1=Morph,2=RM,3=PM,4=FM.. */
+ unsigned char PFMEnabled;
+
+ /* Voice that I use as modullator instead of FMSmp.
+ It is -1 if I use FMSmp(default).
+ It maynot be equal or bigger than current voice */
+ short int PFMVoice;
+
+ /* Modullator oscillator */
+ OscilGen *FMSmp;
+
+ /* Modullator Volume */
+ unsigned char PFMVolume;
+
+ /* Modullator damping at higher frequencies */
+ unsigned char PFMVolumeDamp;
+
+ /* Modullator Velocity Sensing */
+ unsigned char PFMVelocityScaleFunction;
+
+ /* Fine Detune of the Modullator*/
+ unsigned short int PFMDetune;
+
+ /* Coarse Detune of the Modullator */
+ unsigned short int PFMCoarseDetune;
+
+ /* The detune type */
+ unsigned char PFMDetuneType;
+
+ /* Frequency Envelope of the Modullator */
+ unsigned char PFMFreqEnvelopeEnabled;
+ EnvelopeParams *FMFreqEnvelope;
+
+ /* Frequency Envelope of the Modullator */
+ unsigned char PFMAmpEnvelopeEnabled;
+ EnvelopeParams *FMAmpEnvelope;
+ };
+
+class ADnoteParameters:public Presets{
+ public:
+ ADnoteParameters(FFTwrapper *fft_);
+ ~ADnoteParameters();
+
+ ADnoteGlobalParam GlobalPar;
+ ADnoteVoiceParam VoicePar[NUM_VOICES];
+
+ void defaults();
+ void add2XML(XMLwrapper *xml);
+ void getfromXML(XMLwrapper *xml);
+
+ REALTYPE getBandwidthDetuneMultiplier();
+ private:
+ void defaults(int n);//n is the nvoice
+
+ void EnableVoice(int nvoice);
+ void KillVoice(int nvoice);
+ FFTwrapper *fft;
+
+ void add2XMLsection(XMLwrapper *xml,int n);
+ void getfromXMLsection(XMLwrapper *xml,int n);
+};
+
+#endif
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.C
new file mode 100644
index 00000000..30f59161
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.C
@@ -0,0 +1,300 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Controller.C - (Midi) Controllers implementation
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include "Controller.h"
+#include <math.h>
+#include <stdio.h>
+
+Controller::Controller(){
+ defaults();
+ resetall();
+};
+
+Controller::~Controller(){
+};
+
+void Controller::defaults(){
+ setpitchwheelbendrange(200);//2 halftones
+ expression.receive=1;
+ panning.depth=64;
+ filtercutoff.depth=64;
+ filterq.depth=64;
+ bandwidth.depth=64;
+ bandwidth.exponential=0;
+ modwheel.depth=80;
+ modwheel.exponential=0;
+ fmamp.receive=1;
+ volume.receive=0;
+ sustain.receive=1;
+ NRPN.receive=1;
+
+ portamento.portamento=0;
+ portamento.used=0;
+ portamento.receive=1;
+ portamento.time=64;
+ portamento.updowntimestretch=64;
+ portamento.pitchthresh=3;
+ portamento.pitchthreshtype=1;
+ portamento.noteusing=-1;
+ resonancecenter.depth=64;
+ resonancebandwidth.depth=64;
+
+ initportamento(440.0,440.0);
+ setportamento(0);
+
+};
+
+void Controller::resetall(){
+ setpitchwheel(0);//center
+ setexpression(127);
+ setpanning(64);
+ setfiltercutoff(64);
+ setfilterq(64);
+ setbandwidth(64);
+ setmodwheel(64);
+ setfmamp(127);
+ setvolume(127);
+ setsustain(0);
+ setresonancecenter(64);
+ setresonancebw(64);
+
+ //reset the NRPN
+ NRPN.parhi=-1;
+ NRPN.parlo=-1;
+ NRPN.valhi=-1;
+ NRPN.vallo=-1;
+};
+
+void Controller::setpitchwheel(int value){
+ pitchwheel.data=value;
+ REALTYPE cents=value/8192.0;
+ cents*=pitchwheel.bendrange;
+ pitchwheel.relfreq=pow(2,cents/1200.0);
+ //fprintf(stderr,"%ld %ld -> %.3f\n",pitchwheel.bendrange,pitchwheel.data,pitchwheel.relfreq);fflush(stderr);
+};
+
+void Controller::setpitchwheelbendrange(unsigned short int value){
+ pitchwheel.bendrange=value;
+};
+
+void Controller::setexpression(int value){
+ expression.data=value;
+ if (expression.receive!=0) expression.relvolume=value/127.0;
+ else expression.relvolume=1.0;
+};
+
+void Controller::setpanning(int value){
+ panning.data=value;
+ panning.pan=(value/128.0-0.5)*(panning.depth/64.0);
+};
+
+void Controller::setfiltercutoff(int value){
+ filtercutoff.data=value;
+ filtercutoff.relfreq=(value-64.0)*filtercutoff.depth/4096.0*3.321928;//3.3219..=ln2(10)
+};
+
+void Controller::setfilterq(int value){
+ filterq.data=value;
+ filterq.relq=pow(30.0,(value-64.0)/64.0*(filterq.depth/64.0));
+};
+
+void Controller::setbandwidth(int value){
+ bandwidth.data=value;
+ if (bandwidth.exponential==0) {
+ REALTYPE tmp=pow(25.0,pow(bandwidth.depth/127.0,1.5))-1.0;
+ if ((value<64)&&(bandwidth.depth>=64)) tmp=1.0;
+ bandwidth.relbw=(value/64.0-1.0)*tmp+1.0;
+ if (bandwidth.relbw<0.01) bandwidth.relbw=0.01;
+ } else {
+ bandwidth.relbw=pow(25.0,(value-64.0)/64.0*(bandwidth.depth/64.0));
+ };
+};
+
+void Controller::setmodwheel(int value){
+ modwheel.data=value;
+ if (modwheel.exponential==0) {
+ REALTYPE tmp=pow(25.0,pow(modwheel.depth/127.0,1.5)*2.0)/25.0;
+ if ((value<64)&&(modwheel.depth>=64)) tmp=1.0;
+ modwheel.relmod=(value/64.0-1.0)*tmp+1.0;
+ if (modwheel.relmod<0.0) modwheel.relmod=0.0;
+ } else modwheel.relmod=pow(25.0,(value-64.0)/64.0*(modwheel.depth/80.0));
+};
+
+void Controller::setfmamp(int value){
+ fmamp.data=value;
+ fmamp.relamp=value/127.0;
+ if (fmamp.receive!=0) fmamp.relamp=value/127.0;
+ else fmamp.relamp=1.0;
+};
+
+void Controller::setvolume(int value){
+ volume.data=value;
+ if (volume.receive!=0) volume.volume=pow(0.1,(127-value)/127.0*2.0);
+ else volume.volume=1.0;
+};
+
+void Controller::setsustain(int value){
+ sustain.data=value;
+ if (sustain.receive!=0) sustain.sustain=((value<64) ? 0 : 1 );
+ else sustain.sustain=0;
+};
+
+void Controller::setportamento(int value){
+ portamento.data=value;
+ if (portamento.receive!=0) portamento.portamento=((value<64) ? 0 : 1 );
+};
+
+int Controller::initportamento(REALTYPE oldfreq,REALTYPE newfreq){
+ portamento.x=0.0;
+ if ((portamento.used!=0) || (portamento.portamento==0)) return(0);
+ REALTYPE portamentotime=pow(100.0,portamento.time/127.0)/50.0;//portamento time in seconds
+
+ if ((portamento.updowntimestretch>=64)&&(newfreq<oldfreq)){
+ if (portamento.updowntimestretch==127) return(0);
+ portamentotime*=pow(0.1,(portamento.updowntimestretch-64)/63.0);
+ }
+ if ((portamento.updowntimestretch<64)&&(newfreq>oldfreq)){
+ if (portamento.updowntimestretch==0) return(0);
+ portamentotime*=pow(0.1,(64.0-portamento.updowntimestretch)/64.0);
+ };
+
+ portamento.dx=SOUND_BUFFER_SIZE/(portamentotime*SAMPLE_RATE);
+ portamento.origfreqrap=oldfreq/newfreq;
+
+ REALTYPE tmprap=( (portamento.origfreqrap>1.0) ?
+ (portamento.origfreqrap) :
+ (1.0/portamento.origfreqrap) );
+
+ REALTYPE thresholdrap=pow(2.0,portamento.pitchthresh/12.0);
+ if ((portamento.pitchthreshtype==0) && (tmprap-0.00001>thresholdrap) ) return(0);
+ if ((portamento.pitchthreshtype==1) && (tmprap+0.00001<thresholdrap) ) return(0);
+
+ portamento.used=1;
+ portamento.freqrap=portamento.origfreqrap;
+ return (1);
+};
+
+void Controller::updateportamento(){
+ if (portamento.used==0) return;
+
+ portamento.x+=portamento.dx;
+ if (portamento.x>1.0) {
+ portamento.x=1.0;
+ portamento.used=0;
+ };
+ portamento.freqrap=(1.0-portamento.x)*portamento.origfreqrap+portamento.x;
+};
+
+
+void Controller::setresonancecenter(int value){
+ resonancecenter.data=value;
+ resonancecenter.relcenter=pow(3.0,(value-64.0)/64.0*(resonancecenter.depth/64.0));
+};
+void Controller::setresonancebw(int value){
+ resonancebandwidth.data=value;
+ resonancebandwidth.relbw=pow(1.5,(value-64.0)/64.0*(resonancebandwidth.depth/127.0));
+};
+
+
+//Returns 0 if there is NRPN or 1 if there is not
+int Controller::getnrpn(int *parhi, int *parlo, int *valhi, int *vallo){
+ if (NRPN.receive==0) return(1);
+ if ((NRPN.parhi<0)||(NRPN.parlo<0)||(NRPN.valhi<0)||(NRPN.vallo<0))
+ return(1);
+
+ *parhi=NRPN.parhi;
+ *parlo=NRPN.parlo;
+ *valhi=NRPN.valhi;
+ *vallo=NRPN.vallo;
+ return(0);
+};
+
+
+void Controller::setparameternumber(unsigned int type,int value){
+ switch(type){
+ case C_nrpnhi:NRPN.parhi=value;
+ NRPN.valhi=-1;NRPN.vallo=-1;//clear the values
+ break;
+ case C_nrpnlo:NRPN.parlo=value;
+ NRPN.valhi=-1;NRPN.vallo=-1;//clear the values
+ break;
+ case C_dataentryhi:if ((NRPN.parhi>=0)&&(NRPN.parlo>=0)) NRPN.valhi=value;
+ break;
+ case C_dataentrylo:if ((NRPN.parhi>=0)&&(NRPN.parlo>=0)) NRPN.vallo=value;
+ break;
+ };
+};
+
+
+
+void Controller::add2XML(XMLwrapper *xml){
+ xml->addpar("pitchwheel_bendrange",pitchwheel.bendrange);
+
+ xml->addparbool("expression_receive",expression.receive);
+ xml->addpar("panning_depth",panning.depth);
+ xml->addpar("filter_cutoff_depth",filtercutoff.depth);
+ xml->addpar("filter_q_depth",filterq.depth);
+ xml->addpar("bandwidth_depth",bandwidth.depth);
+ xml->addpar("mod_wheel_depth",modwheel.depth);
+ xml->addparbool("mod_wheel_exponential",modwheel.exponential);
+ xml->addparbool("fm_amp_receive",fmamp.receive);
+ xml->addparbool("volume_receive",volume.receive);
+ xml->addparbool("sustain_receive",sustain.receive);
+
+ xml->addparbool("portamento_receive",portamento.receive);
+ xml->addpar("portamento_time",portamento.time);
+ xml->addpar("portamento_pitchthresh",portamento.pitchthresh);
+ xml->addpar("portamento_pitchthreshtype",portamento.pitchthreshtype);
+ xml->addpar("portamento_portamento",portamento.portamento);
+ xml->addpar("portamento_updowntimestretch",portamento.updowntimestretch);
+
+ xml->addpar("resonance_center_depth",resonancecenter.depth);
+ xml->addpar("resonance_bandwidth_depth",resonancebandwidth.depth);
+};
+
+void Controller::getfromXML(XMLwrapper *xml){
+ pitchwheel.bendrange=xml->getpar("pitchwheel_bendrange",pitchwheel.bendrange,-6400,6400);
+
+ expression.receive=xml->getparbool("expression_receive",expression.receive);
+ panning.depth=xml->getpar127("panning_depth",panning.depth);
+ filtercutoff.depth=xml->getpar127("filter_cutoff_depth",filtercutoff.depth);
+ filterq.depth=xml->getpar127("filter_q_depth",filterq.depth);
+ bandwidth.depth=xml->getpar127("bandwidth_depth",bandwidth.depth);
+ modwheel.depth=xml->getpar127("mod_wheel_depth",modwheel.depth);
+ modwheel.exponential=xml->getparbool("mod_wheel_exponential",modwheel.exponential);
+ fmamp.receive=xml->getparbool("fm_amp_receive",fmamp.receive);
+ volume.receive=xml->getparbool("volume_receive",volume.receive);
+ sustain.receive=xml->getparbool("sustain_receive",sustain.receive);
+
+ portamento.receive=xml->getparbool("portamento_receive",portamento.receive);
+ portamento.time=xml->getpar127("portamento_time",portamento.time);
+ portamento.pitchthresh=xml->getpar127("portamento_pitchthresh",portamento.pitchthresh);
+ portamento.pitchthreshtype=xml->getpar127("portamento_pitchthreshtype",portamento.pitchthreshtype);
+ portamento.portamento=xml->getpar127("portamento_portamento",portamento.portamento);
+ portamento.updowntimestretch=xml->getpar127("portamento_updowntimestretch",portamento.updowntimestretch);
+
+ resonancecenter.depth=xml->getpar127("resonance_center_depth",resonancecenter.depth);
+ resonancebandwidth.depth=xml->getpar127("resonance_bandwidth_depth",resonancebandwidth.depth);
+};
+
+
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.h
new file mode 100644
index 00000000..12257b59
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Controller.h
@@ -0,0 +1,179 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Controller.h - (Midi) Controllers implementation
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+
+#ifndef CONTROLLER_H
+#define CONTROLLER_H
+
+#include "../globals.h"
+#include "../Misc/XMLwrapper.h"
+
+class Controller{
+ public:
+ Controller();
+ ~Controller();
+ void resetall();
+
+ void add2XML(XMLwrapper *xml);
+ void defaults();
+ void getfromXML(XMLwrapper *xml);
+
+ //Controllers functions
+ void setpitchwheel(int value);
+ void setpitchwheelbendrange(unsigned short int value);
+ void setexpression(int value);
+ void setpanning(int value);
+ void setfiltercutoff(int value);
+ void setfilterq(int value);
+ void setbandwidth(int value);
+ void setmodwheel(int value);
+ void setfmamp(int value);
+ void setvolume(int value);
+ void setsustain(int value);
+ void setportamento(int value);
+ void setresonancecenter(int value);
+ void setresonancebw(int value);
+
+
+ void setparameternumber(unsigned int type,int value);//used for RPN and NRPN's
+ int getnrpn(int *parhi, int *parlo, int *valhi, int *vallo);
+
+ int initportamento(REALTYPE oldfreq,REALTYPE newfreq);//returns 1 if the portamento's conditions are true, else return 0
+ void updateportamento(); //update portamento values
+
+ // Controllers values
+ struct {//Pitch Wheel
+ int data;
+ short int bendrange;//bendrange is in cents
+ REALTYPE relfreq;//the relative frequency (default is 1.0)
+ } pitchwheel;
+
+ struct{//Expression
+ int data;
+ REALTYPE relvolume;
+ unsigned char receive;
+ } expression;
+
+ struct{//Panning
+ int data;
+ REALTYPE pan;
+ unsigned char depth;
+ } panning;
+
+
+ struct{//Filter cutoff
+ int data;
+ REALTYPE relfreq;
+ unsigned char depth;
+ } filtercutoff;
+
+ struct{//Filter Q
+ int data;
+ REALTYPE relq;
+ unsigned char depth;
+ } filterq;
+
+ struct{//Bandwidth
+ int data;
+ REALTYPE relbw;
+ unsigned char depth;
+ unsigned char exponential;
+ } bandwidth;
+
+ struct {//Modulation Wheel
+ int data;
+ REALTYPE relmod;
+ unsigned char depth;
+ unsigned char exponential;
+ } modwheel;
+
+ struct{//FM amplitude
+ int data;
+ REALTYPE relamp;
+ unsigned char receive;
+ } fmamp;
+
+ struct{//Volume
+ int data;
+ REALTYPE volume;
+ unsigned char receive;
+ } volume;
+
+ struct{//Sustain
+ int data,sustain;
+ unsigned char receive;
+ } sustain;
+
+ struct{//Portamento
+ //parameters
+ int data;
+ unsigned char portamento;
+
+ //pitchthresh is the threshold of enabling protamento
+ //pitchthreshtype -> enable the portamento only below(0)/above(1) the threshold
+ unsigned char receive,time,pitchthresh,pitchthreshtype;
+
+ //'up portanemto' means when the frequency is rising (eg: the portamento is from 200Hz to 300 Hz)
+ //'down portanemto' means when the frequency is lowering (eg: the portamento is from 300Hz to 200 Hz)
+ unsigned char updowntimestretch;//this value represent how the portamento time is reduced
+ //0 - for down portamento, 1..63 - the up portamento's time is smaller than the down portamento
+ //64 - the portamento time is always the same
+ //64-126 - the down portamento's time is smaller than the up portamento
+ //127 - for upper portamento
+
+ REALTYPE freqrap;//this value is used to compute the actual portamento
+ int noteusing;//this is used by the Part:: for knowing which note uses the portamento
+ int used;//if a the portamento is used by a note
+ //internal data
+ REALTYPE x,dx;//x is from 0.0 (start portamento) to 1.0 (finished portamento), dx is x increment
+ REALTYPE origfreqrap;// this is used for computing oldfreq value from x
+ } portamento;
+
+ struct{//Resonance Center Frequency
+ int data;
+ REALTYPE relcenter;
+ unsigned char depth;
+ } resonancecenter;
+
+ struct{//Resonance Bandwidth
+ int data;
+ REALTYPE relbw;
+ unsigned char depth;
+ } resonancebandwidth;
+
+
+ /* RPN and NPRPN */
+ struct{//nrpn
+ int parhi,parlo;
+ int valhi,vallo;
+ unsigned char receive;//this is saved to disk by Master
+ } NRPN;
+
+ private:
+};
+
+
+
+
+
+#endif
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.C
new file mode 100644
index 00000000..074d6aee
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.C
@@ -0,0 +1,227 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ EnvelopeParams.C - Parameters for Envelope
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include <stdio.h>
+
+#include <math.h>
+#include <stdlib.h>
+#include "EnvelopeParams.h"
+
+EnvelopeParams::EnvelopeParams(unsigned char Penvstretch_,unsigned char Pforcedrelease_):Presets(){
+ int i;
+
+ PA_dt=10;PD_dt=10;PR_dt=10;PA_val=64;PD_val=64;PS_val=64;PR_val=64;
+
+ for (i=0;i<MAX_ENVELOPE_POINTS;i++){
+ Penvdt[i]=32;
+ Penvval[i]=64;
+ };
+ Penvdt[0]=0;//no used
+ Penvsustain=1;
+ Penvpoints=1;
+ Envmode=1;
+ Penvstretch=Penvstretch_;
+ Pforcedrelease=Pforcedrelease_;
+ Pfreemode=1;
+ Plinearenvelope=0;
+
+ store2defaults();
+};
+
+EnvelopeParams::~EnvelopeParams(){
+};
+
+REALTYPE EnvelopeParams::getdt(char i){
+ REALTYPE result=(pow(2.0,Penvdt[i]/127.0*12.0)-1.0)*10.0;//miliseconds
+ return(result);
+};
+
+
+/*
+ * ADSR/ASR... initialisations
+ */
+void EnvelopeParams::ADSRinit(char A_dt,char D_dt,char S_val,char R_dt){
+ setpresettype("Penvamplitude");
+ Envmode=1;
+ PA_dt=A_dt;PD_dt=D_dt;PS_val=S_val;PR_dt=R_dt;
+ Pfreemode=0;
+ converttofree();
+
+ store2defaults();
+};
+
+void EnvelopeParams::ADSRinit_dB(char A_dt,char D_dt,char S_val,char R_dt){
+ setpresettype("Penvamplitude");
+ Envmode=2;
+ PA_dt=A_dt;PD_dt=D_dt;PS_val=S_val;PR_dt=R_dt;
+ Pfreemode=0;
+ converttofree();
+
+ store2defaults();
+};
+
+void EnvelopeParams::ASRinit(char A_val,char A_dt,char R_val,char R_dt){
+ setpresettype("Penvfrequency");
+ Envmode=3;
+ PA_val=A_val;PA_dt=A_dt;PR_val=R_val;PR_dt=R_dt;
+ Pfreemode=0;
+ converttofree();
+
+ store2defaults();
+};
+
+void EnvelopeParams::ADSRinit_filter(char A_val,char A_dt,char D_val,char D_dt,char R_dt,char R_val){
+ setpresettype("Penvfilter");
+ Envmode=4;
+ PA_val=A_val;PA_dt=A_dt;PD_val=D_val;PD_dt=D_dt;PR_dt=R_dt;PR_val=R_val;
+ Pfreemode=0;
+ converttofree();
+ store2defaults();
+};
+
+void EnvelopeParams::ASRinit_bw(char A_val,char A_dt,char R_val,char R_dt){
+ setpresettype("Penvbandwidth");
+ Envmode=5;
+ PA_val=A_val;PA_dt=A_dt;PR_val=R_val;PR_dt=R_dt;
+ Pfreemode=0;
+ converttofree();
+ store2defaults();
+};
+
+/*
+ * Convert the Envelope to freemode
+ */
+void EnvelopeParams::converttofree(){
+ switch (Envmode){
+ case 1: Penvpoints=4;Penvsustain=2;
+ Penvval[0]=0;Penvdt[1]=PA_dt;Penvval[1]=127;
+ Penvdt[2]=PD_dt;Penvval[2]=PS_val;
+ Penvdt[3]=PR_dt;Penvval[3]=0;
+ break;
+ case 2: Penvpoints=4;Penvsustain=2;
+ Penvval[0]=0;Penvdt[1]=PA_dt;
+ Penvval[1]=127;Penvdt[2]=PD_dt;
+ Penvval[2]=PS_val;Penvdt[3]=PR_dt;Penvval[3]=0;
+ break;
+ case 3: Penvpoints=3;Penvsustain=1;
+ Penvval[0]=PA_val;Penvdt[1]=PA_dt;
+ Penvval[1]=64;Penvdt[2]=PR_dt;Penvval[2]=PR_val;
+ break;
+ case 4: Penvpoints=4;Penvsustain=2;
+ Penvval[0]=PA_val;Penvdt[1]=PA_dt;
+ Penvval[1]=PD_val;Penvdt[2]=PD_dt;Penvval[2]=64;
+ Penvdt[3]=PR_dt;Penvval[3]=PR_val;
+ break;
+ case 5: Penvpoints=3;Penvsustain=1;
+ Penvval[0]=PA_val;Penvdt[1]=PA_dt;
+ Penvval[1]=64;Penvdt[2]=PR_dt;Penvval[2]=PR_val;
+ break;
+ };
+};
+
+
+
+
+void EnvelopeParams::add2XML(XMLwrapper *xml){
+ xml->addparbool("free_mode",Pfreemode);
+ xml->addpar("env_points",Penvpoints);
+ xml->addpar("env_sustain",Penvsustain);
+ xml->addpar("env_stretch",Penvstretch);
+ xml->addparbool("forced_release",Pforcedrelease);
+ xml->addparbool("linear_envelope",Plinearenvelope);
+ xml->addpar("A_dt",PA_dt);
+ xml->addpar("D_dt",PD_dt);
+ xml->addpar("R_dt",PR_dt);
+ xml->addpar("A_val",PA_val);
+ xml->addpar("D_val",PD_val);
+ xml->addpar("S_val",PS_val);
+ xml->addpar("R_val",PR_val);
+
+ if ((Pfreemode!=0)||(!xml->minimal)){
+ for (int i=0;i<Penvpoints;i++){
+ xml->beginbranch("POINT",i);
+ if (i!=0) xml->addpar("dt",Penvdt[i]);
+ xml->addpar("val",Penvval[i]);
+ xml->endbranch();
+ };
+ };
+};
+
+
+
+void EnvelopeParams::getfromXML(XMLwrapper *xml){
+ Pfreemode=xml->getparbool("free_mode",Pfreemode);
+ Penvpoints=xml->getpar127("env_points",Penvpoints);
+ Penvsustain=xml->getpar127("env_sustain",Penvsustain);
+ Penvstretch=xml->getpar127("env_stretch",Penvstretch);
+ Pforcedrelease=xml->getparbool("forced_release",Pforcedrelease);
+ Plinearenvelope=xml->getparbool("linear_envelope",Plinearenvelope);
+
+ PA_dt=xml->getpar127("A_dt",PA_dt);
+ PD_dt=xml->getpar127("D_dt",PD_dt);
+ PR_dt=xml->getpar127("R_dt",PR_dt);
+ PA_val=xml->getpar127("A_val",PA_val);
+ PD_val=xml->getpar127("D_val",PD_val);
+ PS_val=xml->getpar127("S_val",PS_val);
+ PR_val=xml->getpar127("R_val",PR_val);
+
+ for (int i=0;i<Penvpoints;i++){
+ if (xml->enterbranch("POINT",i)==0) continue;
+ if (i!=0) Penvdt[i]=xml->getpar127("dt",Penvdt[i]);
+ Penvval[i]=xml->getpar127("val",Penvval[i]);
+ xml->exitbranch();
+ };
+
+ if (!Pfreemode) converttofree();
+};
+
+
+void EnvelopeParams::defaults(){
+ Penvstretch=Denvstretch;
+ Pforcedrelease=Dforcedrelease;
+ Plinearenvelope=Dlinearenvelope;
+ PA_dt=DA_dt;
+ PD_dt=DD_dt;
+ PR_dt=DR_dt;
+ PA_val=DA_val;
+ PD_val=DD_val;
+ PS_val=DS_val;
+ PR_val=DR_val;
+ Pfreemode=0;
+ converttofree();
+};
+
+void EnvelopeParams::store2defaults(){
+ Denvstretch=Penvstretch;
+ Dforcedrelease=Pforcedrelease;
+ Dlinearenvelope=Plinearenvelope;
+ DA_dt=PA_dt;
+ DD_dt=PD_dt;
+ DR_dt=PR_dt;
+ DA_val=PA_val;
+ DD_val=PD_val;
+ DS_val=PS_val;
+ DR_val=PR_val;
+};
+
+
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.h
new file mode 100644
index 00000000..793291c6
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/EnvelopeParams.h
@@ -0,0 +1,86 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ EnvelopeParams.h - Parameters for Envelope
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef ENVELOPE_PARAMS_H
+#define ENVELOPE_PARAMS_H
+
+#include "../globals.h"
+#include "../Misc/XMLwrapper.h"
+#include "Presets.h"
+
+#define MAX_ENVELOPE_POINTS 40
+#define MIN_ENVELOPE_DB -40
+
+class EnvelopeParams:public Presets{
+ public:
+ EnvelopeParams(unsigned char Penvstretch_,unsigned char Pforcedrelease_);
+ ~EnvelopeParams();
+ void ADSRinit(char A_dt,char D_dt,char S_val,char R_dt);
+ void ADSRinit_dB(char A_dt,char D_dt,char S_val,char R_dt);
+ void ASRinit(char A_val,char A_dt,char R_val,char R_dt);
+ void ADSRinit_filter(char A_val,char A_dt,char D_val,char D_dt,char R_dt,char R_val);
+ void ASRinit_bw(char A_val,char A_dt,char R_val,char R_dt);
+ void converttofree();
+
+ void add2XML(XMLwrapper *xml);
+ void defaults();
+ void getfromXML(XMLwrapper *xml);
+
+ REALTYPE getdt(char i);
+
+ /* Parametrii MIDI */
+ unsigned char Pfreemode;//1 daca este in modul free sau 0 daca este in mod ADSR,ASR,...
+ unsigned char Penvpoints;
+ unsigned char Penvsustain;//127 pentru dezactivat
+ unsigned char Penvdt[MAX_ENVELOPE_POINTS];
+ unsigned char Penvval[MAX_ENVELOPE_POINTS];
+ unsigned char Penvstretch;//64=normal stretch (piano-like), 0=no stretch
+ unsigned char Pforcedrelease;//0 - OFF, 1 - ON
+ unsigned char Plinearenvelope;//if the amplitude envelope is linear
+
+ unsigned char PA_dt,PD_dt,PR_dt,
+ PA_val,PD_val,PS_val,PR_val;
+
+
+
+ int Envmode;// 1 for ADSR parameters (linear amplitude)
+ // 2 for ADSR_dB parameters (dB amplitude)
+ // 3 for ASR parameters (frequency LFO)
+ // 4 for ADSR_filter parameters (filter parameters)
+ // 5 for ASR_bw parameters (bandwidth parameters)
+
+ private:
+ void store2defaults();
+
+ /* Default parameters */
+ unsigned char Denvstretch;
+ unsigned char Dforcedrelease;
+ unsigned char Dlinearenvelope;
+ unsigned char DA_dt,DD_dt,DR_dt,
+ DA_val,DD_val,DS_val,DR_val;
+
+
+};
+
+
+#endif
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.C
new file mode 100644
index 00000000..073f6711
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.C
@@ -0,0 +1,344 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ FilterParams.C - Parameters for filter
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include <math.h>
+#include <stdio.h>
+#include <stdlib.h>
+#include "FilterParams.h"
+
+FilterParams::FilterParams(unsigned char Ptype_,unsigned char Pfreq_,unsigned char Pq_):Presets(){
+ setpresettype("Pfilter");
+ Dtype=Ptype_;
+ Dfreq=Pfreq_;
+ Dq=Pq_;
+
+ changed=false;
+ defaults();
+};
+
+FilterParams::~FilterParams(){
+};
+
+
+void FilterParams::defaults(){
+ Ptype=Dtype;
+ Pfreq=Dfreq;
+ Pq=Dq;
+
+ Pstages=0;
+ Pfreqtrack=64;
+ Pgain=64;
+ Pcategory=0;
+
+ Pnumformants=3;
+ Pformantslowness=64;
+ for (int j=0;j<FF_MAX_VOWELS;j++){
+ defaults(j);
+ };
+
+ Psequencesize=3;
+ for (int i=0;i<FF_MAX_SEQUENCE;i++) Psequence[i].nvowel=i%FF_MAX_VOWELS;
+
+ Psequencestretch=40;
+ Psequencereversed=0;
+ Pcenterfreq=64;//1 kHz
+ Poctavesfreq=64;
+ Pvowelclearness=64;
+};
+
+void FilterParams::defaults(int n){
+ int j=n;
+ for (int i=0;i<FF_MAX_FORMANTS;i++){
+ Pvowels[j].formants[i].freq=(int)(RND*127.0);//some random freqs
+ Pvowels[j].formants[i].q=64;
+ Pvowels[j].formants[i].amp=127;
+ };
+};
+
+
+/*
+ * Get the parameters from other FilterParams
+ */
+
+void FilterParams::getfromFilterParams(FilterParams *pars){
+ defaults();
+
+ if (pars==NULL) return;
+
+ Ptype=pars->Ptype;
+ Pfreq=pars->Pfreq;
+ Pq=pars->Pq;
+
+ Pstages=pars->Pstages;
+ Pfreqtrack=pars->Pfreqtrack;
+ Pgain=pars->Pgain;
+ Pcategory=pars->Pcategory;
+
+ Pnumformants=pars->Pnumformants;
+ Pformantslowness=pars->Pformantslowness;
+ for (int j=0;j<FF_MAX_VOWELS;j++){
+ for (int i=0;i<FF_MAX_FORMANTS;i++){
+ Pvowels[j].formants[i].freq=pars->Pvowels[j].formants[i].freq;
+ Pvowels[j].formants[i].q=pars->Pvowels[j].formants[i].q;
+ Pvowels[j].formants[i].amp=pars->Pvowels[j].formants[i].amp;
+ };
+ };
+
+ Psequencesize=pars->Psequencesize;
+ for (int i=0;i<FF_MAX_SEQUENCE;i++) Psequence[i].nvowel=pars->Psequence[i].nvowel;
+
+ Psequencestretch=pars->Psequencestretch;
+ Psequencereversed=pars->Psequencereversed;
+ Pcenterfreq=pars->Pcenterfreq;
+ Poctavesfreq=pars->Poctavesfreq;
+ Pvowelclearness=pars->Pvowelclearness;
+};
+
+
+/*
+ * Parameter control
+ */
+REALTYPE FilterParams::getfreq(){
+ return((Pfreq/64.0-1.0)*5.0);
+};
+
+REALTYPE FilterParams::getq(){
+ return(exp(pow((REALTYPE) Pq/127.0,2)*log(1000.0))-0.9);
+};
+REALTYPE FilterParams::getfreqtracking(REALTYPE notefreq){
+ return(log(notefreq/440.0)*(Pfreqtrack-64.0)/(64.0*LOG_2));
+};
+
+REALTYPE FilterParams::getgain(){
+ return((Pgain/64.0-1.0)*30.0);//-30..30dB
+};
+
+/*
+ * Get the center frequency of the formant's graph
+ */
+REALTYPE FilterParams::getcenterfreq(){
+ return(10000.0*pow(10,-(1.0-Pcenterfreq/127.0)*2.0));
+};
+
+/*
+ * Get the number of octave that the formant functions applies to
+ */
+REALTYPE FilterParams::getoctavesfreq(){
+ return(0.25+10.0*Poctavesfreq/127.0);
+};
+
+/*
+ * Get the frequency from x, where x is [0..1]
+ */
+REALTYPE FilterParams::getfreqx(REALTYPE x){
+ if (x>1.0) x=1.0;
+ REALTYPE octf=pow(2.0,getoctavesfreq());
+ return(getcenterfreq()/sqrt(octf)*pow(octf,x));
+};
+
+/*
+ * Get the x coordinate from frequency (used by the UI)
+ */
+REALTYPE FilterParams::getfreqpos(REALTYPE freq){
+ return((log(freq)-log(getfreqx(0.0)))/log(2.0)/getoctavesfreq());
+};
+
+
+/*
+ * Get the freq. response of the formant filter
+ */
+void FilterParams::formantfilterH(int nvowel,int nfreqs,REALTYPE *freqs){
+ REALTYPE c[3],d[3];
+ REALTYPE filter_freq,filter_q,filter_amp;
+ REALTYPE omega,sn,cs,alpha;
+
+ for (int i=0;i<nfreqs;i++) freqs[i]=0.0;
+
+ //for each formant...
+ for (int nformant=0;nformant<Pnumformants;nformant++){
+ //compute formant parameters(frequency,amplitude,etc.)
+ filter_freq=getformantfreq(Pvowels[nvowel].formants[nformant].freq);
+ filter_q=getformantq(Pvowels[nvowel].formants[nformant].q)*getq();
+ if (Pstages>0) filter_q=(filter_q>1.0 ? pow(filter_q,1.0/(Pstages+1)) : filter_q);
+
+ filter_amp=getformantamp(Pvowels[nvowel].formants[nformant].amp);
+
+
+ if (filter_freq<=(SAMPLE_RATE/2-100.0)){
+ omega=2*PI*filter_freq/SAMPLE_RATE;
+ sn=sin(omega);
+ cs=cos(omega);
+ alpha=sn/(2*filter_q);
+ REALTYPE tmp=1+alpha;
+ c[0]=alpha/tmp*sqrt(filter_q+1);
+ c[1]=0;
+ c[2]=-alpha/tmp*sqrt(filter_q+1);
+ d[1]=-2*cs/tmp*(-1);
+ d[2]=(1-alpha)/tmp*(-1);
+ } else continue;
+
+
+ for (int i=0;i<nfreqs;i++) {
+ REALTYPE freq=getfreqx(i/(REALTYPE) nfreqs);
+ if (freq>SAMPLE_RATE/2) {
+ for (int tmp=i;tmp<nfreqs;tmp++) freqs[tmp]=0.0;
+ break;
+ };
+ REALTYPE fr=freq/SAMPLE_RATE*PI*2.0;
+ REALTYPE x=c[0],y=0.0;
+ for (int n=1;n<3;n++){
+ x+=cos(n*fr)*c[n];
+ y-=sin(n*fr)*c[n];
+ };
+ REALTYPE h=x*x+y*y;
+ x=1.0;y=0.0;
+ for (int n=1;n<3;n++){
+ x-=cos(n*fr)*d[n];
+ y+=sin(n*fr)*d[n];
+ };
+ h=h/(x*x+y*y);
+
+ freqs[i]+=pow(h,(Pstages+1.0)/2.0)*filter_amp;
+ };
+ };
+ for (int i=0;i<nfreqs;i++) {
+ if (freqs[i]>0.000000001) freqs[i]=rap2dB(freqs[i])+getgain();
+ else freqs[i]=-90.0;
+ };
+
+};
+
+/*
+ * Transforms a parameter to the real value
+ */
+REALTYPE FilterParams::getformantfreq(unsigned char freq){
+ REALTYPE result=getfreqx(freq/127.0);
+ return(result);
+};
+
+REALTYPE FilterParams::getformantamp(unsigned char amp){
+ REALTYPE result=pow(0.1,(1.0-amp/127.0)*4.0);
+ return(result);
+};
+
+REALTYPE FilterParams::getformantq(unsigned char q){
+ //temp
+ REALTYPE result=pow(25.0,(q-32.0)/64.0);
+ return(result);
+};
+
+
+
+void FilterParams::add2XMLsection(XMLwrapper *xml,int n){
+ int nvowel=n;
+ for (int nformant=0;nformant<FF_MAX_FORMANTS;nformant++){
+ xml->beginbranch("FORMANT",nformant);
+ xml->addpar("freq",Pvowels[nvowel].formants[nformant].freq);
+ xml->addpar("amp",Pvowels[nvowel].formants[nformant].amp);
+ xml->addpar("q",Pvowels[nvowel].formants[nformant].q);
+ xml->endbranch();
+ };
+};
+
+void FilterParams::add2XML(XMLwrapper *xml){
+ //filter parameters
+ xml->addpar("category",Pcategory);
+ xml->addpar("type",Ptype);
+ xml->addpar("freq",Pfreq);
+ xml->addpar("q",Pq);
+ xml->addpar("stages",Pstages);
+ xml->addpar("freq_track",Pfreqtrack);
+ xml->addpar("gain",Pgain);
+
+ //formant filter parameters
+ if ((Pcategory==1)||(!xml->minimal)){
+ xml->beginbranch("FORMANT_FILTER");
+ xml->addpar("num_formants",Pnumformants);
+ xml->addpar("formant_slowness",Pformantslowness);
+ xml->addpar("vowel_clearness",Pvowelclearness);
+ xml->addpar("center_freq",Pcenterfreq);
+ xml->addpar("octaves_freq",Poctavesfreq);
+ for (int nvowel=0;nvowel<FF_MAX_VOWELS;nvowel++){
+ xml->beginbranch("VOWEL",nvowel);
+ add2XMLsection(xml,nvowel);
+ xml->endbranch();
+ };
+ xml->addpar("sequence_size",Psequencesize);
+ xml->addpar("sequence_stretch",Psequencestretch);
+ xml->addparbool("sequence_reversed",Psequencereversed);
+ for (int nseq=0;nseq<FF_MAX_SEQUENCE;nseq++){
+ xml->beginbranch("SEQUENCE_POS",nseq);
+ xml->addpar("vowel_id",Psequence[nseq].nvowel);
+ xml->endbranch();
+ };
+ xml->endbranch();
+ };
+};
+
+
+void FilterParams::getfromXMLsection(XMLwrapper *xml,int n){
+ int nvowel=n;
+ for (int nformant=0;nformant<FF_MAX_FORMANTS;nformant++){
+ if (xml->enterbranch("FORMANT",nformant)==0) continue;
+ Pvowels[nvowel].formants[nformant].freq=xml->getpar127("freq",Pvowels[nvowel].formants[nformant].freq);
+ Pvowels[nvowel].formants[nformant].amp=xml->getpar127("amp",Pvowels[nvowel].formants[nformant].amp);
+ Pvowels[nvowel].formants[nformant].q=xml->getpar127("q",Pvowels[nvowel].formants[nformant].q);
+ xml->exitbranch();
+ };
+};
+
+void FilterParams::getfromXML(XMLwrapper *xml){
+ //filter parameters
+ Pcategory=xml->getpar127("category",Pcategory);
+ Ptype=xml->getpar127("type",Ptype);
+ Pfreq=xml->getpar127("freq",Pfreq);
+ Pq=xml->getpar127("q",Pq);
+ Pstages=xml->getpar127("stages",Pstages);
+ Pfreqtrack=xml->getpar127("freq_track",Pfreqtrack);
+ Pgain=xml->getpar127("gain",Pgain);
+
+ //formant filter parameters
+ if(xml->enterbranch("FORMANT_FILTER")){
+ Pnumformants=xml->getpar127("num_formants",Pnumformants);
+ Pformantslowness=xml->getpar127("formant_slowness",Pformantslowness);
+ Pvowelclearness=xml->getpar127("vowel_clearness",Pvowelclearness);
+ Pcenterfreq=xml->getpar127("center_freq",Pcenterfreq);
+ Poctavesfreq=xml->getpar127("octaves_freq",Poctavesfreq);
+
+ for (int nvowel=0;nvowel<FF_MAX_VOWELS;nvowel++){
+ if (xml->enterbranch("VOWEL",nvowel)==0) continue;
+ getfromXMLsection(xml,nvowel);
+ xml->exitbranch();
+ };
+ Psequencesize=xml->getpar127("sequence_size",Psequencesize);
+ Psequencestretch=xml->getpar127("sequence_stretch",Psequencestretch);
+ Psequencereversed=xml->getparbool("sequence_reversed",Psequencereversed);
+ for (int nseq=0;nseq<FF_MAX_SEQUENCE;nseq++){
+ if (xml->enterbranch("SEQUENCE_POS",nseq)==0) continue;
+ Psequence[nseq].nvowel=xml->getpar("vowel_id",Psequence[nseq].nvowel,0,FF_MAX_VOWELS-1);
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+
+};
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.h
new file mode 100644
index 00000000..58ebd589
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/FilterParams.h
@@ -0,0 +1,100 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ FilterParams.h - Parameters for filter
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef FILTER_PARAMS_H
+#define FILTER_PARAMS_H
+
+#include "../globals.h"
+#include "../Misc/XMLwrapper.h"
+#include "Presets.h"
+
+class FilterParams:public Presets{
+ public:
+ FilterParams(unsigned char Ptype_,unsigned char Pfreq,unsigned char Pq_);
+ ~FilterParams();
+
+ void add2XML(XMLwrapper *xml);
+ void add2XMLsection(XMLwrapper *xml,int n);
+ void defaults();
+ void getfromXML(XMLwrapper *xml);
+ void getfromXMLsection(XMLwrapper *xml,int n);
+
+
+ void getfromFilterParams(FilterParams *pars);
+
+ REALTYPE getfreq();
+ REALTYPE getq();
+ REALTYPE getfreqtracking(REALTYPE notefreq);
+ REALTYPE getgain();
+
+ unsigned char Pcategory;//Filter category (Analog/Formant/StVar)
+ unsigned char Ptype;// Filter type (for analog lpf,hpf,bpf..)
+ unsigned char Pfreq;// Frequency (64-central frequency)
+ unsigned char Pq; // Q parameters (resonance or bandwidth)
+ unsigned char Pstages; //filter stages+1
+ unsigned char Pfreqtrack;//how the filter frequency is changing according the note frequency
+ unsigned char Pgain;//filter's output gain
+
+ //Formant filter parameters
+ unsigned char Pnumformants;//how many formants are used
+ unsigned char Pformantslowness;//how slow varies the formants
+ unsigned char Pvowelclearness;//how vowels are kept clean (how much try to avoid "mixed" vowels)
+ unsigned char Pcenterfreq,Poctavesfreq;//the center frequency of the res. func., and the number of octaves
+
+ struct {
+ struct {
+ unsigned char freq,amp,q;//frequency,amplitude,Q
+ }formants[FF_MAX_FORMANTS];
+ }Pvowels[FF_MAX_VOWELS];
+
+
+ unsigned char Psequencesize;//how many vowels are in the sequence
+ unsigned char Psequencestretch;//how the sequence is stretched (how the input from filter envelopes/LFOs/etc. is "stretched")
+ unsigned char Psequencereversed;//if the input from filter envelopes/LFOs/etc. is reversed(negated)
+ struct {
+ unsigned char nvowel;//the vowel from the position
+ } Psequence[FF_MAX_SEQUENCE];
+
+ REALTYPE getcenterfreq();
+ REALTYPE getoctavesfreq();
+ REALTYPE getfreqpos(REALTYPE freq);
+ REALTYPE getfreqx(REALTYPE x);
+
+ void formantfilterH(int nvowel,int nfreqs,REALTYPE *freqs);//used by UI
+
+ REALTYPE getformantfreq(unsigned char freq);
+ REALTYPE getformantamp(unsigned char amp);
+ REALTYPE getformantq(unsigned char q);
+
+ bool changed;
+
+ private:
+ void defaults(int n);
+
+ //stored default parameters
+ unsigned char Dtype;
+ unsigned char Dfreq;
+ unsigned char Dq;
+};
+
+#endif
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.C
new file mode 100644
index 00000000..0f9c816d
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.C
@@ -0,0 +1,91 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ LFOParams.C - Parameters for LFO
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include <math.h>
+#include <stdio.h>
+#include "../globals.h"
+#include "LFOParams.h"
+
+int LFOParams::time;
+
+LFOParams::LFOParams(char Pfreq_,char Pintensity_,char Pstartphase_, char PLFOtype_,char Prandomness_, char Pdelay_,char Pcontinous_,char fel_):Presets(){
+ switch(fel_) {
+ case 0:setpresettype("Plfofrequency");
+ break;
+ case 1:setpresettype("Plfoamplitude");
+ break;
+ case 2:setpresettype("Plfofilter");
+ break;
+ };
+ Dfreq=Pfreq_;
+ Dintensity=Pintensity_;
+ Dstartphase=Pstartphase_;
+ DLFOtype=PLFOtype_;
+ Drandomness=Prandomness_;
+ Ddelay=Pdelay_;
+ Dcontinous=Pcontinous_;
+ fel=fel_;
+ time=0;
+
+ defaults();
+};
+
+LFOParams::~LFOParams(){
+};
+
+void LFOParams::defaults(){
+ Pfreq=Dfreq/127.0;
+ Pintensity=Dintensity;
+ Pstartphase=Dstartphase;
+ PLFOtype=DLFOtype;
+ Prandomness=Drandomness;
+ Pdelay=Ddelay;
+ Pcontinous=Dcontinous;
+ Pfreqrand=0;
+ Pstretch=64;
+};
+
+
+void LFOParams::add2XML(XMLwrapper *xml){
+ xml->addparreal("freq",Pfreq);
+ xml->addpar("intensity",Pintensity);
+ xml->addpar("start_phase",Pstartphase);
+ xml->addpar("lfo_type",PLFOtype);
+ xml->addpar("randomness_amplitude",Prandomness);
+ xml->addpar("randomness_frequency",Pfreqrand);
+ xml->addpar("delay",Pdelay);
+ xml->addpar("stretch",Pstretch);
+ xml->addparbool("continous",Pcontinous);
+};
+
+void LFOParams::getfromXML(XMLwrapper *xml){
+ Pfreq=xml->getparreal("freq",Pfreq,0.0,1.0);
+ Pintensity=xml->getpar127("intensity",Pintensity);
+ Pstartphase=xml->getpar127("start_phase",Pstartphase);
+ PLFOtype=xml->getpar127("lfo_type",PLFOtype);
+ Prandomness=xml->getpar127("randomness_amplitude",Prandomness);
+ Pfreqrand=xml->getpar127("randomness_frequency",Pfreqrand);
+ Pdelay=xml->getpar127("delay",Pdelay);
+ Pstretch=xml->getpar127("stretch",Pstretch);
+ Pcontinous=xml->getparbool("continous",Pcontinous);
+};
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.h
new file mode 100644
index 00000000..48a0d5d2
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/LFOParams.h
@@ -0,0 +1,64 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ LFOParams.h - Parameters for LFO
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef LFO_PARAMS_H
+#define LFO_PARAMS_H
+
+#include "../Misc/XMLwrapper.h"
+#include "Presets.h"
+
+class LFOParams:public Presets{
+ public:
+ LFOParams(char Pfreq_,char Pintensity_,char Pstartphase_, char PLFOtype_,char Prandomness_, char Pdelay_,char Pcontinous,char fel_);
+ ~LFOParams();
+
+ void add2XML(XMLwrapper *xml);
+ void defaults();
+ void getfromXML(XMLwrapper *xml);
+
+ /* Parametrii MIDI */
+ REALTYPE Pfreq; // frequency
+ unsigned char Pintensity; // intensity
+ unsigned char Pstartphase;// start phase (0=random)
+ unsigned char PLFOtype; // LFO type (sin,triangle,square,ramp,...)
+ unsigned char Prandomness;// randomness (0=off)
+ unsigned char Pfreqrand; // frequency randomness (0=off)
+ unsigned char Pdelay; // delay (0=off)
+ unsigned char Pcontinous; // 1 if LFO is continous
+ unsigned char Pstretch; // how the LFO is "stretched" according the note frequency (64=no stretch)
+
+ int fel;//what kind is the LFO (0 - frequency, 1 - amplitude, 2 - filter)
+ static int time;//is used by Pcontinous parameter
+ private:
+ /* Default parameters */
+ unsigned char Dfreq;
+ unsigned char Dintensity;
+ unsigned char Dstartphase;
+ unsigned char DLFOtype;
+ unsigned char Drandomness;
+ unsigned char Ddelay;
+ unsigned char Dcontinous;
+
+};
+
+
+#endif
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.C
new file mode 100644
index 00000000..0c62e53b
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.C
@@ -0,0 +1,742 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ PADnoteParameters.C - Parameters for PADnote (PADsynth)
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+#include <math.h>
+#include "PADnoteParameters.h"
+#include "../Misc/Master.h"
+
+PADnoteParameters::PADnoteParameters(FFTwrapper *fft_,Master* master_):Presets(){
+ setpresettype("Ppadsyth");
+
+ fft=fft_;
+ master=master_;
+
+ resonance=new Resonance();
+ oscilgen=new OscilGen(fft_,resonance);
+ oscilgen->ADvsPAD=true;
+
+ FreqEnvelope=new EnvelopeParams(0,0);
+ FreqEnvelope->ASRinit(64,50,64,60);
+ FreqLfo=new LFOParams(70,0,64,0,0,0,0,0);
+
+ AmpEnvelope=new EnvelopeParams(64,1);
+ AmpEnvelope->ADSRinit_dB(0,40,127,25);
+ AmpLfo=new LFOParams(80,0,64,0,0,0,0,1);
+
+ GlobalFilter=new FilterParams(2,94,40);
+ FilterEnvelope=new EnvelopeParams(0,1);
+ FilterEnvelope->ADSRinit_filter(64,40,64,70,60,64);
+ FilterLfo=new LFOParams(80,0,64,0,0,0,0,2);
+
+ for (int i=0;i<PAD_MAX_SAMPLES;i++) sample[i].smp=NULL;
+ newsample.smp=NULL;
+
+ defaults();
+};
+
+PADnoteParameters::~PADnoteParameters(){
+ deletesamples();
+ delete(oscilgen);
+ delete(resonance);
+
+ delete(FreqEnvelope);
+ delete(FreqLfo);
+ delete(AmpEnvelope);
+ delete(AmpLfo);
+ delete(GlobalFilter);
+ delete(FilterEnvelope);
+ delete(FilterLfo);
+
+};
+
+void PADnoteParameters::defaults(){
+ Pmode=0;
+ Php.base.type=0;
+ Php.base.par1=80;
+ Php.freqmult=0;
+ Php.modulator.par1=0;
+ Php.modulator.freq=30;
+ Php.width=127;
+ Php.amp.type=0;
+ Php.amp.mode=0;
+ Php.amp.par1=80;
+ Php.amp.par2=64;
+ Php.autoscale=true;
+ Php.onehalf=0;
+
+ setPbandwidth(500);
+ Pbwscale=0;
+
+ resonance->defaults();
+ oscilgen->defaults();
+
+ Phrpos.type=0;
+ Phrpos.par1=64;
+ Phrpos.par2=64;
+ Phrpos.par3=0;
+
+ Pquality.samplesize=3;
+ Pquality.basenote=4;
+ Pquality.oct=3;
+ Pquality.smpoct=2;
+
+ PStereo=1;//stereo
+ /* Frequency Global Parameters */
+ Pfixedfreq=0;
+ PfixedfreqET=0;
+ PDetune=8192;//zero
+ PCoarseDetune=0;
+ PDetuneType=1;
+ FreqEnvelope->defaults();
+ FreqLfo->defaults();
+
+ /* Amplitude Global Parameters */
+ PVolume=90;
+ PPanning=64;//center
+ PAmpVelocityScaleFunction=64;
+ AmpEnvelope->defaults();
+ AmpLfo->defaults();
+ PPunchStrength=0;
+ PPunchTime=60;
+ PPunchStretch=64;
+ PPunchVelocitySensing=72;
+
+ /* Filter Global Parameters*/
+ PFilterVelocityScale=64;
+ PFilterVelocityScaleFunction=64;
+ GlobalFilter->defaults();
+ FilterEnvelope->defaults();
+ FilterLfo->defaults();
+
+ deletesamples();
+};
+
+void PADnoteParameters::deletesample(int n){
+ if ((n<0)||(n>=PAD_MAX_SAMPLES)) return;
+ if (sample[n].smp!=NULL){
+ delete(sample[n].smp);
+ sample[n].smp=NULL;
+ };
+ sample[n].size=0;
+ sample[n].basefreq=440.0;
+};
+
+void PADnoteParameters::deletesamples(){
+ for (int i=0;i<PAD_MAX_SAMPLES;i++) deletesample(i);
+};
+
+/*
+ * Get the harmonic profile (i.e. the frequency distributio of a single harmonic)
+ */
+REALTYPE PADnoteParameters::getprofile(REALTYPE *smp,int size){
+ for (int i=0;i<size;i++) smp[i]=0.0;
+ const int supersample=16;
+ REALTYPE basepar=pow(2.0,(1.0-Php.base.par1/127.0)*12.0);
+ REALTYPE freqmult=floor(pow(2.0,Php.freqmult/127.0*5.0)+0.000001);
+
+ REALTYPE modfreq=floor(pow(2.0,Php.modulator.freq/127.0*5.0)+0.000001);
+ REALTYPE modpar1=pow(Php.modulator.par1/127.0,4.0)*5.0/sqrt(modfreq);
+ REALTYPE amppar1=pow(2.0,pow(Php.amp.par1/127.0,2.0)*10.0)-0.999;
+ REALTYPE amppar2=(1.0-Php.amp.par2/127.0)*0.998+0.001;
+ REALTYPE width=pow(150.0/(Php.width+22.0),2.0);
+
+ for (int i=0;i<size*supersample;i++){
+ bool makezero=false;
+ REALTYPE x=i*1.0/(size*(REALTYPE) supersample);
+
+ REALTYPE origx=x;
+
+ //do the sizing (width)
+ x=(x-0.5)*width+0.5;
+ if (x<0.0) {
+ x=0.0;
+ makezero=true;
+ } else {
+ if (x>1.0) {
+ x=1.0;
+ makezero=true;
+ };
+ };
+
+ //compute the full profile or one half
+ switch(Php.onehalf){
+ case 1:x=x*0.5+0.5;
+ break;
+ case 2:x=x*0.5;
+ break;
+ };
+
+ REALTYPE x_before_freq_mult=x;
+
+ //do the frequency multiplier
+ x*=freqmult;
+
+ //do the modulation of the profile
+ x+=sin(x_before_freq_mult*3.1415926*modfreq)*modpar1;
+ x=fmod(x+1000.0,1.0)*2.0-1.0;
+
+
+ //this is the base function of the profile
+ REALTYPE f;
+ switch (Php.base.type){
+ case 1:f=exp(-(x*x)*basepar);if (f<0.4) f=0.0; else f=1.0;
+ break;
+ case 2:f=exp(-(fabs(x))*sqrt(basepar));
+ break;
+ default:f=exp(-(x*x)*basepar);
+ break;
+ };
+ if (makezero) f=0.0;
+
+ REALTYPE amp=1.0;
+ origx=origx*2.0-1.0;
+
+ //compute the amplitude multiplier
+ switch(Php.amp.type){
+ case 1:amp=exp(-(origx*origx)*10.0*amppar1);
+ break;
+ case 2:amp=0.5*(1.0+cos(3.1415926*origx*sqrt(amppar1*4.0+1.0)));
+ break;
+ case 3:amp=1.0/(pow(origx*(amppar1*2.0+0.8),14.0)+1.0);
+ break;
+ };
+
+ //apply the amplitude multiplier
+ REALTYPE finalsmp=f;
+ if (Php.amp.type!=0){
+ switch(Php.amp.mode){
+ case 0:finalsmp=amp*(1.0-amppar2)+finalsmp*amppar2;
+ break;
+ case 1:finalsmp*=amp*(1.0-amppar2)+amppar2;
+ break;
+ case 2:finalsmp=finalsmp/(amp+pow(amppar2,4.0)*20.0+0.0001);
+ break;
+ case 3:finalsmp=amp/(finalsmp+pow(amppar2,4.0)*20.0+0.0001);
+ break;
+ };
+ };
+
+ smp[i/supersample]+=finalsmp/supersample;
+ };
+
+ //normalize the profile (make the max. to be equal to 1.0)
+ REALTYPE max=0.0;
+ for (int i=0;i<size;i++) {
+ if (smp[i]<0.0) smp[i]=0.0;
+ if (smp[i]>max) max=smp[i];
+ };
+ if (max<0.00001) max=1.0;
+ for (int i=0;i<size;i++) smp[i]/=max;
+
+ if (!Php.autoscale) return(0.5);
+
+ //compute the estimated perceived bandwidth
+ REALTYPE sum=0.0;
+ int i;
+ for (i=0;i<size/2-2;i++) {
+ sum+=smp[i]*smp[i]+smp[size-i-1]*smp[size-i-1];
+ if (sum>=4.0) break;
+ };
+
+ REALTYPE result=1.0-2.0*i/(REALTYPE) size;
+ return(result);
+};
+
+/*
+ * Compute the real bandwidth in cents and returns it
+ * Also, sets the bandwidth parameter
+ */
+REALTYPE PADnoteParameters::setPbandwidth(int Pbandwidth){
+ this->Pbandwidth=Pbandwidth;
+ REALTYPE result=pow(Pbandwidth/1000.0,1.1);
+ result=pow(10.0,result*4.0)*0.25;
+ return(result);
+};
+
+/*
+ * Get the harmonic(overtone) position
+ */
+REALTYPE PADnoteParameters::getNhr(int n){
+ REALTYPE result=1.0;
+ REALTYPE par1=pow(10.0,-(1.0-Phrpos.par1/255.0)*3.0);
+ REALTYPE par2=Phrpos.par2/255.0;
+
+ REALTYPE n0=n-1.0;
+ REALTYPE tmp=0.0;
+ int thresh=0;
+ switch(Phrpos.type){
+ case 1:
+ thresh=(int)(par2*par2*100.0)+1;
+ if (n<thresh) result=n;
+ else result=1.0+n0+(n0-thresh+1.0)*par1*8.0;
+ break;
+ case 2:
+ thresh=(int)(par2*par2*100.0)+1;
+ if (n<thresh) result=n;
+ else result=1.0+n0-(n0-thresh+1.0)*par1*0.90;
+ break;
+ case 3:
+ tmp=par1*100.0+1.0;
+ result=pow(n0/tmp,1.0-par2*0.8)*tmp+1.0;
+ break;
+ case 4:
+ result=n0*(1.0-par1)+pow(n0*0.1,par2*3.0+1.0)*par1*10.0+1.0;
+ break;
+ case 5:
+ result=n0+sin(n0*par2*par2*PI*0.999)*sqrt(par1)*2.0+1.0;
+ break;
+ case 6:
+ tmp=pow(par2*2.0,2.0)+0.1;
+ result=n0*pow(1.0+par1*pow(n0*0.8,tmp),tmp)+1.0;
+ break;
+ default:
+ result=n;
+ break;
+ };
+
+ REALTYPE par3=Phrpos.par3/255.0;
+
+ REALTYPE iresult=floor(result+0.5);
+ REALTYPE dresult=result-iresult;
+
+ result=iresult+(1.0-par3)*dresult;
+
+ return(result);
+};
+
+/*
+ * Generates the long spectrum for Bandwidth mode (only amplitudes are generated; phases will be random)
+ */
+void PADnoteParameters::generatespectrum_bandwidthMode(REALTYPE *spectrum, int size,REALTYPE basefreq,REALTYPE *profile,int profilesize,REALTYPE bwadjust){
+ for (int i=0;i<size;i++) spectrum[i]=0.0;
+
+ REALTYPE harmonics[OSCIL_SIZE/2];
+ for (int i=0;i<OSCIL_SIZE/2;i++) harmonics[i]=0.0;
+ //get the harmonic structure from the oscillator (I am using the frequency amplitudes, only)
+ oscilgen->get(harmonics,basefreq,false);
+
+ //normalize
+ REALTYPE max=0.0;
+ for (int i=0;i<OSCIL_SIZE/2;i++) if (harmonics[i]>max) max=harmonics[i];
+ if (max<0.000001) max=1;
+ for (int i=0;i<OSCIL_SIZE/2;i++) harmonics[i]/=max;
+
+ for (int nh=1;nh<OSCIL_SIZE/2;nh++){//for each harmonic
+ REALTYPE realfreq=getNhr(nh)*basefreq;
+ if (realfreq>SAMPLE_RATE*0.49999) break;
+ if (realfreq<20.0) break;
+ if (harmonics[nh-1]<1e-4) continue;
+
+ //compute the bandwidth of each harmonic
+ REALTYPE bandwidthcents=setPbandwidth(Pbandwidth);
+ REALTYPE bw=(pow(2.0,bandwidthcents/1200.0)-1.0)*basefreq/bwadjust;
+ REALTYPE power=1.0;
+ switch (Pbwscale){
+ case 0: power=1.0;break;
+ case 1: power=0.0;break;
+ case 2: power=0.25;break;
+ case 3: power=0.5;break;
+ case 4: power=0.75;break;
+ case 5: power=1.5;break;
+ case 6: power=2.0;break;
+ case 7: power=-0.5;break;
+ };
+ bw=bw*pow(realfreq/basefreq,power);
+ int ibw=(int)((bw/(SAMPLE_RATE*0.5)*size))+1;
+
+ REALTYPE amp=harmonics[nh-1];
+ if (resonance->Penabled) amp*=resonance->getfreqresponse(realfreq);
+
+ if (ibw>profilesize){//if the bandwidth is larger than the profilesize
+ REALTYPE rap=sqrt((REALTYPE)profilesize/(REALTYPE)ibw);
+ int cfreq=(int) (realfreq/(SAMPLE_RATE*0.5)*size)-ibw/2;
+ for (int i=0;i<ibw;i++){
+ int src=(int)(i*rap*rap);
+ int spfreq=i+cfreq;
+ if (spfreq<0) continue;
+ if (spfreq>=size) break;
+ spectrum[spfreq]+=amp*profile[src]*rap;
+ };
+ }else{//if the bandwidth is smaller than the profilesize
+ REALTYPE rap=sqrt((REALTYPE)ibw/(REALTYPE)profilesize);
+ REALTYPE ibasefreq=realfreq/(SAMPLE_RATE*0.5)*size;
+ for (int i=0;i<profilesize;i++){
+ REALTYPE idfreq=i/(REALTYPE)profilesize-0.5;
+ idfreq*=ibw;
+ int spfreq=(int) (idfreq+ibasefreq);
+ REALTYPE fspfreq=fmod(idfreq+ibasefreq,1.0);
+ if (spfreq<=0) continue;
+ if (spfreq>=size-1) break;
+ spectrum[spfreq]+=amp*profile[i]*rap*(1.0-fspfreq);
+ spectrum[spfreq+1]+=amp*profile[i]*rap*fspfreq;
+ };
+ };
+ };
+};
+
+/*
+ * Generates the long spectrum for non-Bandwidth modes (only amplitudes are generated; phases will be random)
+ */
+void PADnoteParameters::generatespectrum_otherModes(REALTYPE *spectrum, int size,REALTYPE basefreq,REALTYPE *profile,int profilesize,REALTYPE bwadjust){
+ for (int i=0;i<size;i++) spectrum[i]=0.0;
+
+ REALTYPE harmonics[OSCIL_SIZE/2];
+ for (int i=0;i<OSCIL_SIZE/2;i++) harmonics[i]=0.0;
+ //get the harmonic structure from the oscillator (I am using the frequency amplitudes, only)
+ oscilgen->get(harmonics,basefreq,false);
+
+ //normalize
+ REALTYPE max=0.0;
+ for (int i=0;i<OSCIL_SIZE/2;i++) if (harmonics[i]>max) max=harmonics[i];
+ if (max<0.000001) max=1;
+ for (int i=0;i<OSCIL_SIZE/2;i++) harmonics[i]/=max;
+
+ for (int nh=1;nh<OSCIL_SIZE/2;nh++){//for each harmonic
+ REALTYPE realfreq=getNhr(nh)*basefreq;
+
+ ///sa fac aici interpolarea si sa am grija daca frecv descresc
+
+ if (realfreq>SAMPLE_RATE*0.49999) break;
+ if (realfreq<20.0) break;
+// if (harmonics[nh-1]<1e-4) continue;
+
+
+ REALTYPE amp=harmonics[nh-1];
+ if (resonance->Penabled) amp*=resonance->getfreqresponse(realfreq);
+ int cfreq=(int) (realfreq/(SAMPLE_RATE*0.5)*size);
+
+ spectrum[cfreq]=amp+1e-9;
+ };
+
+ if (Pmode!=1){
+ int old=0;
+ for (int k=1;k<size;k++){
+ if ( (spectrum[k]>1e-10) || (k==(size-1)) ){
+ int delta=k-old;
+ REALTYPE val1=spectrum[old];
+ REALTYPE val2=spectrum[k];
+ REALTYPE idelta=1.0/delta;
+ for (int i=0;i<delta;i++){
+ REALTYPE x=idelta*i;
+ spectrum[old+i]=val1*(1.0-x)+val2*x;
+ };
+ old=k;
+ };
+ };
+ };
+
+};
+
+/*
+ * Applies the parameters (i.e. computes all the samples, based on parameters);
+ */
+void PADnoteParameters::applyparameters(bool lockmutex){
+ const int samplesize=(((int) 1)<<(Pquality.samplesize+14));
+ int spectrumsize=samplesize/2;
+ REALTYPE spectrum[spectrumsize];
+ int profilesize=512;
+ REALTYPE profile[profilesize];
+
+printf("applyparameters %d\n", lockmutex);
+
+ REALTYPE bwadjust=getprofile(profile,profilesize);
+// for (int i=0;i<profilesize;i++) profile[i]*=profile[i];
+ REALTYPE basefreq=65.406*pow(2.0,Pquality.basenote/2);
+ if (Pquality.basenote%2==1) basefreq*=1.5;
+
+ int samplemax=Pquality.oct+1;
+ int smpoct=Pquality.smpoct;
+ if (Pquality.smpoct==5) smpoct=6;
+ if (Pquality.smpoct==6) smpoct=12;
+ if (smpoct!=0) samplemax*=smpoct;
+ else samplemax=samplemax/2+1;
+ if (samplemax==0) samplemax=1;
+
+ //prepare a BIG FFT stuff
+ FFTwrapper *fft=new FFTwrapper(samplesize);
+ FFTFREQS fftfreqs;
+ newFFTFREQS(&fftfreqs,samplesize/2);
+
+ REALTYPE adj[samplemax];//this is used to compute frequency relation to the base frequency
+ for (int nsample=0;nsample<samplemax;nsample++) adj[nsample]=(Pquality.oct+1.0)*(REALTYPE)nsample/samplemax;
+ for (int nsample=0;nsample<samplemax;nsample++){
+ REALTYPE tmp=adj[nsample]-adj[samplemax-1]*0.5;
+ REALTYPE basefreqadjust=pow(2.0,tmp);
+
+ if (Pmode==0) generatespectrum_bandwidthMode(spectrum,spectrumsize,basefreq*basefreqadjust,profile,profilesize,bwadjust);
+ else generatespectrum_otherModes(spectrum,spectrumsize,basefreq*basefreqadjust,profile,profilesize,bwadjust);
+
+ const int extra_samples=5;//the last samples contains the first samples (used for linear/cubic interpolation)
+ newsample.smp=new REALTYPE[samplesize+extra_samples];
+
+ newsample.smp[0]=0.0;
+ for (int i=1;i<spectrumsize;i++){//randomize the phases
+ REALTYPE phase=RND*6.29;
+ fftfreqs.c[i]=spectrum[i]*cos(phase);
+ fftfreqs.s[i]=spectrum[i]*sin(phase);
+ };
+ fft->freqs2smps(fftfreqs,newsample.smp);//that's all; here is the only ifft for the whole sample; no windows are used ;-)
+
+
+ //normalize(rms)
+ REALTYPE rms=0.0;
+ for (int i=0;i<samplesize;i++) rms+=newsample.smp[i]*newsample.smp[i];
+ rms=sqrt(rms);
+ if (rms<0.000001) rms=1.0;
+ rms*=sqrt(262144.0/samplesize);
+ for (int i=0;i<samplesize;i++) newsample.smp[i]*=1.0/rms*50.0;
+
+ //prepare extra samples used by the linear or cubic interpolation
+ for (int i=0;i<extra_samples;i++) newsample.smp[i+samplesize]=newsample.smp[i];
+
+ //replace the current sample with the new computed sample
+ if (lockmutex){
+ master->lock();
+ deletesample(nsample);
+ sample[nsample].smp=newsample.smp;
+ sample[nsample].size=samplesize;
+ sample[nsample].basefreq=basefreq*basefreqadjust;
+ master->unlock();
+ } else {
+ deletesample(nsample);
+ sample[nsample].smp=newsample.smp;
+ sample[nsample].size=samplesize;
+ sample[nsample].basefreq=basefreq*basefreqadjust;
+ };
+ newsample.smp=NULL;
+ };
+ delete(fft);
+ deleteFFTFREQS(&fftfreqs);
+
+ //delete the additional samples that might exists and are not useful
+ if (lockmutex){
+ master->lock();
+ for (int i=samplemax;i<PAD_MAX_SAMPLES;i++) deletesample(i);
+ master->unlock();
+ } else {
+ for (int i=samplemax;i<PAD_MAX_SAMPLES;i++) deletesample(i);
+ };
+};
+
+
+void PADnoteParameters::add2XML(XMLwrapper *xml){
+ xml->information.PADsynth_used=true;
+
+ xml->addparbool("stereo",PStereo);
+ xml->addpar("mode",Pmode);
+ xml->addpar("bandwidth",Pbandwidth);
+ xml->addpar("bandwidth_scale",Pbwscale);
+
+ xml->beginbranch("HARMONIC_PROFILE");
+ xml->addpar("base_type",Php.base.type);
+ xml->addpar("base_par1",Php.base.par1);
+ xml->addpar("frequency_multiplier",Php.freqmult);
+ xml->addpar("modulator_par1",Php.modulator.par1);
+ xml->addpar("modulator_frequency",Php.modulator.freq);
+ xml->addpar("width",Php.width);
+ xml->addpar("amplitude_multiplier_type",Php.amp.type);
+ xml->addpar("amplitude_multiplier_mode",Php.amp.mode);
+ xml->addpar("amplitude_multiplier_par1",Php.amp.par1);
+ xml->addpar("amplitude_multiplier_par2",Php.amp.par2);
+ xml->addparbool("autoscale",Php.autoscale);
+ xml->addpar("one_half",Php.onehalf);
+ xml->endbranch();
+
+ xml->beginbranch("OSCIL");
+ oscilgen->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("RESONANCE");
+ resonance->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("HARMONIC_POSITION");
+ xml->addpar("type",Phrpos.type);
+ xml->addpar("parameter1",Phrpos.par1);
+ xml->addpar("parameter2",Phrpos.par2);
+ xml->addpar("parameter3",Phrpos.par3);
+ xml->endbranch();
+
+ xml->beginbranch("SAMPLE_QUALITY");
+ xml->addpar("samplesize",Pquality.samplesize);
+ xml->addpar("basenote",Pquality.basenote);
+ xml->addpar("octaves",Pquality.oct);
+ xml->addpar("samples_per_octave",Pquality.smpoct);
+ xml->endbranch();
+
+ xml->beginbranch("AMPLITUDE_PARAMETERS");
+ xml->addpar("volume",PVolume);
+ xml->addpar("panning",PPanning);
+ xml->addpar("velocity_sensing",PAmpVelocityScaleFunction);
+ xml->addpar("punch_strength",PPunchStrength);
+ xml->addpar("punch_time",PPunchTime);
+ xml->addpar("punch_stretch",PPunchStretch);
+ xml->addpar("punch_velocity_sensing",PPunchVelocitySensing);
+
+ xml->beginbranch("AMPLITUDE_ENVELOPE");
+ AmpEnvelope->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("AMPLITUDE_LFO");
+ AmpLfo->add2XML(xml);
+ xml->endbranch();
+
+ xml->endbranch();
+
+ xml->beginbranch("FREQUENCY_PARAMETERS");
+ xml->addpar("fixed_freq",Pfixedfreq);
+ xml->addpar("fixed_freq_et",PfixedfreqET);
+ xml->addpar("detune",PDetune);
+ xml->addpar("coarse_detune",PCoarseDetune);
+ xml->addpar("detune_type",PDetuneType);
+
+ xml->beginbranch("FREQUENCY_ENVELOPE");
+ FreqEnvelope->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("FREQUENCY_LFO");
+ FreqLfo->add2XML(xml);
+ xml->endbranch();
+ xml->endbranch();
+
+ xml->beginbranch("FILTER_PARAMETERS");
+ xml->addpar("velocity_sensing_amplitude",PFilterVelocityScale);
+ xml->addpar("velocity_sensing",PFilterVelocityScaleFunction);
+
+ xml->beginbranch("FILTER");
+ GlobalFilter->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("FILTER_ENVELOPE");
+ FilterEnvelope->add2XML(xml);
+ xml->endbranch();
+
+ xml->beginbranch("FILTER_LFO");
+ FilterLfo->add2XML(xml);
+ xml->endbranch();
+ xml->endbranch();
+};
+
+void PADnoteParameters::getfromXML(XMLwrapper *xml){
+ PStereo=xml->getparbool("stereo",PStereo);
+ Pmode=xml->getpar127("mode",0);
+ Pbandwidth=xml->getpar("bandwidth",Pbandwidth,0,1000);
+ Pbwscale=xml->getpar127("bandwidth_scale",Pbwscale);
+
+ if (xml->enterbranch("HARMONIC_PROFILE")){
+ Php.base.type=xml->getpar127("base_type",Php.base.type);
+ Php.base.par1=xml->getpar127("base_par1",Php.base.par1);
+ Php.freqmult=xml->getpar127("frequency_multiplier",Php.freqmult);
+ Php.modulator.par1=xml->getpar127("modulator_par1",Php.modulator.par1);
+ Php.modulator.freq=xml->getpar127("modulator_frequency",Php.modulator.freq);
+ Php.width=xml->getpar127("width",Php.width);
+ Php.amp.type=xml->getpar127("amplitude_multiplier_type",Php.amp.type);
+ Php.amp.mode=xml->getpar127("amplitude_multiplier_mode",Php.amp.mode);
+ Php.amp.par1=xml->getpar127("amplitude_multiplier_par1",Php.amp.par1);
+ Php.amp.par2=xml->getpar127("amplitude_multiplier_par2",Php.amp.par2);
+ Php.autoscale=xml->getparbool("autoscale",Php.autoscale);
+ Php.onehalf=xml->getpar127("one_half",Php.onehalf);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("OSCIL")){
+ oscilgen->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("RESONANCE")){
+ resonance->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("HARMONIC_POSITION")){
+ Phrpos.type=xml->getpar127("type",Phrpos.type);
+ Phrpos.par1=xml->getpar("parameter1",Phrpos.par1,0,255);
+ Phrpos.par2=xml->getpar("parameter2",Phrpos.par2,0,255);
+ Phrpos.par3=xml->getpar("parameter3",Phrpos.par3,0,255);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("SAMPLE_QUALITY")){
+ Pquality.samplesize=xml->getpar127("samplesize",Pquality.samplesize);
+ Pquality.basenote=xml->getpar127("basenote",Pquality.basenote);
+ Pquality.oct=xml->getpar127("octaves",Pquality.oct);
+ Pquality.smpoct=xml->getpar127("samples_per_octave",Pquality.smpoct);
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
+ PVolume=xml->getpar127("volume",PVolume);
+ PPanning=xml->getpar127("panning",PPanning);
+ PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",PAmpVelocityScaleFunction);
+ PPunchStrength=xml->getpar127("punch_strength",PPunchStrength);
+ PPunchTime=xml->getpar127("punch_time",PPunchTime);
+ PPunchStretch=xml->getpar127("punch_stretch",PPunchStretch);
+ PPunchVelocitySensing=xml->getpar127("punch_velocity_sensing",PPunchVelocitySensing);
+
+ xml->enterbranch("AMPLITUDE_ENVELOPE");
+ AmpEnvelope->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("AMPLITUDE_LFO");
+ AmpLfo->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FREQUENCY_PARAMETERS")){
+ Pfixedfreq=xml->getpar127("fixed_freq",Pfixedfreq);
+ PfixedfreqET=xml->getpar127("fixed_freq_et",PfixedfreqET);
+ PDetune=xml->getpar("detune",PDetune,0,16383);
+ PCoarseDetune=xml->getpar("coarse_detune",PCoarseDetune,0,16383);
+ PDetuneType=xml->getpar127("detune_type",PDetuneType);
+
+ xml->enterbranch("FREQUENCY_ENVELOPE");
+ FreqEnvelope->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("FREQUENCY_LFO");
+ FreqLfo->getfromXML(xml);
+ xml->exitbranch();
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FILTER_PARAMETERS")){
+ PFilterVelocityScale=xml->getpar127("velocity_sensing_amplitude",PFilterVelocityScale);
+ PFilterVelocityScaleFunction=xml->getpar127("velocity_sensing",PFilterVelocityScaleFunction);
+
+ xml->enterbranch("FILTER");
+ GlobalFilter->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("FILTER_ENVELOPE");
+ FilterEnvelope->getfromXML(xml);
+ xml->exitbranch();
+
+ xml->enterbranch("FILTER_LFO");
+ FilterLfo->getfromXML(xml);
+ xml->exitbranch();
+ xml->exitbranch();
+ };
+};
+
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.h
new file mode 100644
index 00000000..a2328e86
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PADnoteParameters.h
@@ -0,0 +1,169 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ PADnoteParameters.h - Parameters for PADnote (PADsynth)
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef PAD_NOTE_PARAMETERS_H
+#define PAD_NOTE_PARAMETERS_H
+
+#include "../Misc/XMLwrapper.h"
+#include "../DSP/FFTwrapper.h"
+#include "../globals.h"
+#include "../Synth/OscilGen.h"
+#include "../Synth/Resonance.h"
+#include "../Misc/Util.h"
+
+#include "EnvelopeParams.h"
+#include "LFOParams.h"
+#include "FilterParams.h"
+#include "Presets.h"
+
+class Master;
+
+class PADnoteParameters:public Presets{
+ public:
+ PADnoteParameters(FFTwrapper *fft_,Master* master);
+ ~PADnoteParameters();
+
+ void defaults();
+ void add2XML(XMLwrapper *xml);
+ void getfromXML(XMLwrapper *xml);
+
+ //returns a value between 0.0-1.0 that represents the estimation perceived bandwidth
+ REALTYPE getprofile(REALTYPE *smp,int size);
+
+ //parameters
+
+ //the mode: 0 - bandwidth, 1 - discrete (bandwidth=0), 2 - continous
+ //the harmonic profile is used only on mode 0
+ unsigned char Pmode;
+
+ //Harmonic profile (the frequency distribution of a single harmonic)
+ struct {
+ struct{//base function
+ unsigned char type;
+ unsigned char par1;
+ }base;
+ unsigned char freqmult;//frequency multiplier of the distribution
+ struct{//the modulator of the distribution
+ unsigned char par1;
+ unsigned char freq;
+ }modulator;
+
+ unsigned char width;//the width of the resulting function after the modulation
+ struct{//the amplitude multiplier of the harmonic profile
+ unsigned char mode;
+ unsigned char type;
+ unsigned char par1;
+ unsigned char par2;
+ }amp;
+ bool autoscale;//if the scale of the harmonic profile is computed automaticaly
+ unsigned char onehalf;//what part of the base function is used to make the distribution
+ }Php;
+
+
+ unsigned int Pbandwidth;//the values are from 0 to 1000
+ unsigned char Pbwscale;//how the bandwidth is increased according to the harmonic's frequency
+
+ struct{//where are positioned the harmonics (on integer multimplier or different places)
+ unsigned char type;
+ unsigned char par1,par2,par3;//0..255
+ }Phrpos;
+
+ struct {//quality of the samples (how many samples, the length of them,etc.)
+ unsigned char samplesize;
+ unsigned char basenote,oct,smpoct;
+ } Pquality;
+
+ //frequency parameters
+ //If the base frequency is fixed to 440 Hz
+ unsigned char Pfixedfreq;
+
+ /* Equal temperate (this is used only if the Pfixedfreq is enabled)
+ If this parameter is 0, the frequency is fixed (to 440 Hz);
+ if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
+ unsigned char PfixedfreqET;
+ unsigned short int PDetune;//fine detune
+ unsigned short int PCoarseDetune;//coarse detune+octave
+ unsigned char PDetuneType;//detune type
+
+ EnvelopeParams *FreqEnvelope; //Frequency Envelope
+ LFOParams *FreqLfo;//Frequency LFO
+
+ //Amplitude parameters
+ unsigned char PStereo;
+ /* Panning - 0 - random
+ 1 - left
+ 64 - center
+ 127 - right */
+ unsigned char PPanning;
+
+ unsigned char PVolume;
+
+ unsigned char PAmpVelocityScaleFunction;
+
+ EnvelopeParams *AmpEnvelope;
+
+ LFOParams *AmpLfo;
+
+ unsigned char PPunchStrength,PPunchTime,PPunchStretch,PPunchVelocitySensing;
+
+ //Filter Parameters
+ FilterParams *GlobalFilter;
+
+ // filter velocity sensing
+ unsigned char PFilterVelocityScale;
+
+ // filter velocity sensing
+ unsigned char PFilterVelocityScaleFunction;
+
+ EnvelopeParams *FilterEnvelope;
+ LFOParams *FilterLfo;
+
+
+
+
+ REALTYPE setPbandwidth(int Pbandwidth);//returns the BandWidth in cents
+ REALTYPE getNhr(int n);//gets the n-th overtone position relatively to N harmonic
+
+ void applyparameters(bool lockmutex);
+
+ OscilGen *oscilgen;
+ Resonance *resonance;
+
+ struct{
+ int size;
+ REALTYPE basefreq;
+ REALTYPE *smp;
+ }sample[PAD_MAX_SAMPLES],newsample;
+
+ private:
+ void generatespectrum_bandwidthMode(REALTYPE *spectrum, int size,REALTYPE basefreq,REALTYPE *profile,int profilesize,REALTYPE bwadjust);
+ void generatespectrum_otherModes(REALTYPE *spectrum, int size,REALTYPE basefreq,REALTYPE *profile,int profilesize,REALTYPE bwadjust);
+ void deletesamples();
+ void deletesample(int n);
+
+ FFTwrapper *fft;
+ Master* master;
+};
+
+
+
+#endif
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.C
new file mode 100644
index 00000000..e5f6e10c
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.C
@@ -0,0 +1,129 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Presets.C - Presets and Clipboard management
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include "Presets.h"
+#include <string.h>
+
+
+Presets::Presets(){
+ type[0]=0;
+ nelement=-1;
+};
+
+Presets::~Presets(){
+};
+
+void Presets::setpresettype(char *type){
+ strcpy(this->type,type);
+};
+
+void Presets::copy(const char *name){
+ XMLwrapper *xml=new XMLwrapper();
+
+ //used only for the clipboard
+ if (name==NULL) xml->minimal=false;
+
+ char type[MAX_PRESETTYPE_SIZE];
+ strcpy(type,this->type);
+ if (nelement!=-1) strcat(type,"n");
+ if (name==NULL) {
+ if (strstr(type,"Plfo")!=NULL) strcpy(type,"Plfo");
+ };
+
+ xml->beginbranch(type);
+ if (nelement==-1) add2XML(xml);
+ else add2XMLsection(xml,nelement);
+ xml->endbranch();
+
+ if (name==NULL) presetsstore.copyclipboard(xml,type);
+ else presetsstore.copypreset(xml,type,name);
+
+ delete(xml);
+ nelement=-1;
+};
+
+void Presets::paste(int npreset){
+ char type[MAX_PRESETTYPE_SIZE];
+ strcpy(type,this->type);
+ if (nelement!=-1) strcat(type,"n");
+ if (npreset==0){
+ if (strstr(type,"Plfo")!=NULL) strcpy(type,"Plfo");
+ };
+
+ XMLwrapper *xml=new XMLwrapper();
+ if (npreset==0){
+ if (!checkclipboardtype()) {
+ nelement=-1;
+ delete(xml);
+ return;
+ };
+ if (!presetsstore.pasteclipboard(xml)) {
+ delete(xml);
+ nelement=-1;
+ return;
+ };
+ } else {
+ if (!presetsstore.pastepreset(xml,npreset)) {
+ delete(xml);
+ nelement=-1;
+ return;
+ };
+ };
+
+ if (xml->enterbranch(type)==0) {
+ nelement=-1;
+ return;
+ };
+ if (nelement==-1) {
+ defaults();
+ getfromXML(xml);
+ } else {
+ defaults(nelement);
+ getfromXMLsection(xml,nelement);
+ };
+ xml->exitbranch();
+
+ delete(xml);
+ nelement=-1;
+};
+
+bool Presets::checkclipboardtype(){
+ char type[MAX_PRESETTYPE_SIZE];
+ strcpy(type,this->type);
+ if (nelement!=-1) strcat(type,"n");
+
+ return(presetsstore.checkclipboardtype(type));
+};
+
+void Presets::setelement(int n){
+ nelement=n;
+};
+
+void Presets::rescanforpresets(){
+ presetsstore.rescanforpresets(type);
+};
+
+
+void Presets::deletepreset(int npreset){
+ presetsstore.deletepreset(npreset);
+};
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.h
new file mode 100644
index 00000000..d7d938d1
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/Presets.h
@@ -0,0 +1,58 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ Presets.h - Presets and Clipboard management
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef PRESETS_H
+#define PRESETS_H
+
+#include "../Misc/XMLwrapper.h"
+
+#include "PresetsStore.h"
+
+class Presets{
+ public:
+ Presets();
+ virtual ~Presets();
+
+ void copy(const char *name);//if name==NULL, the clipboard is used
+ void paste(int npreset);//npreset==0 for clipboard
+ bool checkclipboardtype();
+ void deletepreset(int npreset);
+
+ char type[MAX_PRESETTYPE_SIZE];
+ void setelement(int n);
+
+ void rescanforpresets();
+
+ protected:
+ void setpresettype(char *type);
+ private:
+ virtual void add2XML(XMLwrapper *xml)=0;
+ virtual void getfromXML(XMLwrapper *xml)=0;
+ virtual void defaults()=0;
+ virtual void add2XMLsection(XMLwrapper */*xml*/,int /*n*/){};
+ virtual void getfromXMLsection(XMLwrapper */*xml*/,int /*n*/){};
+ virtual void defaults(int /*n*/){};
+ int nelement;
+};
+
+#endif
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C
new file mode 100644
index 00000000..8bbb2bec
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.C
@@ -0,0 +1,181 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ PresetsStore.C - Presets and Clipboard store
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+#include <stdlib.h>
+#include <string.h>
+#include <dirent.h>
+#include <sys/stat.h>
+
+#include "PresetsStore.h"
+#include "../Misc/Util.h"
+
+PresetsStore presetsstore;
+
+PresetsStore::PresetsStore(){
+ clipboard.data=NULL;
+ clipboard.type[0]=0;
+
+ for (int i=0;i<MAX_PRESETS;i++){
+ presets[i].file=NULL;
+ presets[i].name=NULL;
+ };
+
+};
+
+PresetsStore::~PresetsStore(){
+ if (clipboard.data!=NULL) delete (clipboard.data);
+ clearpresets();
+};
+
+//Clipboard management
+
+void PresetsStore::copyclipboard(XMLwrapper *xml,char *type){
+ strcpy(clipboard.type,type);
+ if (clipboard.data!=NULL) delete (clipboard.data);
+ clipboard.data=xml->getXMLdata();
+};
+
+bool PresetsStore::pasteclipboard(XMLwrapper *xml){
+ if (clipboard.data!=NULL) xml->putXMLdata(clipboard.data);
+ else return(false);
+ return(true);
+};
+
+bool PresetsStore::checkclipboardtype(char *type){
+ //makes LFO's compatible
+ if ((strstr(type,"Plfo")!=NULL)&&(strstr(clipboard.type,"Plfo")!=NULL)) return(true);
+ return(strcmp(type,clipboard.type)==0);
+};
+
+//Presets management
+void PresetsStore::clearpresets(){
+ for (int i=0;i<MAX_PRESETS;i++){
+ if (presets[i].file!=NULL) {
+ delete(presets[i].file);
+ presets[i].file=NULL;
+ };
+ if (presets[i].name!=NULL) {
+ delete(presets[i].name);
+ presets[i].name=NULL;
+ };
+ };
+
+};
+
+//a helper function that compares 2 presets[]
+int Presets_compar(const void *a,const void *b){
+ struct PresetsStore::presetstruct *p1= (PresetsStore::presetstruct *)a;
+ struct PresetsStore::presetstruct *p2= (PresetsStore::presetstruct *)b;
+ if (((p1->name)==NULL)||((p2->name)==NULL)) return(0);
+
+ return(strcasecmp(p1->name,p2->name)<0);
+};
+
+
+void PresetsStore::rescanforpresets(char *type){
+ clearpresets();
+ int presetk=0;
+ char ftype[MAX_STRING_SIZE];
+ snprintf(ftype,MAX_STRING_SIZE,".%s.xpz",type);
+
+ for (int i=0;i<MAX_BANK_ROOT_DIRS;i++){
+ if (config.cfg.presetsDirList[i]==NULL) continue;
+ char *dirname=config.cfg.presetsDirList[i];
+ DIR *dir=opendir(dirname);
+ if (dir==NULL) continue;
+ struct dirent *fn;
+ while((fn=readdir(dir))){
+ const char *filename=fn->d_name;
+ if (strstr(filename,ftype)==NULL) continue;
+
+
+ presets[presetk].file=new char [MAX_STRING_SIZE];
+ presets[presetk].name=new char [MAX_STRING_SIZE];
+ char tmpc=dirname[strlen(dirname)-1];
+ char *tmps="/";
+ if ((tmpc=='/')||(tmpc=='\\')) tmps="";
+ snprintf(presets[presetk].file,MAX_STRING_SIZE,"%s%s%s",dirname,tmps,filename);
+ snprintf(presets[presetk].name,MAX_STRING_SIZE,"%s",filename);
+
+ char *tmp=strstr(presets[presetk].name,ftype);
+ if (tmp!=NULL) tmp[0]='\0';
+ presetk++; if (presetk>=MAX_PRESETS) return;
+ };
+
+ closedir(dir);
+ };
+
+ //sort the presets
+ for (int j=0;j<MAX_PRESETS-1;j++){
+ for (int i=j+1;i<MAX_PRESETS;i++){
+ if (Presets_compar(&presets[i],&presets[j])) {
+ presetstruct tmp=presets[i];
+ presets[i]=presets[j];
+ presets[j]=tmp;
+ };
+ };
+ };
+};
+
+void PresetsStore::copypreset(XMLwrapper *xml,char *type, const char *name){
+ char filename[MAX_STRING_SIZE],tmpfilename[MAX_STRING_SIZE];
+
+ if (config.cfg.presetsDirList[0]==NULL) return;
+
+ snprintf(tmpfilename,MAX_STRING_SIZE,"%s",name);
+
+ //make the filenames legal
+ for (int i=0;i<(int) strlen(tmpfilename);i++) {
+ char c=tmpfilename[i];
+ if ((c>='0')&&(c<='9')) continue;
+ if ((c>='A')&&(c<='Z')) continue;
+ if ((c>='a')&&(c<='z')) continue;
+ if ((c=='-')||(c==' ')) continue;
+ tmpfilename[i]='_';
+ };
+
+ char *dirname=config.cfg.presetsDirList[0];
+ char tmpc=dirname[strlen(dirname)-1];
+ char *tmps="/";
+ if ((tmpc=='/')||(tmpc=='\\')) tmps="";
+
+ snprintf(filename,MAX_STRING_SIZE,"%s%s%s.%s.xpz",dirname,tmps,name,type);
+
+ xml->saveXMLfile(filename);
+};
+
+bool PresetsStore::pastepreset(XMLwrapper *xml, int npreset){
+ npreset--;
+ if (npreset>=MAX_PRESETS) return(false);
+ char *filename=presets[npreset].file;
+ if (filename==NULL) return(false);
+ bool result=(xml->loadXMLfile(filename)>=0);
+ return(result);
+};
+
+void PresetsStore::deletepreset(int npreset){
+ npreset--;
+ if (npreset>=MAX_PRESETS) return;
+ char *filename=presets[npreset].file;
+ if (filename==NULL) return;
+ remove(filename);
+};
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.h
new file mode 100644
index 00000000..555e20cb
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/PresetsStore.h
@@ -0,0 +1,63 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ PresetsStore.C - Presets and Clipboard store
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include "../Misc/XMLwrapper.h"
+#include "../Misc/Config.h"
+
+#define MAX_PRESETTYPE_SIZE 30
+#define MAX_PRESETS 1000
+
+class PresetsStore{
+ public:
+ PresetsStore();
+ ~PresetsStore();
+
+ //Clipboard stuff
+ void copyclipboard(XMLwrapper *xml,char *type);
+ bool pasteclipboard(XMLwrapper *xml);
+ bool checkclipboardtype(char *type);
+
+ //presets stuff
+ void copypreset(XMLwrapper *xml,char *type, const char *name);
+ bool pastepreset(XMLwrapper *xml, int npreset);
+ void deletepreset(int npreset);
+
+ struct presetstruct{
+ char *file;
+ char *name;
+ };
+ presetstruct presets[MAX_PRESETS];
+
+ void rescanforpresets(char *type);
+
+ private:
+ struct {
+ char *data;
+ char type[MAX_PRESETTYPE_SIZE];
+ } clipboard;
+
+ void clearpresets();
+
+};
+
+extern PresetsStore presetsstore;
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.C b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.C
new file mode 100644
index 00000000..b04b2a9f
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.C
@@ -0,0 +1,238 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ SUBnoteParameters.C - Parameters for SUBnote (SUBsynth)
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#include "../globals.h"
+#include "SUBnoteParameters.h"
+#include <stdio.h>
+
+SUBnoteParameters::SUBnoteParameters():Presets(){
+ setpresettype("Psubsyth");
+ AmpEnvelope=new EnvelopeParams(64,1);
+ AmpEnvelope->ADSRinit_dB(0,40,127,25);
+ FreqEnvelope=new EnvelopeParams(64,0);
+ FreqEnvelope->ASRinit(30,50,64,60);
+ BandWidthEnvelope=new EnvelopeParams(64,0);
+ BandWidthEnvelope->ASRinit_bw(100,70,64,60);
+
+ GlobalFilter=new FilterParams(2,80,40);
+ GlobalFilterEnvelope=new EnvelopeParams(0,1);
+ GlobalFilterEnvelope->ADSRinit_filter(64,40,64,70,60,64);
+
+ defaults();
+};
+
+
+void SUBnoteParameters::defaults(){
+ PVolume=96;
+ PPanning=64;
+ PAmpVelocityScaleFunction=90;
+
+ Pfixedfreq=0;
+ PfixedfreqET=0;
+ Pnumstages=2;
+ Pbandwidth=40;
+ Phmagtype=0;
+ Pbwscale=64;
+ Pstereo=1;
+ Pstart=1;
+
+ PDetune=8192;
+ PCoarseDetune=0;
+ PDetuneType=1;
+ PFreqEnvelopeEnabled=0;
+ PBandWidthEnvelopeEnabled=0;
+
+ for (int n=0;n<MAX_SUB_HARMONICS;n++){
+ Phmag[n]=0;
+ Phrelbw[n]=64;
+ };
+ Phmag[0]=127;
+
+ PGlobalFilterEnabled=0;
+ PGlobalFilterVelocityScale=64;
+ PGlobalFilterVelocityScaleFunction=64;
+
+ AmpEnvelope->defaults();
+ FreqEnvelope->defaults();
+ BandWidthEnvelope->defaults();
+ GlobalFilter->defaults();
+ GlobalFilterEnvelope->defaults();
+
+};
+
+
+
+SUBnoteParameters::~SUBnoteParameters(){
+ delete (AmpEnvelope);
+ delete (FreqEnvelope);
+ delete (BandWidthEnvelope);
+ delete (GlobalFilter);
+ delete (GlobalFilterEnvelope);
+};
+
+
+
+
+void SUBnoteParameters::add2XML(XMLwrapper *xml){
+ xml->addpar("num_stages",Pnumstages);
+ xml->addpar("harmonic_mag_type",Phmagtype);
+ xml->addpar("start",Pstart);
+
+ xml->beginbranch("HARMONICS");
+ for (int i=0;i<MAX_SUB_HARMONICS;i++){
+ if ((Phmag[i]==0)&&(xml->minimal)) continue;
+ xml->beginbranch("HARMONIC",i);
+ xml->addpar("mag",Phmag[i]);
+ xml->addpar("relbw",Phrelbw[i]);
+ xml->endbranch();
+ };
+ xml->endbranch();
+
+ xml->beginbranch("AMPLITUDE_PARAMETERS");
+ xml->addparbool("stereo",Pstereo);
+ xml->addpar("volume",PVolume);
+ xml->addpar("panning",PPanning);
+ xml->addpar("velocity_sensing",PAmpVelocityScaleFunction);
+ xml->beginbranch("AMPLITUDE_ENVELOPE");
+ AmpEnvelope->add2XML(xml);
+ xml->endbranch();
+ xml->endbranch();
+
+ xml->beginbranch("FREQUENCY_PARAMETERS");
+ xml->addparbool("fixed_freq",Pfixedfreq);
+ xml->addpar("fixed_freq_et",PfixedfreqET);
+
+ xml->addpar("detune",PDetune);
+ xml->addpar("coarse_detune",PCoarseDetune);
+ xml->addpar("detune_type",PDetuneType);
+
+ xml->addpar("bandwidth",Pbandwidth);
+ xml->addpar("bandwidth_scale",Pbwscale);
+
+ xml->addparbool("freq_envelope_enabled",PFreqEnvelopeEnabled);
+ if ((PFreqEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FREQUENCY_ENVELOPE");
+ FreqEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+
+ xml->addparbool("band_width_envelope_enabled",PBandWidthEnvelopeEnabled);
+ if ((PBandWidthEnvelopeEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("BANDWIDTH_ENVELOPE");
+ BandWidthEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->endbranch();
+
+ xml->beginbranch("FILTER_PARAMETERS");
+ xml->addparbool("enabled",PGlobalFilterEnabled);
+ if ((PGlobalFilterEnabled!=0)||(!xml->minimal)){
+ xml->beginbranch("FILTER");
+ GlobalFilter->add2XML(xml);
+ xml->endbranch();
+
+ xml->addpar("filter_velocity_sensing",PGlobalFilterVelocityScaleFunction);
+ xml->addpar("filter_velocity_sensing_amplitude",PGlobalFilterVelocityScale);
+
+ xml->beginbranch("FILTER_ENVELOPE");
+ GlobalFilterEnvelope->add2XML(xml);
+ xml->endbranch();
+ };
+ xml->endbranch();
+};
+
+void SUBnoteParameters::getfromXML(XMLwrapper *xml){
+ Pnumstages=xml->getpar127("num_stages",Pnumstages);
+ Phmagtype=xml->getpar127("harmonic_mag_type",Phmagtype);
+ Pstart=xml->getpar127("start",Pstart);
+
+ if (xml->enterbranch("HARMONICS")){
+ Phmag[0]=0;
+ for (int i=0;i<MAX_SUB_HARMONICS;i++){
+ if (xml->enterbranch("HARMONIC",i)==0) continue;
+ Phmag[i]=xml->getpar127("mag",Phmag[i]);
+ Phrelbw[i]=xml->getpar127("relbw",Phrelbw[i]);
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
+ Pstereo=xml->getparbool("stereo",Pstereo);
+ PVolume=xml->getpar127("volume",PVolume);
+ PPanning=xml->getpar127("panning",PPanning);
+ PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",PAmpVelocityScaleFunction);
+ if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
+ AmpEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FREQUENCY_PARAMETERS")){
+ Pfixedfreq=xml->getparbool("fixed_freq",Pfixedfreq);
+ PfixedfreqET=xml->getpar127("fixed_freq_et",PfixedfreqET);
+
+ PDetune=xml->getpar("detune",PDetune,0,16383);
+ PCoarseDetune=xml->getpar("coarse_detune",PCoarseDetune,0,16383);
+ PDetuneType=xml->getpar127("detune_type",PDetuneType);
+
+ Pbandwidth=xml->getpar127("bandwidth",Pbandwidth);
+ Pbwscale=xml->getpar127("bandwidth_scale",Pbwscale);
+
+ PFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",PFreqEnvelopeEnabled);
+ if (xml->enterbranch("FREQUENCY_ENVELOPE")){
+ FreqEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ PBandWidthEnvelopeEnabled=xml->getparbool("band_width_envelope_enabled",PBandWidthEnvelopeEnabled);
+ if (xml->enterbranch("BANDWIDTH_ENVELOPE")){
+ BandWidthEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ xml->exitbranch();
+ };
+
+ if (xml->enterbranch("FILTER_PARAMETERS")){
+ PGlobalFilterEnabled=xml->getparbool("enabled",PGlobalFilterEnabled);
+ if (xml->enterbranch("FILTER")){
+ GlobalFilter->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ PGlobalFilterVelocityScaleFunction=xml->getpar127("filter_velocity_sensing",PGlobalFilterVelocityScaleFunction);
+ PGlobalFilterVelocityScale=xml->getpar127("filter_velocity_sensing_amplitude",PGlobalFilterVelocityScale);
+
+ if (xml->enterbranch("FILTER_ENVELOPE")){
+ GlobalFilterEnvelope->getfromXML(xml);
+ xml->exitbranch();
+ };
+
+ xml->exitbranch();
+ };
+};
+
+
+
+
diff --git a/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.h b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.h
new file mode 100644
index 00000000..a506a260
--- /dev/null
+++ b/attic/muse_qt4_evolution/synti/zynaddsubfx/Params/SUBnoteParameters.h
@@ -0,0 +1,105 @@
+/*
+ ZynAddSubFX - a software synthesizer
+
+ SUBnoteParameters.h - Parameters for SUBnote (SUBsynth)
+ Copyright (C) 2002-2005 Nasca Octavian Paul
+ Author: Nasca Octavian Paul
+
+ This program is free software; you can redistribute it and/or modify
+ it under the terms of version 2 of the GNU General Public License
+ as published by the Free Software Foundation.
+
+ This program is distributed in the hope that it will be useful,
+ but WITHOUT ANY WARRANTY; without even the implied warranty of
+ MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ GNU General Public License (version 2) for more details.
+
+ You should have received a copy of the GNU General Public License (version 2)
+ along with this program; if not, write to the Free Software Foundation,
+ Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
+
+*/
+
+#ifndef SUB_NOTE_PARAMETERS_H
+#define SUB_NOTE_PARAMETERS_H
+
+#include "../globals.h"
+#include "../Misc/XMLwrapper.h"
+#include "EnvelopeParams.h"
+#include "FilterParams.h"
+#include "Presets.h"
+
+class SUBnoteParameters:public Presets{
+ public:
+ SUBnoteParameters();
+ ~SUBnoteParameters();
+
+ void add2XML(XMLwrapper *xml);
+ void defaults();
+ void getfromXML(XMLwrapper *xml);
+
+ //Parameters
+ //AMPLITUDE PARAMETRERS
+ unsigned char Pstereo;//0 for mono,1 for stereo
+ unsigned char PVolume;
+ unsigned char PPanning;
+ unsigned char PAmpVelocityScaleFunction;
+ EnvelopeParams *AmpEnvelope;
+
+ //Frequency Parameters
+ unsigned short int PDetune;
+ unsigned short int PCoarseDetune;
+ unsigned char PDetuneType;
+ unsigned char PFreqEnvelopeEnabled;
+ EnvelopeParams *FreqEnvelope;
+ unsigned char PBandWidthEnvelopeEnabled;
+ EnvelopeParams *BandWidthEnvelope;
+
+ //Filter Parameters (Global)
+ unsigned char PGlobalFilterEnabled;
+ FilterParams *GlobalFilter;
+ unsigned char PGlobalFilterVelocityScale;
+ unsigned char PGlobalFilterVelocityScaleFunction;
+ EnvelopeParams *GlobalFilterEnvelope;
+
+
+ //Other Parameters
+
+ //If the base frequency is fixed to 440 Hz
+ unsigned char Pfixedfreq;
+
+ /* Equal temperate (this is used only if the Pfixedfreq is enabled)
+ If this parameter is 0, the frequency is fixed (to 440 Hz);
+ if this parameter is 64, 1 MIDI halftone -> 1 frequency halftone */
+ unsigned char PfixedfreqET;
+
+
+ //how many times the filters are applied
+ unsigned char Pnumstages;
+
+ //bandwidth
+ unsigned char Pbandwidth;
+
+ //How the magnitudes are computed (0=linear,1=-60dB,2=-60dB)
+ unsigned char Phmagtype;
+
+ //Magnitudes
+ unsigned char Phmag[MAX_SUB_HARMONICS];
+
+ //Relative BandWidth ("64"=1.0)
+ unsigned char Phrelbw[MAX_SUB_HARMONICS];
+
+ //how much the bandwidth is increased according to lower/higher frequency; 64-default
+ unsigned char Pbwscale;
+
+ //how the harmonics start("0"=0,"1"=random,"2"=1)
+ unsigned char Pstart;
+
+
+ private:
+};
+
+#endif
+
+
+