home *** CD-ROM | disk | FTP | other *** search
/ Chip 2004 November / CMCD1104.ISO / Software / Complet / ZynAddFX / Setup_ZynAddSubFX-2.1.1.exe / SUBnoteParameters.C < prev    next >
Encoding:
C/C++ Source or Header  |  2004-08-24  |  6.8 KB  |  239 lines

  1. /*
  2.   ZynAddSubFX - a software synthesizer
  3.  
  4.   SUBnoteParameters.C - Parameters for SUBnote (SUBsynth)  
  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 "../globals.h"
  24. #include "SUBnoteParameters.h"
  25. #include <stdio.h>
  26.  
  27. SUBnoteParameters::SUBnoteParameters():Presets(){
  28.     setpresettype("Psubsyth");
  29.     AmpEnvelope=new EnvelopeParams(64,1);
  30.     AmpEnvelope->ADSRinit_dB(0,40,127,25);
  31.     FreqEnvelope=new EnvelopeParams(64,0);
  32.     FreqEnvelope->ASRinit(30,50,64,60);
  33.     BandWidthEnvelope=new EnvelopeParams(64,0);
  34.     BandWidthEnvelope->ASRinit_bw(100,70,64,60);
  35.  
  36.     GlobalFilter=new FilterParams(2,80,40);
  37.     GlobalFilterEnvelope=new EnvelopeParams(0,1);
  38.     GlobalFilterEnvelope->ADSRinit_filter(64,40,64,70,60,64);
  39.     
  40.     defaults();
  41. };
  42.  
  43.  
  44. void SUBnoteParameters::defaults(){
  45.     PVolume=96;    
  46.     PPanning=64;
  47.     PAmpVelocityScaleFunction=90;
  48.     
  49.     Pfixedfreq=0;
  50.     PfixedfreqET=0;
  51.     Pnumstages=2;
  52.     Pbandwidth=40;
  53.     Phmagtype=0;
  54.     Pbwscale=64;
  55.     Pstereo=1;
  56.     Pstart=1;
  57.  
  58.     PDetune=8192;
  59.     PCoarseDetune=0;
  60.     PDetuneType=1;
  61.     PFreqEnvelopeEnabled=0;
  62.     PBandWidthEnvelopeEnabled=0;
  63.     
  64.     for (int n=0;n<MAX_SUB_HARMONICS;n++){
  65.     Phmag[n]=0;
  66.     Phrelbw[n]=64;
  67.     };
  68.     Phmag[0]=127;
  69.  
  70.     PGlobalFilterEnabled=0;
  71.     PGlobalFilterVelocityScale=64;
  72.     PGlobalFilterVelocityScaleFunction=64;
  73.  
  74.     AmpEnvelope->defaults();
  75.     FreqEnvelope->defaults();
  76.     BandWidthEnvelope->defaults();
  77.     GlobalFilter->defaults();
  78.     GlobalFilterEnvelope->defaults();
  79.  
  80. };
  81.  
  82.  
  83.  
  84. SUBnoteParameters::~SUBnoteParameters(){
  85.     delete (AmpEnvelope);
  86.     delete (FreqEnvelope);
  87.     delete (BandWidthEnvelope);
  88.     delete (GlobalFilter);
  89.     delete (GlobalFilterEnvelope);
  90. };
  91.  
  92.  
  93.  
  94.  
  95. void SUBnoteParameters::add2XML(XMLwrapper *xml){
  96.     xml->addpar("num_stages",Pnumstages);
  97.     xml->addpar("harmonic_mag_type",Phmagtype);
  98.     xml->addpar("start",Pstart);
  99.     
  100.     xml->beginbranch("HARMONICS");
  101.     for (int i=0;i<MAX_SUB_HARMONICS;i++){
  102.         if ((Phmag[i]==0)&&(xml->minimal)) continue;
  103.         xml->beginbranch("HARMONIC",i);
  104.         xml->addpar("mag",Phmag[i]);
  105.         xml->addpar("relbw",Phrelbw[i]);
  106.         xml->endbranch();
  107.     };
  108.     xml->endbranch();
  109.  
  110.     xml->beginbranch("AMPLITUDE_PARAMETERS");
  111.     xml->addparbool("stereo",Pstereo);
  112.     xml->addpar("volume",PVolume);
  113.     xml->addpar("panning",PPanning);
  114.     xml->addpar("velocity_sensing",PAmpVelocityScaleFunction);
  115.     xml->beginbranch("AMPLITUDE_ENVELOPE");
  116.         AmpEnvelope->add2XML(xml);
  117.     xml->endbranch();
  118.     xml->endbranch();
  119.  
  120.     xml->beginbranch("FREQUENCY_PARAMETERS");
  121.     xml->addparbool("fixed_freq",Pfixedfreq);
  122.     xml->addpar("fixed_freq_et",PfixedfreqET);
  123.  
  124.     xml->addpar("detune",PDetune);
  125.     xml->addpar("coarse_detune",PCoarseDetune);
  126.     xml->addpar("detune_type",PDetuneType);
  127.  
  128.     xml->addpar("bandwidth",Pbandwidth);
  129.     xml->addpar("bandwidth_scale",Pbwscale);
  130.  
  131.     xml->addparbool("freq_envelope_enabled",PFreqEnvelopeEnabled);
  132.     if ((PFreqEnvelopeEnabled!=0)||(!xml->minimal)){
  133.         xml->beginbranch("FREQUENCY_ENVELOPE");
  134.             FreqEnvelope->add2XML(xml);
  135.         xml->endbranch();
  136.     };
  137.  
  138.     xml->addparbool("band_width_envelope_enabled",PBandWidthEnvelopeEnabled);
  139.     if ((PBandWidthEnvelopeEnabled!=0)||(!xml->minimal)){
  140.         xml->beginbranch("BANDWIDTH_ENVELOPE");
  141.             BandWidthEnvelope->add2XML(xml);
  142.         xml->endbranch();
  143.     };
  144.     xml->endbranch();
  145.  
  146.     xml->beginbranch("FILTER_PARAMETERS");
  147.     xml->addparbool("enabled",PGlobalFilterEnabled);
  148.     if ((PGlobalFilterEnabled!=0)||(!xml->minimal)){
  149.         xml->beginbranch("FILTER");
  150.         GlobalFilter->add2XML(xml);
  151.         xml->endbranch();
  152.  
  153.         xml->addpar("filter_velocity_sensing",PGlobalFilterVelocityScaleFunction);
  154.         xml->addpar("filter_velocity_sensing_amplitude",PGlobalFilterVelocityScale);
  155.  
  156.         xml->beginbranch("FILTER_ENVELOPE");
  157.         GlobalFilterEnvelope->add2XML(xml);
  158.         xml->endbranch();
  159.     };
  160.     xml->endbranch();
  161. };
  162.  
  163. void SUBnoteParameters::getfromXML(XMLwrapper *xml){
  164.     Pnumstages=xml->getpar127("num_stages",Pnumstages);
  165.     Phmagtype=xml->getpar127("harmonic_mag_type",Phmagtype);
  166.     Pstart=xml->getpar127("start",Pstart);
  167.     
  168.     if (xml->enterbranch("HARMONICS")){
  169.     Phmag[0]=0;
  170.     for (int i=0;i<MAX_SUB_HARMONICS;i++){
  171.         if (xml->enterbranch("HARMONIC",i)==0) continue;
  172.         Phmag[i]=xml->getpar127("mag",Phmag[i]);
  173.         Phrelbw[i]=xml->getpar127("relbw",Phrelbw[i]);
  174.         xml->exitbranch();
  175.     };
  176.     xml->exitbranch();
  177.     };
  178.  
  179.     if (xml->enterbranch("AMPLITUDE_PARAMETERS")){
  180.     Pstereo=xml->getparbool("stereo",Pstereo);
  181.     PVolume=xml->getpar127("volume",PVolume);
  182.     PPanning=xml->getpar127("panning",PPanning);
  183.     PAmpVelocityScaleFunction=xml->getpar127("velocity_sensing",PAmpVelocityScaleFunction);
  184.     if (xml->enterbranch("AMPLITUDE_ENVELOPE")){
  185.         AmpEnvelope->getfromXML(xml);
  186.         xml->exitbranch();
  187.     };
  188.     xml->exitbranch();
  189.     };
  190.  
  191.     if (xml->enterbranch("FREQUENCY_PARAMETERS")){
  192.     Pfixedfreq=xml->getparbool("fixed_freq",Pfixedfreq);
  193.     PfixedfreqET=xml->getpar127("fixed_freq_et",PfixedfreqET);
  194.  
  195.     PDetune=xml->getpar("detune",PDetune,0,16383);
  196.     PCoarseDetune=xml->getpar("coarse_detune",PCoarseDetune,0,16383);
  197.     PDetuneType=xml->getpar127("detune_type",PDetuneType);
  198.  
  199.     Pbandwidth=xml->getpar127("bandwidth",Pbandwidth);
  200.     Pbwscale=xml->getpar127("bandwidth_scale",Pbwscale);
  201.  
  202.     PFreqEnvelopeEnabled=xml->getparbool("freq_envelope_enabled",PFreqEnvelopeEnabled);
  203.     if (xml->enterbranch("FREQUENCY_ENVELOPE")){
  204.         FreqEnvelope->getfromXML(xml);
  205.         xml->exitbranch();
  206.     };
  207.  
  208.     PBandWidthEnvelopeEnabled=xml->getparbool("band_width_envelope_enabled",PBandWidthEnvelopeEnabled);
  209.     if (xml->enterbranch("BANDWIDTH_ENVELOPE")){
  210.         BandWidthEnvelope->getfromXML(xml);
  211.         xml->exitbranch();
  212.     };
  213.     
  214.         xml->exitbranch();
  215.     };
  216.     
  217.     if (xml->enterbranch("FILTER_PARAMETERS")){
  218.     PGlobalFilterEnabled=xml->getparbool("enabled",PGlobalFilterEnabled);
  219.     if (xml->enterbranch("FILTER")){
  220.         GlobalFilter->getfromXML(xml);
  221.         xml->exitbranch();
  222.     };
  223.  
  224.     PGlobalFilterVelocityScaleFunction=xml->getpar127("filter_velocity_sensing",PGlobalFilterVelocityScaleFunction);
  225.     PGlobalFilterVelocityScale=xml->getpar127("filter_velocity_sensing_amplitude",PGlobalFilterVelocityScale);
  226.  
  227.     if (xml->enterbranch("FILTER_ENVELOPE")){
  228.         GlobalFilterEnvelope->getfromXML(xml);
  229.         xml->exitbranch();
  230.     };
  231.     
  232.     xml->exitbranch();
  233.     };
  234. };
  235.  
  236.  
  237.  
  238.  
  239.