zynaddsubfx

ZynAddSubFX open source synthesizer
Log | Files | Refs | Submodules | LICENSE

commit 8714947c7ee7d724692320cf920762b5ec52b42b
parent 94dbf2d9ff0c7b5480379b6559e3cda42a859925
Author: paulnasca <paulnasca>
Date:   Tue, 17 Aug 2004 21:33:08 +0000

*** empty log message ***

Diffstat:
MChangeLog | 4++--
Msrc/Params/ADnoteParameters.C | 23+++++++++++++++++------
Msrc/Params/ADnoteParameters.h | 6++++--
Msrc/Params/FilterParams.C | 34+++++++++++++++++++++-------------
Msrc/Params/FilterParams.h | 6++++--
Msrc/Params/Presets.C | 44+++++++++++++++++++++++++++++++++++++-------
Msrc/Params/Presets.h | 5+++++
Msrc/UI/ADnoteUI.fl | 72+++++++++++++++++++++++++++++++++++++++++-------------------------------
Msrc/UI/EnvelopeUI.fl | 7+++----
Msrc/UI/FilterUI.fl | 23++++++++++++++++++-----
Msrc/UI/PresetsUI.fl | 29++++++++++++++++-------------
11 files changed, 168 insertions(+), 85 deletions(-)

diff --git a/ChangeLog b/ChangeLog @@ -683,14 +683,14 @@ 13 Aug 2004 - Inceput sa scriu modurile continous si discrete la PADnote 14 Aug 2004 - Terminat modul continous la PADnote - Corectata o mica eroare la OscilGen care facea daca adaptive harmonics e activ si phase randomness>0 sa rezulte si aleatorism in amplitudinile armonicelor - - Inceput sa scriu Presets/Clipboard + - Inceput sa scriu Presets/Clipboard (Clipboardul, in stadiu actual va putea copia doar parametrii folositi si nu cei dezactivati) - Merge partial partea de Copy in clipboard 15 Aug 2004 - Corectata o eroare in main.c la pitch bend - Scos Swap/Copy la efecte si la PartUI si vechiul Copy/Paste de la ADnote voice - Merge clipboardul la Oscil, Resonance, Filter si partial la ADsynth,SUBSynth si PADsynth 16 Aug 2004 - Corectata inca o eroare la pitch bend (aratata de Krzysztof Korpiela) - Adaugat refresh si la Filtru si paste la ADnote, SUBnote si PADsynth sunt complete -17 Aug 2004 - Adaugat clipboard la LFO si Envelope +17 Aug 2004 - Adaugat clipboard la LFO, Envelope, ADnoteVoice si Filter Vowel \ No newline at end of file diff --git a/src/Params/ADnoteParameters.C b/src/Params/ADnoteParameters.C @@ -81,6 +81,16 @@ void ADnoteParameters::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; @@ -135,11 +145,10 @@ void ADnoteParameters::defaults(){ VoicePar[nvoice].FMFreqEnvelope->defaults(); VoicePar[nvoice].FMAmpEnvelope->defaults(); - }; - VoicePar[0].Enabled=1; }; + /* * Init the voice parameters */ @@ -509,7 +518,8 @@ void ADnoteParameters::saveloadbuf(Buffer *buf){ }; -void ADnoteParameters::add2XMLvoice(XMLwrapper *xml,int 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 @@ -703,7 +713,7 @@ void ADnoteParameters::add2XML(XMLwrapper *xml){ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){ xml->beginbranch("VOICE",nvoice); - add2XMLvoice(xml,nvoice); + add2XMLsection(xml,nvoice); xml->endbranch(); }; }; @@ -779,14 +789,15 @@ void ADnoteParameters::getfromXML(XMLwrapper *xml){ for (int nvoice=0;nvoice<NUM_VOICES;nvoice++){ VoicePar[nvoice].Enabled=0; if (xml->enterbranch("VOICE",nvoice)==0) continue; - getfromXMLvoice(xml,nvoice); + getfromXMLsection(xml,nvoice); xml->exitbranch(); }; }; -void ADnoteParameters::getfromXMLvoice(XMLwrapper *xml,int nvoice){ +void ADnoteParameters::getfromXMLsection(XMLwrapper *xml,int n){ + int nvoice=n; if (nvoice>=NUM_VOICES) return; VoicePar[nvoice].Enabled=xml->getparbool("enabled",0); diff --git a/src/Params/ADnoteParameters.h b/src/Params/ADnoteParameters.h @@ -269,12 +269,14 @@ class ADnoteParameters:public Presets{ void saveloadbufvoice(Buffer *buf,unsigned char nvoice); private: + void defaults(int n);//n is the nvoice + void EnableVoice(int nvoice); void KillVoice(int nvoice); FFTwrapper *fft; - void add2XMLvoice(XMLwrapper *xml,int nvoice); - void getfromXMLvoice(XMLwrapper *xml,int nvoice); + void add2XMLsection(XMLwrapper *xml,int n); + void getfromXMLsection(XMLwrapper *xml,int n); }; #endif diff --git a/src/Params/FilterParams.C b/src/Params/FilterParams.C @@ -52,11 +52,7 @@ void FilterParams::defaults(){ Pnumformants=3; Pformantslowness=64; for (int j=0;j<FF_MAX_VOWELS;j++){ - 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; - }; + defaults(j); }; Psequencesize=3; @@ -69,6 +65,16 @@ void FilterParams::defaults(){ 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 */ @@ -348,8 +354,8 @@ void FilterParams::saveloadbuf(Buffer *buf){ }; -void FilterParams::add2XMLvowel(XMLwrapper *xml,int nvowel){ - xml->beginbranch("VOWEL",nvowel); +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); @@ -357,7 +363,6 @@ void FilterParams::add2XMLvowel(XMLwrapper *xml,int nvowel){ xml->addpar("q",Pvowels[nvowel].formants[nformant].q); xml->endbranch(); }; - xml->endbranch(); }; void FilterParams::add2XML(XMLwrapper *xml){ @@ -379,7 +384,9 @@ void FilterParams::add2XML(XMLwrapper *xml){ xml->addpar("center_freq",Pcenterfreq); xml->addpar("octaves_freq",Poctavesfreq); for (int nvowel=0;nvowel<FF_MAX_VOWELS;nvowel++){ - add2XMLvowel(xml,nvowel); + xml->beginbranch("VOWEL",nvowel); + add2XMLsection(xml,nvowel); + xml->endbranch(); }; xml->addpar("sequence_size",Psequencesize); xml->addpar("sequence_stretch",Psequencestretch); @@ -394,8 +401,8 @@ void FilterParams::add2XML(XMLwrapper *xml){ }; -void FilterParams::getfromXMLvowel(XMLwrapper *xml,int nvowel){ - if (xml->enterbranch("VOWEL",nvowel)==0) return; +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); @@ -403,7 +410,6 @@ void FilterParams::getfromXMLvowel(XMLwrapper *xml,int nvowel){ Pvowels[nvowel].formants[nformant].q=xml->getpar127("q",Pvowels[nvowel].formants[nformant].q); xml->exitbranch(); }; - xml->exitbranch(); }; void FilterParams::getfromXML(XMLwrapper *xml){ @@ -425,7 +431,9 @@ void FilterParams::getfromXML(XMLwrapper *xml){ Poctavesfreq=xml->getpar127("octaves_freq",Poctavesfreq); for (int nvowel=0;nvowel<FF_MAX_VOWELS;nvowel++){ - getfromXMLvowel(xml,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); diff --git a/src/Params/FilterParams.h b/src/Params/FilterParams.h @@ -35,10 +35,10 @@ class FilterParams:public Presets{ void saveloadbuf(Buffer *buf); void add2XML(XMLwrapper *xml); - void add2XMLvowel(XMLwrapper *xml,int nvowel); + void add2XMLsection(XMLwrapper *xml,int n); void defaults(); void getfromXML(XMLwrapper *xml); - void getfromXMLvowel(XMLwrapper *xml,int nvowel); + void getfromXMLsection(XMLwrapper *xml,int n); void getfromFilterParams(FilterParams *pars); @@ -90,6 +90,8 @@ class FilterParams:public Presets{ bool changed; private: + void defaults(int n); + //stored default parameters unsigned char Dtype; unsigned char Dfreq; diff --git a/src/Params/Presets.C b/src/Params/Presets.C @@ -25,7 +25,8 @@ Presets::Presets(){ - type[0]=0;; + type[0]=0; + nelement=-1; }; Presets::~Presets(){ @@ -38,34 +39,63 @@ void Presets::setpresettype(char *type){ void Presets::copyclipboard(){ XMLwrapper *xml=new XMLwrapper(); + char type[MAX_PRESETTYPE_SIZE]; + strcpy(type,this->type); + if (nelement!=-1) strcat(type,"n"); + xml->beginbranch(type); - add2XML(xml); + if (nelement==-1) add2XML(xml); + else add2XMLsection(xml,nelement); xml->endbranch(); presetsstore.copyclipboard(xml,type); delete(xml); + nelement=-1; }; void Presets::pasteclipboard(){ - if (!checkclipboardtype()) return; + char type[MAX_PRESETTYPE_SIZE]; + strcpy(type,this->type); + if (nelement!=-1) strcat(type,"n"); + + if (!checkclipboardtype()) { + nelement=-1; + return; + }; XMLwrapper *xml=new XMLwrapper(); if (!presetsstore.pasteclipboard(xml)) { delete(xml); + nelement=-1; return; }; - if (xml->enterbranch(type)==0) return; - defaults(); - getfromXML(xml); + 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; +}; diff --git a/src/Params/Presets.h b/src/Params/Presets.h @@ -37,12 +37,17 @@ class Presets{ bool checkclipboardtype(); char type[MAX_PRESETTYPE_SIZE]; + void setelement(int n); 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/src/UI/ADnoteUI.fl b/src/UI/ADnoteUI.fl @@ -637,7 +637,7 @@ o->redraw();} code0 {o->value(pars->VoicePar[nvoice].PFilterEnvelopeEnabled);} } Fl_Group voicefilterlfogroup { - label {Filter LFO } open selected + label {Filter LFO } open xywh {250 175 230 70} box FLAT_BOX color 47 align 144 code0 {o->init(pars->VoicePar[nvoice].FilterLfo);} code1 {if (pars->VoicePar[nvoice].PFilterLfoEnabled==0) o->deactivate();} @@ -950,6 +950,46 @@ resui->resonancewindow->show();} xywh {435 380 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7 } } + Fl_Window ADnoteVoice { + label {ADsynth Voice Parameters} + xywh {53 58 765 560} type Double hide + } { + Fl_Group advoice { + xywh {0 0 760 525} box BORDER_BOX + code0 {o->init(pars,nvoice,master);} + code1 {o->show();} + class ADvoiceUI + } {} + Fl_Counter currentvoicecounter { + label {Current Voice} + callback {nvoice=(int)o->value(); +advoice->hide(); +ADnoteVoice->remove(advoice); +delete advoice; +advoice=new ADvoiceUI(0,0,765,525); +ADnoteVoice->add(advoice); +advoice->init(pars,nvoice,master); +advoice->show(); +ADnoteVoice->redraw();} + xywh {5 530 130 25} type Simple labelfont 1 align 8 minimum 0 maximum 0 step 1 textfont 1 textsize 18 + code0 {o->bounds(0,NUM_VOICES-1);} + } + Fl_Button {} { + label {Close Window} + callback {ADnoteVoice->hide();} + xywh {300 530 195 25} box THIN_UP_BOX labelfont 1 + } + Fl_Button {} { + label C + callback {presetsui->copy(pars,nvoice);} selected + xywh {700 535 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7 + } + Fl_Button {} { + label P + callback {presetsui->paste(pars,this,nvoice);} selected + xywh {730 535 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7 + } + } Fl_Window ADnoteVoiceList { label {ADsynth Voices list} xywh {32 266 650 260} type Double hide @@ -992,36 +1032,6 @@ resui->resonancewindow->show();} } {} } } - Fl_Window ADnoteVoice { - label {ADsynth Voice Parameters} - xywh {53 58 765 560} type Double hide - } { - Fl_Group advoice { - xywh {0 0 760 525} box BORDER_BOX - code0 {o->init(pars,nvoice,master);} - code1 {o->show();} - class ADvoiceUI - } {} - Fl_Counter currentvoicecounter { - label {Current Voice} - callback {nvoice=(int)o->value(); -advoice->hide(); -ADnoteVoice->remove(advoice); -delete advoice; -advoice=new ADvoiceUI(0,0,765,525); -ADnoteVoice->add(advoice); -advoice->init(pars,nvoice,master); -advoice->show(); -ADnoteVoice->redraw();} - xywh {5 530 130 25} type Simple labelfont 1 align 8 minimum 0 maximum 0 step 1 textfont 1 textsize 18 - code0 {o->bounds(0,NUM_VOICES-1);} - } - Fl_Button {} { - label {Close Window} - callback {ADnoteVoice->hide();} - xywh {300 530 195 25} box THIN_UP_BOX labelfont 1 - } - } } Function {ADnoteUI(ADnoteParameters *parameters,Master *master_)} {} { code {pars=parameters; diff --git a/src/UI/EnvelopeUI.fl b/src/UI/EnvelopeUI.fl @@ -210,8 +210,8 @@ envfree=NULL;} {} code {envwindow->hide(); hide(); freemodeeditwindow->hide(); -//delete (envwindow); -delete (freemodeeditwindow);} {} +delete (freemodeeditwindow);} {selected + } } Function {make_freemode_edit_window()} {} { Fl_Window freemodeeditwindow { @@ -645,8 +645,7 @@ freeedit->redraw();} } } } - Function {make_free_window()} {selected - } { + Function {make_free_window()} {} { Fl_Window envfree { xywh {373 413 205 70} type Double color 50 labelfont 1 hide resizable class Fl_Group diff --git a/src/UI/FilterUI.fl b/src/UI/FilterUI.fl @@ -333,8 +333,8 @@ pars->changed=true;} open } Function {make_formant_window()} {} { Fl_Window formantparswindow { - label {Formant Filter Parameters} - xywh {47 301 710 205} type Double hide + label {Formant Filter Parameters} selected + xywh {47 301 700 205} type Double hide } { Fl_Group {} { xywh {485 47 105 113} box THIN_UP_BOX @@ -491,7 +491,21 @@ pars->changed=true;} Fl_Button {} { label Close callback {formantparswindow->hide();} - xywh {645 180 60 25} box THIN_UP_BOX + xywh {645 180 50 25} box THIN_UP_BOX + } + Fl_Button {} { + label C + callback {presetsui->copy(pars,nvowel);} + xywh {635 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7 + } + Fl_Button {} { + label P + callback {presetsui->paste(pars,this,nvowel);} + xywh {665 25 25 15} box THIN_UP_BOX color 179 labelfont 1 labelsize 12 labelcolor 7 + } + Fl_Box {} { + label Vowel + xywh {635 10 55 15} } } } @@ -523,8 +537,7 @@ qdial->value(pars->Pq); freqtrdial->value(pars->Pfreqtrack); gaindial->value(pars->Pgain); -stcounter->value(pars->Pstages);} {selected - } +stcounter->value(pars->Pstages);} {} } Function {init(FilterParams *filterpars_,unsigned char *velsnsamp_,unsigned char *velsns_)} {} { code {pars=filterpars_; diff --git a/src/UI/PresetsUI.fl b/src/UI/PresetsUI.fl @@ -8,27 +8,23 @@ decl {\#include <stdlib.h>} {public decl {\#include "../Params/Presets.h"} {public } -class PresetsUI_ {open -} { +class PresetsUI_ {} { Function {refresh()} {open return_type {virtual void} } {} Function {~PresetsUI_()} {open return_type virtual } {} } -class PresetsUI {open -} { +class PresetsUI {} { Function {PresetsUI()} {} { code {p=NULL; make_window();} {} } - Function {~PresetsUI()} {open - } { + Function {~PresetsUI()} {} { code {copywin->hide();delete(copywin); pastewin->hide();delete(pastewin);} {} } - Function {make_window()} {open - } { + Function {make_window()} {} { Fl_Window copywin { label {Copy to Clipboard/Preset} xywh {95 240 265 315} type Double box PLASTIC_THIN_UP_BOX color 238 hide non_modal @@ -64,7 +60,7 @@ copywin->hide();} label {Paste from Clipboard/Preset} xywh {516 204 265 315} type Double box PLASTIC_THIN_UP_BOX color 238 hide modal } { - Fl_Browser {} {selected + Fl_Browser {} { xywh {10 30 245 205} type Hold } Fl_Button {} { @@ -92,8 +88,7 @@ pui->refresh();} } } } - Function {copy(Presets *p)} {open - } { + Function {copy(Presets *p)} {} { code {this->p=p; this->pui=NULL; bool but=(Fl::event_button()!=FL_LEFT_MOUSE); @@ -104,8 +99,7 @@ if (but) p->copyclipboard(); copywin->show(); };} {} } - Function {paste(Presets *p,PresetsUI_ *pui)} {open - } { + Function {paste(Presets *p,PresetsUI_ *pui)} {} { code {this->p=p; this->pui=pui; bool but=(Fl::event_button()!=FL_LEFT_MOUSE); @@ -120,6 +114,15 @@ if (but) { pastewin->show(); };} {} } + Function {copy(Presets *p,int n)} {} { + code {p->setelement(n); +copy(p);} {} + } + Function {paste(Presets *p,PresetsUI_ *pui,int n)} {} { + code {p->setelement(n); +paste(p,pui);} {selected + } + } decl {Presets *p;} {public } decl {PresetsUI_ *pui;} {public