home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Complet / ZynAddFX / Setup_ZynAddSubFX-2.1.1.exe / ADnoteParameters.C < prev    next >
Encoding:
C/C++ Source or Header  |  2004-09-27  |  21.1 KB  |  623 lines

  1. /*
  2.   ZynAddSubFX - a software synthesizer
  3.  
  4.   ADnoteParameters.C - Parameters for ADnote (ADsynth)
  5.   Copyright (C) 2002-2004 Nasca Octavian Paul
  6.   Author: Nasca Octavian Paul
  7.  
  8.   This program is free software; you can redistribute it and/or modify
  9.   it under the terms of version 2 of the GNU General Public License 
  10.   as published by the Free Software Foundation.
  11.  
  12.   This program is distributed in the hope that it will be useful,
  13.   but WITHOUT ANY WARRANTY; without even the implied warranty of
  14.   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
  15.   GNU General Public License (version 2) for more details.
  16.  
  17.   You should have received a copy of the GNU General Public License (version 2)
  18.   along with this program; if not, write to the Free Software Foundation,
  19.   Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307 USA
  20.  
  21. */
  22.  
  23. #include <stdlib.h>
  24. #include <stdio.h>
  25. #include <math.h>
  26.  
  27. #include "ADnoteParameters.h"
  28.  
  29. ADnoteParameters::ADnoteParameters(FFTwrapper *fft_):Presets(){
  30.     setpresettype("Padsyth");
  31.     fft=fft_;
  32.  
  33.     GlobalPar.FreqEnvelope=new EnvelopeParams(0,0);
  34.     GlobalPar.FreqEnvelope->ASRinit(64,50,64,60);
  35.     GlobalPar.FreqLfo=new LFOParams(70,0,64,0,0,0,0,0);
  36.     
  37.     GlobalPar.AmpEnvelope=new EnvelopeParams(64,1);
  38.     GlobalPar.AmpEnvelope->ADSRinit_dB(0,40,127,25);
  39.     GlobalPar.AmpLfo=new LFOParams(80,0,64,0,0,0,0,1);
  40.  
  41.     GlobalPar.GlobalFilter=new FilterParams(2,94,40);
  42.     GlobalPar.FilterEnvelope=new EnvelopeParams(0,1);
  43.     GlobalPar.FilterEnvelope->ADSRinit_filter(64,40,64,70,60,64);
  44.     GlobalPar.FilterLfo=new LFOParams(80,0,64,0,0,0,0,2);
  45.     GlobalPar.Reson=new Resonance();
  46.  
  47.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++) EnableVoice(nvoice);
  48.     
  49.     defaults();
  50. };
  51.  
  52. void ADnoteParameters::defaults(){
  53.     //Default Parameters
  54.     /* Frequency Global Parameters */
  55.     GlobalPar.PStereo=1;//stereo
  56.     GlobalPar.PDetune=8192;//zero
  57.     GlobalPar.PCoarseDetune=0;
  58.     GlobalPar.PDetuneType=1;
  59.     GlobalPar.FreqEnvelope->defaults();
  60.     GlobalPar.FreqLfo->defaults();
  61.     
  62.     /* Amplitude Global Parameters */
  63.     GlobalPar.PVolume=90;
  64.     GlobalPar.PPanning=64;//center
  65.     GlobalPar.PAmpVelocityScaleFunction=64;
  66.     GlobalPar.AmpEnvelope->defaults();
  67.     GlobalPar.AmpLfo->defaults();
  68.     GlobalPar.PPunchStrength=0;
  69.     GlobalPar.PPunchTime=60;
  70.     GlobalPar.PPunchStretch=64;
  71.     GlobalPar.PPunchVelocitySensing=72;
  72.     GlobalPar.Hrandgrouping=0;
  73.     
  74.     /* Filter Global Parameters*/
  75.     GlobalPar.PFilterVelocityScale=64;
  76.     GlobalPar.PFilterVelocityScaleFunction=64;
  77.     GlobalPar.GlobalFilter->defaults();
  78.     GlobalPar.FilterEnvelope->defaults();
  79.     GlobalPar.FilterLfo->defaults();
  80.     GlobalPar.Reson->defaults();
  81.  
  82.  
  83.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  84.     defaults(nvoice);
  85.     };
  86.     VoicePar[0].Enabled=1;
  87. };
  88.  
  89. /*
  90.  * Defaults a voice
  91.  */
  92. void ADnoteParameters::defaults(int n){
  93.     int nvoice=n;
  94.     VoicePar[nvoice].Enabled=0;
  95.     VoicePar[nvoice].Type=0;
  96.     VoicePar[nvoice].Pfixedfreq=0;
  97.     VoicePar[nvoice].PfixedfreqET=0;
  98.     VoicePar[nvoice].Presonance=1;
  99.     VoicePar[nvoice].Pfilterbypass=0;
  100.     VoicePar[nvoice].Pextoscil=-1;
  101.     VoicePar[nvoice].PextFMoscil=-1;
  102.     VoicePar[nvoice].Poscilphase=64;
  103.     VoicePar[nvoice].PFMoscilphase=64;
  104.     VoicePar[nvoice].PDelay=0;
  105.     VoicePar[nvoice].PVolume=100;
  106.     VoicePar[nvoice].PVolumeminus=0;
  107.     VoicePar[nvoice].PPanning=64;//center
  108.     VoicePar[nvoice].PDetune=8192;//8192=0
  109.     VoicePar[nvoice].PCoarseDetune=0;
  110.     VoicePar[nvoice].PDetuneType=0;
  111.     VoicePar[nvoice].PFreqLfoEnabled=0;
  112.     VoicePar[nvoice].PFreqEnvelopeEnabled=0;
  113.     VoicePar[nvoice].PAmpEnvelopeEnabled=0;
  114.     VoicePar[nvoice].PAmpLfoEnabled=0;
  115.     VoicePar[nvoice].PAmpVelocityScaleFunction=127;
  116.     VoicePar[nvoice].PFilterEnabled=0;
  117.     VoicePar[nvoice].PFilterEnvelopeEnabled=0;
  118.     VoicePar[nvoice].PFilterLfoEnabled=0;
  119.     VoicePar[nvoice].PFMEnabled=0;
  120.  
  121.     //I use the internal oscillator (-1)
  122.     VoicePar[nvoice].PFMVoice=-1;
  123.  
  124.     VoicePar[nvoice].PFMVolume=90;
  125.     VoicePar[nvoice].PFMVolumeDamp=64;
  126.     VoicePar[nvoice].PFMDetune=8192;
  127.     VoicePar[nvoice].PFMCoarseDetune=0;
  128.     VoicePar[nvoice].PFMDetuneType=0;
  129.     VoicePar[nvoice].PFMFreqEnvelopeEnabled=0;
  130.     VoicePar[nvoice].PFMAmpEnvelopeEnabled=0;
  131.     VoicePar[nvoice].PFMVelocityScaleFunction=64;    
  132.  
  133.     VoicePar[nvoice].OscilSmp->defaults();
  134.     VoicePar[nvoice].FMSmp->defaults();
  135.  
  136.     VoicePar[nvoice].AmpEnvelope->defaults();
  137.     VoicePar[nvoice].AmpLfo->defaults();
  138.  
  139.     VoicePar[nvoice].FreqEnvelope->defaults();
  140.     VoicePar[nvoice].FreqLfo->defaults();
  141.  
  142.     VoicePar[nvoice].VoiceFilter->defaults();
  143.     VoicePar[nvoice].FilterEnvelope->defaults();
  144.     VoicePar[nvoice].FilterLfo->defaults();
  145.  
  146.     VoicePar[nvoice].FMFreqEnvelope->defaults();
  147.     VoicePar[nvoice].FMAmpEnvelope->defaults();
  148. };
  149.  
  150.  
  151.  
  152. /*
  153.  * Init the voice parameters
  154.  */
  155. void ADnoteParameters::EnableVoice(int nvoice){
  156.     VoicePar[nvoice].OscilSmp=new OscilGen(fft,GlobalPar.Reson);
  157.     VoicePar[nvoice].FMSmp=new OscilGen(fft,NULL);
  158.  
  159.     VoicePar[nvoice].AmpEnvelope=new EnvelopeParams(64,1);
  160.     VoicePar[nvoice].AmpEnvelope->ADSRinit_dB(0,100,127,100);    
  161.     VoicePar[nvoice].AmpLfo=new LFOParams(90,32,64,0,0,30,0,1);
  162.  
  163.     VoicePar[nvoice].FreqEnvelope=new EnvelopeParams(0,0);
  164.     VoicePar[nvoice].FreqEnvelope->ASRinit(30,40,64,60);
  165.     VoicePar[nvoice].FreqLfo=new LFOParams(50,40,0,0,0,0,0,0);
  166.  
  167.     VoicePar[nvoice].VoiceFilter=new FilterParams(2,50,60);
  168.     VoicePar[nvoice].FilterEnvelope=new EnvelopeParams(0,0);
  169.     VoicePar[nvoice].FilterEnvelope->ADSRinit_filter(90,70,40,70,10,40);
  170.     VoicePar[nvoice].FilterLfo=new LFOParams(50,20,64,0,0,0,0,2);
  171.  
  172.     VoicePar[nvoice].FMFreqEnvelope=new EnvelopeParams(0,0);
  173.     VoicePar[nvoice].FMFreqEnvelope->ASRinit(20,90,40,80);
  174.     VoicePar[nvoice].FMAmpEnvelope=new EnvelopeParams(64,1);
  175.     VoicePar[nvoice].FMAmpEnvelope->ADSRinit(80,90,127,100);
  176. };
  177.  
  178.  
  179. /*
  180.  * Kill the voice
  181.  */
  182. void ADnoteParameters::KillVoice(int nvoice){
  183.     delete (VoicePar[nvoice].OscilSmp);
  184.     delete (VoicePar[nvoice].FMSmp);
  185.  
  186.     delete (VoicePar[nvoice].AmpEnvelope);
  187.     delete (VoicePar[nvoice].AmpLfo);
  188.  
  189.     delete (VoicePar[nvoice].FreqEnvelope);
  190.     delete (VoicePar[nvoice].FreqLfo);
  191.  
  192.     delete (VoicePar[nvoice].VoiceFilter);
  193.     delete (VoicePar[nvoice].FilterEnvelope);
  194.     delete (VoicePar[nvoice].FilterLfo);
  195.  
  196.     delete (VoicePar[nvoice].FMFreqEnvelope);
  197.     delete (VoicePar[nvoice].FMAmpEnvelope);
  198. };
  199.  
  200. ADnoteParameters::~ADnoteParameters(){
  201.     delete(GlobalPar.FreqEnvelope);
  202.     delete(GlobalPar.FreqLfo);
  203.     delete(GlobalPar.AmpEnvelope);
  204.     delete(GlobalPar.AmpLfo);
  205.     delete(GlobalPar.GlobalFilter);
  206.     delete(GlobalPar.FilterEnvelope);
  207.     delete(GlobalPar.FilterLfo);
  208.     delete(GlobalPar.Reson);
  209.  
  210.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  211.         KillVoice(nvoice);
  212.     };
  213. };
  214.  
  215.  
  216.  
  217.  
  218. void ADnoteParameters::add2XMLsection(XMLwrapper *xml,int n){
  219.     int nvoice=n;
  220.     if (nvoice>=NUM_VOICES) return;
  221.     
  222.     int oscilused=0,fmoscilused=0;//if the oscil or fmoscil are used by another voice
  223.  
  224.     for (int i=0;i<NUM_VOICES;i++){
  225.     if (VoicePar[i].Pextoscil==nvoice) oscilused=1;
  226.     if (VoicePar[i].PextFMoscil==nvoice) fmoscilused=1;
  227.     };
  228.     
  229.     xml->addparbool("enabled",VoicePar[nvoice].Enabled);
  230.     if (((VoicePar[nvoice].Enabled==0)&&(oscilused==0)&&(fmoscilused==0))&&(xml->minimal)) return;
  231.  
  232.     xml->addpar("type",VoicePar[nvoice].Type);
  233.     xml->addpar("delay",VoicePar[nvoice].PDelay);
  234.     xml->addparbool("resonance",VoicePar[nvoice].Presonance);
  235.     
  236.     xml->addpar("ext_oscil",VoicePar[nvoice].Pextoscil);
  237.     xml->addpar("ext_fm_oscil",VoicePar[nvoice].PextFMoscil);
  238.  
  239.     xml->addpar("oscil_phase",VoicePar[nvoice].Poscilphase);
  240.     xml->addpar("oscil_fm_phase",VoicePar[nvoice].PFMoscilphase);
  241.  
  242.     xml->addparbool("filter_enabled",VoicePar[nvoice].PFilterEnabled);
  243.     xml->addparbool("filter_bypass",VoicePar[nvoice].Pfilterbypass);
  244.  
  245.     xml->addpar("fm_enabled",VoicePar[nvoice].PFMEnabled);
  246.  
  247.     xml->beginbranch("OSCIL");
  248.     VoicePar[nvoice].OscilSmp->add2XML(xml);
  249.     xml->endbranch();
  250.  
  251.  
  252.     xml->beginbranch("AMPLITUDE_PARAMETERS");
  253.     xml->addpar("panning",VoicePar[nvoice].PPanning);
  254.         xml->addpar("volume",VoicePar[nvoice].PVolume);
  255.         xml->addparbool("volume_minus",VoicePar[nvoice].PVolumeminus);
  256.         xml->addpar("velocity_sensing",VoicePar[nvoice].PAmpVelocityScaleFunction);
  257.  
  258.     xml->addparbool("amp_envelope_enabled",VoicePar[nvoice].PAmpEnvelopeEnabled);
  259.     if ((VoicePar[nvoice].PAmpEnvelopeEnabled!=0)||(!xml->minimal)){
  260.         xml->beginbranch("AMPLITUDE_ENVELOPE");
  261.         VoicePar[nvoice].AmpEnvelope->add2XML(xml);
  262.         xml->endbranch();
  263.     };
  264.     xml->addparbool("amp_lfo_enabled",VoicePar[nvoice].PAmpLfoEnabled);
  265.     if ((VoicePar[nvoice].PAmpLfoEnabled!=0)||(!xml->minimal)){
  266.         xml->beginbranch("AMPLITUDE_LFO");
  267.         VoicePar[nvoice].AmpLfo->add2XML(xml);
  268.         xml->endbranch();
  269.     };
  270.     xml->endbranch();
  271.  
  272.     xml->beginbranch("FREQUENCY_PARAMETERS");
  273.     xml->addparbool("fixed_freq",VoicePar[nvoice].Pfixedfreq);
  274.     xml->addpar("fixed_freq_et",VoicePar[nvoice].PfixedfreqET);
  275.     xml->addpar("detune",VoicePar[nvoice].PDetune);
  276.     xml->addpar("coarse_detune",VoicePar[nvoice].PCoarseDetune);
  277.     xml->addpar("detune_type",VoicePar[nvoice].PDetuneType);
  278.  
  279.     xml->addparbool("freq_envelope_enabled",VoicePar[nvoice].PFreqEnvelopeEnabled);
  280.     if ((VoicePar[nvoice].PFreqEnvelopeEnabled!=0)||(!xml->minimal)){
  281.         xml->beginbranch("FREQUENCY_ENVELOPE");
  282.         VoicePar[nvoice].FreqEnvelope->add2XML(xml);
  283.         xml->endbranch();
  284.     };
  285.     xml->addparbool("freq_lfo_enabled",VoicePar[nvoice].PFreqLfoEnabled);
  286.     if ((VoicePar[nvoice].PFreqLfoEnabled!=0)||(!xml->minimal)){
  287.         xml->beginbranch("FREQUENCY_LFO");
  288.         VoicePar[nvoice].FreqLfo->add2XML(xml);
  289.         xml->endbranch();
  290.     };
  291.     xml->endbranch();
  292.  
  293.  
  294.     if ((VoicePar[nvoice].PFilterEnabled!=0)||(!xml->minimal)){
  295.     xml->beginbranch("FILTER_PARAMETERS");
  296.         xml->beginbranch("FILTER");
  297.         VoicePar[nvoice].VoiceFilter->add2XML(xml);
  298.         xml->endbranch();
  299.  
  300.         xml->addparbool("filter_envelope_enabled",VoicePar[nvoice].PFilterEnvelopeEnabled);
  301.         if ((VoicePar[nvoice].PFilterEnvelopeEnabled!=0)||(!xml->minimal)){
  302.         xml->beginbranch("FILTER_ENVELOPE");
  303.             VoicePar[nvoice].FilterEnvelope->add2XML(xml);
  304.         xml->endbranch();
  305.         };
  306.  
  307.         xml->addparbool("filter_lfo_enabled",VoicePar[nvoice].PFilterLfoEnabled);
  308.         if ((VoicePar[nvoice].PFilterLfoEnabled!=0)||(!xml->minimal)){
  309.         xml->beginbranch("FILTER_LFO");
  310.             VoicePar[nvoice].FilterLfo->add2XML(xml);
  311.         xml->endbranch();
  312.         };
  313.     xml->endbranch();
  314.     };
  315.  
  316.     if ((VoicePar[nvoice].PFMEnabled!=0)||(fmoscilused!=0)||(!xml->minimal)){
  317.     xml->beginbranch("FM_PARAMETERS");
  318.         xml->addpar("input_voice",VoicePar[nvoice].PFMVoice);
  319.  
  320.             xml->addpar("volume",VoicePar[nvoice].PFMVolume);
  321.             xml->addpar("volume_damp",VoicePar[nvoice].PFMVolumeDamp);
  322.             xml->addpar("velocity_sensing",VoicePar[nvoice].PFMVelocityScaleFunction);
  323.  
  324.         xml->addparbool("amp_envelope_enabled",VoicePar[nvoice].PFMAmpEnvelopeEnabled);
  325.         if ((VoicePar[nvoice].PFMAmpEnvelopeEnabled!=0)||(!xml->minimal)){
  326.         xml->beginbranch("AMPLITUDE_ENVELOPE");
  327.             VoicePar[nvoice].FMAmpEnvelope->add2XML(xml);
  328.         xml->endbranch();
  329.         };
  330.         xml->beginbranch("MODULATOR");
  331.             xml->addpar("detune",VoicePar[nvoice].PFMDetune);
  332.             xml->addpar("coarse_detune",VoicePar[nvoice].PFMCoarseDetune);
  333.             xml->addpar("detune_type",VoicePar[nvoice].PFMDetuneType);
  334.  
  335.         xml->addparbool("freq_envelope_enabled",VoicePar[nvoice].PFMFreqEnvelopeEnabled);
  336.         if ((VoicePar[nvoice].PFMFreqEnvelopeEnabled!=0)||(!xml->minimal)){
  337.             xml->beginbranch("FREQUENCY_ENVELOPE");
  338.             VoicePar[nvoice].FMFreqEnvelope->add2XML(xml);
  339.             xml->endbranch();
  340.         };
  341.  
  342.         xml->beginbranch("OSCIL");
  343.             VoicePar[nvoice].FMSmp->add2XML(xml);
  344.         xml->endbranch();
  345.  
  346.         xml->endbranch();
  347.     xml->endbranch();
  348.     };
  349. };
  350.  
  351.  
  352. void ADnoteParameters::add2XML(XMLwrapper *xml){
  353.     xml->addparbool("stereo",GlobalPar.PStereo);
  354.  
  355.     xml->beginbranch("AMPLITUDE_PARAMETERS");
  356.     xml->addpar("volume",GlobalPar.PVolume);
  357.     xml->addpar("panning",GlobalPar.PPanning);
  358.     xml->addpar("velocity_sensing",GlobalPar.PAmpVelocityScaleFunction);
  359.     xml->addpar("punch_strength",GlobalPar.PPunchStrength);
  360.     xml->addpar("punch_time",GlobalPar.PPunchTime);
  361.     xml->addpar("punch_stretch",GlobalPar.PPunchStretch);
  362.     xml->addpar("punch_velocity_sensing",GlobalPar.PPunchVelocitySensing);
  363.     xml->addpar("harmonic_randomness_grouping",GlobalPar.Hrandgrouping);
  364.     
  365.     xml->beginbranch("AMPLITUDE_ENVELOPE");
  366.         GlobalPar.AmpEnvelope->add2XML(xml);
  367.     xml->endbranch();
  368.     
  369.     xml->beginbranch("AMPLITUDE_LFO");
  370.         GlobalPar.AmpLfo->add2XML(xml);
  371.     xml->endbranch();
  372.     xml->endbranch();
  373.  
  374.     xml->beginbranch("FREQUENCY_PARAMETERS");
  375.     xml->addpar("detune",GlobalPar.PDetune);
  376.     
  377.     xml->addpar("coarse_detune",GlobalPar.PCoarseDetune);
  378.         xml->addpar("detune_type",GlobalPar.PDetuneType);
  379.     
  380.     xml->beginbranch("FREQUENCY_ENVELOPE");
  381.         GlobalPar.FreqEnvelope->add2XML(xml);
  382.     xml->endbranch();
  383.     
  384.     xml->beginbranch("FREQUENCY_LFO");
  385.         GlobalPar.FreqLfo->add2XML(xml);
  386.     xml->endbranch();
  387.     xml->endbranch();
  388.     
  389.     
  390.     xml->beginbranch("FILTER_PARAMETERS");
  391.     xml->addpar("velocity_sensing_amplitude",GlobalPar.PFilterVelocityScale);
  392.     xml->addpar("velocity_sensing",GlobalPar.PFilterVelocityScaleFunction);
  393.     
  394.     xml->beginbranch("FILTER");
  395.         GlobalPar.GlobalFilter->add2XML(xml);
  396.     xml->endbranch();
  397.     
  398.     xml->beginbranch("FILTER_ENVELOPE");
  399.         GlobalPar.FilterEnvelope->add2XML(xml);
  400.     xml->endbranch();
  401.     
  402.     xml->beginbranch("FILTER_LFO");
  403.         GlobalPar.FilterLfo->add2XML(xml);
  404.     xml->endbranch();
  405.     xml->endbranch();
  406.     
  407.     xml->beginbranch("RESONANCE");
  408.         GlobalPar.Reson->add2XML(xml);
  409.     xml->endbranch();
  410.  
  411.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  412.     xml->beginbranch("VOICE",nvoice);
  413.         add2XMLsection(xml,nvoice);
  414.     xml->endbranch();
  415.     };
  416. };
  417.  
  418.  
  419. void ADnoteParameters::getfromXML(XMLwrapper *xml){
  420.     GlobalPar.PStereo=xml->getparbool("stereo",GlobalPar.PStereo);
  421.     
  422.     if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
  423.     GlobalPar.PVolume=xml->getpar127("volume",GlobalPar.PVolume);
  424.     GlobalPar.PPanning=xml->getpar127("panning",GlobalPar.PPanning);
  425.     GlobalPar.PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",GlobalPar.PAmpVelocityScaleFunction);
  426.  
  427.     GlobalPar.PPunchStrength=xml->getpar127("punch_strength",GlobalPar.PPunchStrength);
  428.     GlobalPar.PPunchTime=xml->getpar127("punch_time",GlobalPar.PPunchTime);
  429.     GlobalPar.PPunchStretch=xml->getpar127("punch_stretch",GlobalPar.PPunchStretch);
  430.     GlobalPar.PPunchVelocitySensing=xml->getpar127("punch_velocity_sensing",GlobalPar.PPunchVelocitySensing);
  431.     GlobalPar.Hrandgrouping=xml->getpar127("harmonic_randomness_grouping",GlobalPar.Hrandgrouping);
  432.     
  433.     if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  434.         GlobalPar.AmpEnvelope->getfromXML(xml);
  435.         xml->exitbranch();
  436.     };
  437.     
  438.     if (xml->enterbranch("AMPLITUDE_LFO")){
  439.         GlobalPar.AmpLfo->getfromXML(xml);
  440.         xml->exitbranch();
  441.     };
  442.     
  443.       xml->exitbranch();
  444.     };
  445.  
  446.     if (xml->enterbranch("FREQUENCY_PARAMETERS")){
  447.     GlobalPar.PDetune=xml->getpar("detune",GlobalPar.PDetune,0,16383);
  448.     GlobalPar.PCoarseDetune=xml->getpar("coarse_detune",GlobalPar.PCoarseDetune,0,16383);
  449.         GlobalPar.PDetuneType=xml->getpar127("detune_type",GlobalPar.PDetuneType);
  450.     
  451.     xml->enterbranch("FREQUENCY_ENVELOPE");
  452.         GlobalPar.FreqEnvelope->getfromXML(xml);
  453.     xml->exitbranch();
  454.     
  455.     xml->enterbranch("FREQUENCY_LFO");
  456.         GlobalPar.FreqLfo->getfromXML(xml);
  457.     xml->exitbranch();
  458.  
  459.       xml->exitbranch();
  460.     };
  461.     
  462.     
  463.     if (xml->enterbranch("FILTER_PARAMETERS")){
  464.     GlobalPar.PFilterVelocityScale=xml->getpar127("velocity_sensing_amplitude",GlobalPar.PFilterVelocityScale);
  465.     GlobalPar.PFilterVelocityScaleFunction=xml->getpar127("velocity_sensing",GlobalPar.PFilterVelocityScaleFunction);
  466.     
  467.     xml->enterbranch("FILTER");
  468.         GlobalPar.GlobalFilter->getfromXML(xml);
  469.     xml->exitbranch();
  470.     
  471.     xml->enterbranch("FILTER_ENVELOPE");
  472.         GlobalPar.FilterEnvelope->getfromXML(xml);
  473.     xml->exitbranch();
  474.     
  475.     xml->enterbranch("FILTER_LFO");
  476.         GlobalPar.FilterLfo->getfromXML(xml);
  477.     xml->exitbranch();
  478.      xml->exitbranch();
  479.     };
  480.  
  481.     if (xml->enterbranch("RESONANCE")){
  482.     GlobalPar.Reson->getfromXML(xml);
  483.      xml->exitbranch();
  484.     };
  485.  
  486.     for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){
  487.     VoicePar[nvoice].Enabled=0;
  488.     if (xml->enterbranch("VOICE",nvoice)==0) continue;
  489.         getfromXMLsection(xml,nvoice);
  490.     xml->exitbranch();
  491.     };
  492.     
  493.     
  494. };
  495.  
  496. void ADnoteParameters::getfromXMLsection(XMLwrapper *xml,int n){
  497.     int nvoice=n;
  498.     if (nvoice>=NUM_VOICES) return;
  499.  
  500.     VoicePar[nvoice].Enabled=xml->getparbool("enabled",0);
  501.  
  502.     VoicePar[nvoice].Type=xml->getpar127("type",VoicePar[nvoice].Type);
  503.     VoicePar[nvoice].PDelay=xml->getpar127("delay",VoicePar[nvoice].PDelay);
  504.     VoicePar[nvoice].Presonance=xml->getparbool("resonance",VoicePar[nvoice].Presonance);
  505.     
  506.     VoicePar[nvoice].Pextoscil=xml->getpar("ext_oscil",-1,-1,nvoice-1);
  507.     VoicePar[nvoice].PextFMoscil=xml->getpar("ext_fm_oscil",-1,-1,nvoice-1);
  508.  
  509.     VoicePar[nvoice].Poscilphase=xml->getpar127("oscil_phase",VoicePar[nvoice].Poscilphase);
  510.     VoicePar[nvoice].PFMoscilphase=xml->getpar127("oscil_fm_phase",VoicePar[nvoice].PFMoscilphase);
  511.  
  512.     VoicePar[nvoice].PFilterEnabled=xml->getparbool("filter_enabled",VoicePar[nvoice].PFilterEnabled);
  513.     VoicePar[nvoice].Pfilterbypass=xml->getparbool("filter_bypass",VoicePar[nvoice].Pfilterbypass);
  514.  
  515.     VoicePar[nvoice].PFMEnabled=xml->getpar127("fm_enabled",VoicePar[nvoice].PFMEnabled);
  516.  
  517.     if (xml->enterbranch("OSCIL")){
  518.     VoicePar[nvoice].OscilSmp->getfromXML(xml);
  519.      xml->exitbranch();
  520.     };
  521.  
  522.  
  523.     if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
  524.     VoicePar[nvoice].PPanning=xml->getpar127("panning",VoicePar[nvoice].PPanning);
  525.     VoicePar[nvoice].PVolume=xml->getpar127("volume",VoicePar[nvoice].PVolume);
  526.         VoicePar[nvoice].PVolumeminus=xml->getparbool("volume_minus",VoicePar[nvoice].PVolumeminus);
  527.         VoicePar[nvoice].PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",VoicePar[nvoice].PAmpVelocityScaleFunction);
  528.  
  529.     VoicePar[nvoice].PAmpEnvelopeEnabled=xml->getparbool("amp_envelope_enabled",VoicePar[nvoice].PAmpEnvelopeEnabled);
  530.     if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  531.         VoicePar[nvoice].AmpEnvelope->getfromXML(xml);
  532.         xml->exitbranch();
  533.     };
  534.  
  535.     VoicePar[nvoice].PAmpLfoEnabled=xml->getparbool("amp_lfo_enabled",VoicePar[nvoice].PAmpLfoEnabled);
  536.     if (xml->enterbranch("AMPLITUDE_LFO")){
  537.         VoicePar[nvoice].AmpLfo->getfromXML(xml);
  538.         xml->exitbranch();
  539.     };
  540.      xml->exitbranch();
  541.     };
  542.  
  543.     if (xml->enterbranch("FREQUENCY_PARAMETERS")){
  544.     VoicePar[nvoice].Pfixedfreq=xml->getparbool("fixed_freq",VoicePar[nvoice].Pfixedfreq);
  545.     VoicePar[nvoice].PfixedfreqET=xml->getpar127("fixed_freq_et",VoicePar[nvoice].PfixedfreqET);
  546.     
  547.     
  548.     VoicePar[nvoice].PDetune=xml->getpar("detune",VoicePar[nvoice].PDetune,0,16383);
  549.     
  550.     VoicePar[nvoice].PCoarseDetune=xml->getpar("coarse_detune",VoicePar[nvoice].PCoarseDetune,0,16383);
  551.     VoicePar[nvoice].PDetuneType=xml->getpar127("detune_type",VoicePar[nvoice].PDetuneType);
  552.  
  553.     VoicePar[nvoice].PFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",VoicePar[nvoice].PFreqEnvelopeEnabled);
  554.     if (xml->enterbranch("FREQUENCY_ENVELOPE")){
  555.         VoicePar[nvoice].FreqEnvelope->getfromXML(xml);
  556.         xml->exitbranch();
  557.     };
  558.  
  559.     VoicePar[nvoice].PFreqLfoEnabled=xml->getparbool("freq_lfo_enabled",VoicePar[nvoice].PFreqLfoEnabled);
  560.     if (xml->enterbranch("FREQUENCY_LFO")){
  561.         VoicePar[nvoice].FreqLfo->getfromXML(xml);
  562.         xml->exitbranch();
  563.     };
  564.      xml->exitbranch();
  565.     };
  566.  
  567.     if (xml->enterbranch("FILTER_PARAMETERS")){
  568.         if (xml->enterbranch("FILTER")){
  569.         VoicePar[nvoice].VoiceFilter->getfromXML(xml);
  570.             xml->exitbranch();
  571.         };
  572.  
  573.         VoicePar[nvoice].PFilterEnvelopeEnabled=xml->getparbool("filter_envelope_enabled",VoicePar[nvoice].PFilterEnvelopeEnabled);
  574.         if (xml->enterbranch("FILTER_ENVELOPE")){
  575.         VoicePar[nvoice].FilterEnvelope->getfromXML(xml);
  576.         xml->exitbranch();
  577.         };
  578.  
  579.         VoicePar[nvoice].PFilterLfoEnabled=xml->getparbool("filter_lfo_enabled",VoicePar[nvoice].PFilterLfoEnabled);
  580.         if (xml->enterbranch("FILTER_LFO")){
  581.         VoicePar[nvoice].FilterLfo->getfromXML(xml);
  582.         xml->exitbranch();
  583.         };
  584.     xml->exitbranch();
  585.     };
  586.  
  587.     if (xml->enterbranch("FM_PARAMETERS")){
  588.         VoicePar[nvoice].PFMVoice=xml->getpar("input_voice",VoicePar[nvoice].PFMVoice,-1,nvoice-1);
  589.  
  590.             VoicePar[nvoice].PFMVolume=xml->getpar127("volume",VoicePar[nvoice].PFMVolume);
  591.             VoicePar[nvoice].PFMVolumeDamp=xml->getpar127("volume_damp",VoicePar[nvoice].PFMVolumeDamp);
  592.             VoicePar[nvoice].PFMVelocityScaleFunction=xml->getpar127("velocity_sensing",VoicePar[nvoice].PFMVelocityScaleFunction);
  593.  
  594.         VoicePar[nvoice].PFMAmpEnvelopeEnabled=xml->getparbool("amp_envelope_enabled",VoicePar[nvoice].PFMAmpEnvelopeEnabled);
  595.         if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  596.         VoicePar[nvoice].FMAmpEnvelope->getfromXML(xml);
  597.         xml->exitbranch();
  598.         };
  599.         
  600.         if (xml->enterbranch("MODULATOR")){
  601.             VoicePar[nvoice].PFMDetune=xml->getpar("detune",VoicePar[nvoice].PFMDetune,0,16383);
  602.             VoicePar[nvoice].PFMCoarseDetune=xml->getpar("coarse_detune",VoicePar[nvoice].PFMCoarseDetune,0,16383);
  603.             VoicePar[nvoice].PFMDetuneType=xml->getpar127("detune_type",VoicePar[nvoice].PFMDetuneType);
  604.  
  605.         VoicePar[nvoice].PFMFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",VoicePar[nvoice].PFMFreqEnvelopeEnabled);
  606.         if (xml->enterbranch("FREQUENCY_ENVELOPE")){
  607.             VoicePar[nvoice].FMFreqEnvelope->getfromXML(xml);
  608.             xml->exitbranch();
  609.         };
  610.  
  611.         if (xml->enterbranch("OSCIL")){
  612.             VoicePar[nvoice].FMSmp->getfromXML(xml);
  613.             xml->exitbranch();
  614.         };
  615.     
  616.            xml->exitbranch();
  617.         };
  618.     xml->exitbranch();
  619.     };
  620. };
  621.  
  622.  
  623.