commit fdfff37567e94e739ee3aa2b17ec1a78b6d2c1e3
parent 9c6fbcf4197d1bb8d4bd3e8a949ac00a78d8b51b
Author: paulnasca <paulnasca>
Date: Tue, 10 Feb 2004 20:33:39 +0000
*** empty log message ***
Diffstat:
7 files changed, 106 insertions(+), 10 deletions(-)
diff --git a/ChangeLog b/ChangeLog
@@ -528,3 +528,6 @@
07 Feb 2004 - Adaugat functii de initializare si renuntat la masterdefaultbuf si instrumentdefaultbuf (adica salvarea la inceput si incarcarea bufferelor cu instrumentele prestabilite)
- Corectata o mica eroare care facea ca sa se incarce subnotepars la adnotepars (eroarea a aparut azi)
08 Feb 2004 - Modificat putin formatul XML
+10 Feb 2004 - Adaugata salvarea parametrilor pt. basefunction la OscilGen
+ - Inceput sa scriu incarcarea parametrilor
+
+\ No newline at end of file
diff --git a/src/Misc/Master.C b/src/Misc/Master.C
@@ -784,8 +784,7 @@ int Master::saveXML(char *filename){
//sa pun aici un test daca exista fisierul
- XMLwrapper *xml;
- xml=new XMLwrapper();
+ XMLwrapper *xml=new XMLwrapper();
xml->beginbranch("MASTER");
add2XML(xml);
@@ -797,6 +796,18 @@ int Master::saveXML(char *filename){
};
+int Master::loadXML(char *filename){
+ XMLwrapper *xml=new XMLwrapper();
+ if (xml->loadXMLfile(filename)<0) {
+ delete(xml);
+ return(-1);
+ };
+
+
+ delete(xml);
+ return(0);
+};
+
diff --git a/src/Misc/Master.h b/src/Misc/Master.h
@@ -48,10 +48,17 @@ class Master{
//saves all settings to a XML file
//returns 0 for ok, 1 if there is a existing file or -1 if there is an error
int saveXML(char *filename);
+
+ //saves all settings to a XML file
+ //returns 0 for ok or -1 if there is an error
+ int loadXML(char *filename);
//this adds the parameters to the XML data
void add2XML(XMLwrapper *xml);
+
void defaults();
+
+
//Midi IN
diff --git a/src/Misc/XMLwrapper.C b/src/Misc/XMLwrapper.C
@@ -38,7 +38,7 @@ int XMLwrapper_whitespace_callback(mxml_node_t *node,int where){
XMLwrapper::XMLwrapper(){
memset(&parentstack,0,sizeof(parentstack));
stackpos=0;
-
+
tree=mxmlNewElement(MXML_NO_PARENT,"?xml");
mxmlElementSetAttr(tree,"version","1.0");
mxmlElementSetAttr(tree,"encoding","UTF-8");
@@ -49,6 +49,8 @@ XMLwrapper::XMLwrapper(){
node=root=mxmlNewElement(tree,"ZynAddSubFX-data");
+ mxmlElementSetAttr(root,"version","0.1");
+
//save zynaddsubfx specifications
beginbranch("BASE_PARAMETERS");
addpar("max_midi_parts",NUM_MIDI_PARTS);
@@ -64,9 +66,29 @@ XMLwrapper::XMLwrapper(){
};
XMLwrapper::~XMLwrapper(){
- mxmlDelete(tree);
+ if (tree!=NULL) mxmlDelete(tree);
};
+int XMLwrapper::loadXMLfile(char *filename){
+ if (tree!=NULL) mxmlDelete(tree);
+ tree=NULL;
+
+ FILE *file=fopen(filename,"r");
+ if (file==NULL) return(-1);
+
+ root=tree=mxmlLoadFile(NULL,file,MXML_NO_CALLBACK);
+ fclose(file);
+
+ if (tree==NULL) return(-1);//this is not XML
+
+// if (strcmp(tree->value.element.name,"?xml")!=0) return(-2);
+ node=root=mxmlFindElement(tree,tree,"ZynAddSuFX-data",NULL,NULL,MXML_DESCEND);
+ if (root==NULL) return(-2);//the XML doesnt embbed zynaddsubfx data
+
+// printf("%s\n",root->value.element.name);
+
+ return(0);
+};
int XMLwrapper::saveXMLfile(char *filename,int compression){
diff --git a/src/Misc/XMLwrapper.h b/src/Misc/XMLwrapper.h
@@ -41,6 +41,9 @@ class XMLwrapper{
//returns 0 if ok or -1 if the file cannot be saved
int saveXMLfile(char *filename, int compression);
+ //returns 0 if ok or -1 if the file cannot be loaded
+ int loadXMLfile(char *filename);
+
//add simple parameter (name and value)
void addpar(char *name,int val);
void addparreal(char *name,REALTYPE val);
diff --git a/src/Synth/OscilGen.C b/src/Synth/OscilGen.C
@@ -842,13 +842,34 @@ void OscilGen::add2XML(XMLwrapper *xml){
xml->beginbranch("HARMONICS");
for (int n=0;n<MAX_AD_HARMONICS;n++){
if ((Phmag[n]==64)&&(Phphase[n]==64)) continue;
- xml->beginbranch("HARMONIC",n);
+ xml->beginbranch("HARMONIC",n+1);
xml->addpar("mag",Phmag[n]);
xml->addpar("phase",Phphase[n]);
xml->endbranch();
};
xml->endbranch();
+
+ if (Pcurrentbasefunc==127){
+ REALTYPE max=0.0;
+
+ for (int i=0;i<OSCIL_SIZE;i++) if (max<fabs(basefuncFFTfreqs[i])) max=fabs(basefuncFFTfreqs[i]);
+ if (max<0.00000001) max=1.0;
+
+ xml->beginbranch("BASE_FUNCTION");
+ for (int i=1;i<OSCIL_SIZE/2;i++){
+ REALTYPE xc=basefuncFFTfreqs[i]/max;
+ REALTYPE xs=basefuncFFTfreqs[OSCIL_SIZE-i]/max;
+ if ((fabs(xs)>0.00001)&&(fabs(xs)>0.00001)){
+ xml->beginbranch("BF_HARMONIC",i);
+ xml->addparreal("cos",xs);
+ xml->addparreal("sin",xs);
+ xml->endbranch();
+ };
+
+ };
+ xml->endbranch();
+ };
};
diff --git a/src/UI/MasterUI.fl b/src/UI/MasterUI.fl
@@ -372,14 +372,14 @@ fl_alert("ZynAddSubFX could not be closed this way, because it's a VST plugin. P
\#else
if (fl_ask("Exit and leave the unsaved data?")) *exitprogram=1;
\#endif}
- xywh {149 197 390 465} type Double
+ xywh {151 174 390 465} type Double
code0 {setfilelabel(NULL);} non_modal visible
} {
- Fl_Menu_Bar mastermenu {open
+ Fl_Menu_Bar mastermenu {
xywh {0 0 690 25}
} {
submenu {} {
- label {&File}
+ label {&File} open
xywh {0 0 100 20}
} {
menuitem {} {
@@ -396,7 +396,35 @@ master->saveXML(filename);
pthread_mutex_unlock(&master->mutex);
updatepanel();}
- xywh {10 10 100 20} divider
+ xywh {10 10 100 20}
+ }
+ menuitem {} {
+ label {&Open XML...}
+ callback {char *filename;
+filename=fl_file_chooser("Open:","(*.xml)",NULL,0);
+if (filename==NULL) return;
+
+
+pthread_mutex_lock(&master->mutex);
+ //clear all parameters
+ master->defaults();
+
+ //load the data
+ master->loadXML(filename);
+pthread_mutex_unlock(&master->mutex);
+
+npartcounter->do_callback();
+syseffnocounter->do_callback();
+inseffnocounter->do_callback();
+masterkeyshiftcounter->value(master->Pkeyshift-64);
+mastervolumedial->value(master->Pvolume);
+globalfinedetuneslider->value(master->microtonal.Pglobalfinedetune);
+microtonalui=new MicrotonalUI(&master->microtonal);
+nrpnbutton->value(master->ctl.NRPN.receive);
+updatesendwindow();
+
+updatepanel();}
+ xywh {20 20 100 20} divider
}
menuitem {} {
label {&New (erase all)...}
@@ -604,7 +632,7 @@ if (result==0) {
else fl_alert("Error: Could not load the file.");
};
-updatepanel();} selected
+updatepanel();}
xywh {20 20 100 20}
}
menuitem {} {