[SCM] calf/master: + Initial implementation of DSSI presets (use calfjackhost to edit presets for now!) + Added GPL license text in COPYING.GPL + Refactoring of LADSPA and preset activation code + VintageDelay: add generation of RDF

js at users.alioth.debian.org js at users.alioth.debian.org
Tue May 7 15:36:48 UTC 2013


The following commit has been merged in the master branch:
commit 2953690c8f2ef292126cedb92662017393142d38
Author: kfoltman <kfoltman at 78b06b96-2940-0410-b7fc-879d825d01d8>
Date:   Sun Dec 23 00:44:13 2007 +0000

    + Initial implementation of DSSI presets (use calfjackhost to edit presets for now!)
    + Added GPL license text in COPYING.GPL
    + Refactoring of LADSPA and preset activation code
    + VintageDelay: add generation of RDF
    
    
    
    git-svn-id: https://calf.svn.sourceforge.net/svnroot/calf/trunk@38 78b06b96-2940-0410-b7fc-879d825d01d8

diff --git a/COPYING.GPL b/COPYING.GPL
new file mode 100644
index 0000000..d60c31a
--- /dev/null
+++ b/COPYING.GPL
@@ -0,0 +1,340 @@
+		    GNU GENERAL PUBLIC LICENSE
+		       Version 2, June 1991
+
+ Copyright (C) 1989, 1991 Free Software Foundation, Inc.
+     59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ Everyone is permitted to copy and distribute verbatim copies
+ of this license document, but changing it is not allowed.
+
+			    Preamble
+
+  The licenses for most software are designed to take away your
+freedom to share and change it.  By contrast, the GNU General Public
+License is intended to guarantee your freedom to share and change free
+software--to make sure the software is free for all its users.  This
+General Public License applies to most of the Free Software
+Foundation's software and to any other program whose authors commit to
+using it.  (Some other Free Software Foundation software is covered by
+the GNU Library General Public License instead.)  You can apply it to
+your programs, too.
+
+  When we speak of free software, we are referring to freedom, not
+price.  Our General Public Licenses are designed to make sure that you
+have the freedom to distribute copies of free software (and charge for
+this service if you wish), that you receive source code or can get it
+if you want it, that you can change the software or use pieces of it
+in new free programs; and that you know you can do these things.
+
+  To protect your rights, we need to make restrictions that forbid
+anyone to deny you these rights or to ask you to surrender the rights.
+These restrictions translate to certain responsibilities for you if you
+distribute copies of the software, or if you modify it.
+
+  For example, if you distribute copies of such a program, whether
+gratis or for a fee, you must give the recipients all the rights that
+you have.  You must make sure that they, too, receive or can get the
+source code.  And you must show them these terms so they know their
+rights.
+
+  We protect your rights with two steps: (1) copyright the software, and
+(2) offer you this license which gives you legal permission to copy,
+distribute and/or modify the software.
+
+  Also, for each author's protection and ours, we want to make certain
+that everyone understands that there is no warranty for this free
+software.  If the software is modified by someone else and passed on, we
+want its recipients to know that what they have is not the original, so
+that any problems introduced by others will not reflect on the original
+authors' reputations.
+
+  Finally, any free program is threatened constantly by software
+patents.  We wish to avoid the danger that redistributors of a free
+program will individually obtain patent licenses, in effect making the
+program proprietary.  To prevent this, we have made it clear that any
+patent must be licensed for everyone's free use or not licensed at all.
+
+  The precise terms and conditions for copying, distribution and
+modification follow.
+
+		    GNU GENERAL PUBLIC LICENSE
+   TERMS AND CONDITIONS FOR COPYING, DISTRIBUTION AND MODIFICATION
+
+  0. This License applies to any program or other work which contains
+a notice placed by the copyright holder saying it may be distributed
+under the terms of this General Public License.  The "Program", below,
+refers to any such program or work, and a "work based on the Program"
+means either the Program or any derivative work under copyright law:
+that is to say, a work containing the Program or a portion of it,
+either verbatim or with modifications and/or translated into another
+language.  (Hereinafter, translation is included without limitation in
+the term "modification".)  Each licensee is addressed as "you".
+
+Activities other than copying, distribution and modification are not
+covered by this License; they are outside its scope.  The act of
+running the Program is not restricted, and the output from the Program
+is covered only if its contents constitute a work based on the
+Program (independent of having been made by running the Program).
+Whether that is true depends on what the Program does.
+
+  1. You may copy and distribute verbatim copies of the Program's
+source code as you receive it, in any medium, provided that you
+conspicuously and appropriately publish on each copy an appropriate
+copyright notice and disclaimer of warranty; keep intact all the
+notices that refer to this License and to the absence of any warranty;
+and give any other recipients of the Program a copy of this License
+along with the Program.
+
+You may charge a fee for the physical act of transferring a copy, and
+you may at your option offer warranty protection in exchange for a fee.
+
+  2. You may modify your copy or copies of the Program or any portion
+of it, thus forming a work based on the Program, and copy and
+distribute such modifications or work under the terms of Section 1
+above, provided that you also meet all of these conditions:
+
+    a) You must cause the modified files to carry prominent notices
+    stating that you changed the files and the date of any change.
+
+    b) You must cause any work that you distribute or publish, that in
+    whole or in part contains or is derived from the Program or any
+    part thereof, to be licensed as a whole at no charge to all third
+    parties under the terms of this License.
+
+    c) If the modified program normally reads commands interactively
+    when run, you must cause it, when started running for such
+    interactive use in the most ordinary way, to print or display an
+    announcement including an appropriate copyright notice and a
+    notice that there is no warranty (or else, saying that you provide
+    a warranty) and that users may redistribute the program under
+    these conditions, and telling the user how to view a copy of this
+    License.  (Exception: if the Program itself is interactive but
+    does not normally print such an announcement, your work based on
+    the Program is not required to print an announcement.)
+
+These requirements apply to the modified work as a whole.  If
+identifiable sections of that work are not derived from the Program,
+and can be reasonably considered independent and separate works in
+themselves, then this License, and its terms, do not apply to those
+sections when you distribute them as separate works.  But when you
+distribute the same sections as part of a whole which is a work based
+on the Program, the distribution of the whole must be on the terms of
+this License, whose permissions for other licensees extend to the
+entire whole, and thus to each and every part regardless of who wrote it.
+
+Thus, it is not the intent of this section to claim rights or contest
+your rights to work written entirely by you; rather, the intent is to
+exercise the right to control the distribution of derivative or
+collective works based on the Program.
+
+In addition, mere aggregation of another work not based on the Program
+with the Program (or with a work based on the Program) on a volume of
+a storage or distribution medium does not bring the other work under
+the scope of this License.
+
+  3. You may copy and distribute the Program (or a work based on it,
+under Section 2) in object code or executable form under the terms of
+Sections 1 and 2 above provided that you also do one of the following:
+
+    a) Accompany it with the complete corresponding machine-readable
+    source code, which must be distributed under the terms of Sections
+    1 and 2 above on a medium customarily used for software interchange; or,
+
+    b) Accompany it with a written offer, valid for at least three
+    years, to give any third party, for a charge no more than your
+    cost of physically performing source distribution, a complete
+    machine-readable copy of the corresponding source code, to be
+    distributed under the terms of Sections 1 and 2 above on a medium
+    customarily used for software interchange; or,
+
+    c) Accompany it with the information you received as to the offer
+    to distribute corresponding source code.  (This alternative is
+    allowed only for noncommercial distribution and only if you
+    received the program in object code or executable form with such
+    an offer, in accord with Subsection b above.)
+
+The source code for a work means the preferred form of the work for
+making modifications to it.  For an executable work, complete source
+code means all the source code for all modules it contains, plus any
+associated interface definition files, plus the scripts used to
+control compilation and installation of the executable.  However, as a
+special exception, the source code distributed need not include
+anything that is normally distributed (in either source or binary
+form) with the major components (compiler, kernel, and so on) of the
+operating system on which the executable runs, unless that component
+itself accompanies the executable.
+
+If distribution of executable or object code is made by offering
+access to copy from a designated place, then offering equivalent
+access to copy the source code from the same place counts as
+distribution of the source code, even though third parties are not
+compelled to copy the source along with the object code.
+
+  4. You may not copy, modify, sublicense, or distribute the Program
+except as expressly provided under this License.  Any attempt
+otherwise to copy, modify, sublicense or distribute the Program is
+void, and will automatically terminate your rights under this License.
+However, parties who have received copies, or rights, from you under
+this License will not have their licenses terminated so long as such
+parties remain in full compliance.
+
+  5. You are not required to accept this License, since you have not
+signed it.  However, nothing else grants you permission to modify or
+distribute the Program or its derivative works.  These actions are
+prohibited by law if you do not accept this License.  Therefore, by
+modifying or distributing the Program (or any work based on the
+Program), you indicate your acceptance of this License to do so, and
+all its terms and conditions for copying, distributing or modifying
+the Program or works based on it.
+
+  6. Each time you redistribute the Program (or any work based on the
+Program), the recipient automatically receives a license from the
+original licensor to copy, distribute or modify the Program subject to
+these terms and conditions.  You may not impose any further
+restrictions on the recipients' exercise of the rights granted herein.
+You are not responsible for enforcing compliance by third parties to
+this License.
+
+  7. If, as a consequence of a court judgment or allegation of patent
+infringement or for any other reason (not limited to patent issues),
+conditions are imposed on you (whether by court order, agreement or
+otherwise) that contradict the conditions of this License, they do not
+excuse you from the conditions of this License.  If you cannot
+distribute so as to satisfy simultaneously your obligations under this
+License and any other pertinent obligations, then as a consequence you
+may not distribute the Program at all.  For example, if a patent
+license would not permit royalty-free redistribution of the Program by
+all those who receive copies directly or indirectly through you, then
+the only way you could satisfy both it and this License would be to
+refrain entirely from distribution of the Program.
+
+If any portion of this section is held invalid or unenforceable under
+any particular circumstance, the balance of the section is intended to
+apply and the section as a whole is intended to apply in other
+circumstances.
+
+It is not the purpose of this section to induce you to infringe any
+patents or other property right claims or to contest validity of any
+such claims; this section has the sole purpose of protecting the
+integrity of the free software distribution system, which is
+implemented by public license practices.  Many people have made
+generous contributions to the wide range of software distributed
+through that system in reliance on consistent application of that
+system; it is up to the author/donor to decide if he or she is willing
+to distribute software through any other system and a licensee cannot
+impose that choice.
+
+This section is intended to make thoroughly clear what is believed to
+be a consequence of the rest of this License.
+
+  8. If the distribution and/or use of the Program is restricted in
+certain countries either by patents or by copyrighted interfaces, the
+original copyright holder who places the Program under this License
+may add an explicit geographical distribution limitation excluding
+those countries, so that distribution is permitted only in or among
+countries not thus excluded.  In such case, this License incorporates
+the limitation as if written in the body of this License.
+
+  9. The Free Software Foundation may publish revised and/or new versions
+of the General Public License from time to time.  Such new versions will
+be similar in spirit to the present version, but may differ in detail to
+address new problems or concerns.
+
+Each version is given a distinguishing version number.  If the Program
+specifies a version number of this License which applies to it and "any
+later version", you have the option of following the terms and conditions
+either of that version or of any later version published by the Free
+Software Foundation.  If the Program does not specify a version number of
+this License, you may choose any version ever published by the Free Software
+Foundation.
+
+  10. If you wish to incorporate parts of the Program into other free
+programs whose distribution conditions are different, write to the author
+to ask for permission.  For software which is copyrighted by the Free
+Software Foundation, write to the Free Software Foundation; we sometimes
+make exceptions for this.  Our decision will be guided by the two goals
+of preserving the free status of all derivatives of our free software and
+of promoting the sharing and reuse of software generally.
+
+			    NO WARRANTY
+
+  11. BECAUSE THE PROGRAM IS LICENSED FREE OF CHARGE, THERE IS NO WARRANTY
+FOR THE PROGRAM, TO THE EXTENT PERMITTED BY APPLICABLE LAW.  EXCEPT WHEN
+OTHERWISE STATED IN WRITING THE COPYRIGHT HOLDERS AND/OR OTHER PARTIES
+PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESSED
+OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
+MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE.  THE ENTIRE RISK AS
+TO THE QUALITY AND PERFORMANCE OF THE PROGRAM IS WITH YOU.  SHOULD THE
+PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF ALL NECESSARY SERVICING,
+REPAIR OR CORRECTION.
+
+  12. IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
+WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MAY MODIFY AND/OR
+REDISTRIBUTE THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES,
+INCLUDING ANY GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING
+OUT OF THE USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED
+TO LOSS OF DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY
+YOU OR THIRD PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER
+PROGRAMS), EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE
+POSSIBILITY OF SUCH DAMAGES.
+
+		     END OF TERMS AND CONDITIONS
+
+	    How to Apply These Terms to Your New Programs
+
+  If you develop a new program, and you want it to be of the greatest
+possible use to the public, the best way to achieve this is to make it
+free software which everyone can redistribute and change under these terms.
+
+  To do so, attach the following notices to the program.  It is safest
+to attach them to the start of each source file to most effectively
+convey the exclusion of warranty; and each file should have at least
+the "copyright" line and a pointer to where the full notice is found.
+
+    <one line to give the program's name and a brief idea of what it does.>
+    Copyright (C) <year>  <name of author>
+
+    This program is free software; you can redistribute it and/or modify
+    it under the terms of the GNU General Public License as published by
+    the Free Software Foundation; either version 2 of the License, or
+    (at your option) any later version.
+
+    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 for more details.
+
+    You should have received a copy of the GNU General Public License
+    along with this program; if not, write to the Free Software
+    Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+
+
+Also add information on how to contact you by electronic and paper mail.
+
+If the program is interactive, make it output a short notice like this
+when it starts in an interactive mode:
+
+    Gnomovision version 69, Copyright (C) year  name of author
+    Gnomovision comes with ABSOLUTELY NO WARRANTY; for details type `show w'.
+    This is free software, and you are welcome to redistribute it
+    under certain conditions; type `show c' for details.
+
+The hypothetical commands `show w' and `show c' should show the appropriate
+parts of the General Public License.  Of course, the commands you use may
+be called something other than `show w' and `show c'; they could even be
+mouse-clicks or menu items--whatever suits your program.
+
+You should also get your employer (if you work as a programmer) or your
+school, if any, to sign a "copyright disclaimer" for the program, if
+necessary.  Here is a sample; alter the names:
+
+  Yoyodyne, Inc., hereby disclaims all copyright interest in the program
+  `Gnomovision' (which makes passes at compilers) written by James Hacker.
+
+  <signature of Ty Coon>, 1 April 1989
+  Ty Coon, President of Vice
+
+This General Public License does not permit incorporating your program into
+proprietary programs.  If your program is a subroutine library, you may
+consider it more useful to permit linking proprietary applications with the
+library.  If this is what you want to do, use the GNU Library General
+Public License instead of this License.
diff --git a/Makefile.am b/Makefile.am
index 8f93369..3e2c629 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -4,7 +4,7 @@ SUBDIRS = $(SRCDIRS)
 
 distdir = $(PACKAGE)-$(VERSION)
 
-EXTRA_DIST = TODO autogen.sh calf.glade presets.xml
+EXTRA_DIST = COPYING.GPL TODO autogen.sh calf.glade presets.xml
 
 clean-local:
 	rm -f *~ *.old
diff --git a/src/calf/giface.h b/src/calf/giface.h
index f47e43e..cbcffb2 100644
--- a/src/calf/giface.h
+++ b/src/calf/giface.h
@@ -37,6 +37,7 @@
 #include <exception>
 #include <string>
 #include "primitives.h"
+#include "preset.h"
 
 namespace synth {
 
@@ -95,6 +96,15 @@ struct parameter_properties
     std::string to_string(float value) const;
 };
 
+struct plugin_ctl_iface
+{
+    virtual parameter_properties *get_param_props(int param_no) = 0;
+    virtual float get_param_value(int param_no) = 0;
+    virtual void set_param_value(int param_no, float value) = 0;
+    virtual int get_param_count() = 0;
+    virtual ~plugin_ctl_iface() {}
+};
+
 struct midi_event {
     uint8_t command;
     uint8_t param1;
@@ -135,15 +145,50 @@ struct ladspa_info
 extern std::string generate_ladspa_rdf(const ladspa_info &info, parameter_properties *params, const char *param_names[], unsigned int count, unsigned int ctl_ofs);
 
 template<class Module>
+struct ladspa_instance: public Module, public plugin_ctl_iface
+{
+    ladspa_instance()
+    {
+        for (int i=0; i < Module::in_count; i++)
+            Module::ins[i] = NULL;
+        for (int i=0; i < Module::out_count; i++)
+            Module::outs[i] = NULL;
+        for (int i=0; i < Module::param_count; i++)
+            Module::params[i] = NULL;
+    }
+    virtual parameter_properties *get_param_props(int param_no)
+    {
+        return &Module::param_props[param_no];
+    }
+    virtual float get_param_value(int param_no)
+    {
+        return *Module::params[param_no];
+    }
+    virtual void set_param_value(int param_no, float value)
+    {
+        *Module::params[param_no] = value;
+    }
+    virtual int get_param_count()
+    {
+        return Module::param_count;
+    }
+};
+
+template<class Module>
 struct ladspa_wrapper
 {
+    typedef ladspa_instance<Module> instance;
+    
     static LADSPA_Descriptor descriptor;
 #if USE_DSSI
     static DSSI_Descriptor dssi_descriptor;
     static DSSI_Program_Descriptor dssi_default_program;
+
+    static std::vector<plugin_preset> *presets;
+    static std::vector<DSSI_Program_Descriptor> *preset_descs;
 #endif
     ladspa_info &info;
-
+    
     ladspa_wrapper(ladspa_info &i) 
     : info(i)
     {
@@ -212,39 +257,67 @@ struct ladspa_wrapper
         dssi_descriptor.configure = cb_configure;
         dssi_descriptor.get_program = cb_get_program;
         dssi_descriptor.select_program = cb_select_program;
-        // XXXKF make one default program
         dssi_descriptor.run_synth = cb_run_synth;
         
+        presets = new std::vector<plugin_preset>;
+        preset_descs = new std::vector<DSSI_Program_Descriptor>;
+
+        preset_list plist;
+        plist.load_defaults();
+        // XXXKF this assumes that plugin name in preset is case-insensitive equal to plugin label
+        // if I forget about this, I'll be in a deep trouble
         dssi_default_program.Bank = 0;
         dssi_default_program.Program = 0;
         dssi_default_program.Name = "default";
+
+        int pos = 1;
+        for (unsigned int i = 0; i < plist.presets.size(); i++)
+        {
+            plugin_preset &pp = plist.presets[i];
+            if (strcasecmp(pp.plugin.c_str(), descriptor.Label))
+                continue;
+            DSSI_Program_Descriptor pd;
+            pd.Bank = pos >> 7;
+            pd.Program = pos++;
+            pd.Name = pp.name.c_str();
+            preset_descs->push_back(pd);
+            presets->push_back(pp);
+        }
+        // printf("presets = %p:%d name = %s\n", presets, presets->size(), descriptor.Label);
+        
 #endif
     }
 
     static LADSPA_Handle cb_instantiate(const struct _LADSPA_Descriptor * Descriptor, unsigned long sample_rate)
     {
-        Module *mod = new Module();
-        for (int i=0; i<Module::in_count; i++)
-            mod->ins[i] = NULL;
-        for (int i=0; i<Module::out_count; i++)
-            mod->outs[i] = NULL;
-        for (int i=0; i<Module::param_count; i++)
-            mod->params[i] = NULL;
+        instance *mod = new instance();
         mod->srate = sample_rate;
         return mod;
     }
 
 #if USE_DSSI
     static const DSSI_Program_Descriptor *cb_get_program(LADSPA_Handle Instance, unsigned long index) {
-        if (index != 0)
+        if (index > presets->size())
             return NULL;
+        if (index)
+            return &(*preset_descs)[index - 1];
         return &dssi_default_program;
     }
     
     static void cb_select_program(LADSPA_Handle Instance, unsigned long Bank, unsigned long Program) {
-        Module *const mod = (Module *)Instance;
-        for (int i =0 ; i < Module::param_count; i++)
-            *mod->params[i] = Module::param_props[i].def_value;
+        instance *mod = (instance *)Instance;
+        unsigned int no = (Bank << 7) + Program - 1;
+        // printf("no = %d presets = %p:%d\n", no, presets, presets->size());
+        if (no == -1U) {
+            for (int i =0 ; i < Module::param_count; i++)
+                *mod->params[i] = Module::param_props[i].def_value;
+            return;
+        }
+        if (no >= presets->size())
+            return;
+        plugin_preset &p = (*presets)[no];
+        // printf("activating preset %s\n", p.name.c_str());
+        p.activate(mod);
     }
     
 #endif
@@ -253,7 +326,7 @@ struct ladspa_wrapper
         unsigned long ins = Module::in_count;
         unsigned long outs = Module::out_count;
         unsigned long params = Module::param_count;
-        Module *const mod = (Module *)Instance;
+        instance *const mod = (instance *)Instance;
         if (port < ins)
             mod->ins[port] = DataLocation;
         else if (port < ins + outs)
@@ -266,7 +339,7 @@ struct ladspa_wrapper
     }
 
     static void cb_activate(LADSPA_Handle Instance) {
-        Module *const mod = (Module *)Instance;
+        instance *const mod = (instance *)Instance;
         mod->set_sample_rate(mod->srate);
         mod->activate();
         /*
@@ -285,7 +358,7 @@ struct ladspa_wrapper
     }
 
     static void cb_run(LADSPA_Handle Instance, unsigned long SampleCount) {
-        Module *const mod = (Module *)Instance;
+        instance *const mod = (instance *)Instance;
         mod->params_changed();
         process_slice(mod, 0, SampleCount);
     }
@@ -304,7 +377,7 @@ struct ladspa_wrapper
 #if USE_DSSI
     static void cb_run_synth(LADSPA_Handle Instance, unsigned long SampleCount, 
             snd_seq_event_t *Events, unsigned long EventCount) {
-        Module *const mod = (Module *)Instance;
+        instance *const mod = (instance *)Instance;
         mod->params_changed();
         
         uint32_t offset = 0;
@@ -353,12 +426,12 @@ struct ladspa_wrapper
 #endif
 
     static void cb_deactivate(LADSPA_Handle Instance) {
-        Module *const mod = (Module *)Instance;
+        instance *const mod = (instance *)Instance;
         mod->deactivate();
     }
 
     static void cb_cleanup(LADSPA_Handle Instance) {
-        Module *const mod = (Module *)Instance;
+        instance *const mod = (instance *)Instance;
         delete mod;
     }
     
@@ -378,6 +451,11 @@ DSSI_Descriptor ladspa_wrapper<Module>::dssi_descriptor;
 template<class Module>
 DSSI_Program_Descriptor ladspa_wrapper<Module>::dssi_default_program;
 
+template<class Module>
+std::vector<plugin_preset> *ladspa_wrapper<Module>::presets;
+
+template<class Module>
+std::vector<DSSI_Program_Descriptor> *ladspa_wrapper<Module>::preset_descs;
 #endif
 
 
diff --git a/src/calf/gui.h b/src/calf/gui.h
index 3fd9cc0..78ebee3 100644
--- a/src/calf/gui.h
+++ b/src/calf/gui.h
@@ -52,15 +52,6 @@ struct param_control
     virtual ~param_control() {}
 };
 
-struct plugin_ctl_iface
-{
-    virtual parameter_properties *get_param_props(int param_no) = 0;
-    virtual float get_param_value(int param_no) = 0;
-    virtual void set_param_value(int param_no, float value) = 0;
-    virtual int get_param_count() = 0;
-    virtual ~plugin_ctl_iface() {}
-};
-
 struct hscale_param_control: public param_control
 {
     GtkHScale *scale;
diff --git a/src/calf/preset.h b/src/calf/preset.h
index 95b9aa7..94c7899 100644
--- a/src/calf/preset.h
+++ b/src/calf/preset.h
@@ -25,10 +25,11 @@
 #include <string>
 #include <sstream>
 #include <ostream>
-#include "giface.h"
 
 namespace synth {
 
+class plugin_ctl_iface;
+    
 struct plugin_preset
 {
     int bank, program;
@@ -37,7 +38,9 @@ struct plugin_preset
     std::vector<std::string> param_names;
     std::vector<float> values;
     std::string blob;
-    std::string to_xml();
+
+    std::string to_xml();    
+    void activate(plugin_ctl_iface *plugin);
 };
 
 struct preset_exception
@@ -76,6 +79,7 @@ struct preset_list
     plugin_preset parser_preset;
 
     static std::string get_preset_filename();
+    bool load_defaults();
     void load(const char *filename);
     void save(const char *filename);
     void add(const plugin_preset &sp);
diff --git a/src/jackhost.cpp b/src/jackhost.cpp
index 3b6ccdc..a35e690 100644
--- a/src/jackhost.cpp
+++ b/src/jackhost.cpp
@@ -24,7 +24,6 @@
 #include <stdint.h>
 #include <stdlib.h>
 #include <config.h>
-#include <sys/stat.h>
 #include <glade/glade.h>
 #include <jack/jack.h>
 #include <calf/giface.h>
@@ -161,11 +160,7 @@ int main(int argc, char *argv[])
         return 0;
     }
     try {
-        struct stat st;
-        if (!stat(preset_list::get_preset_filename().c_str(), &st))
-            global_presets.load(preset_list::get_preset_filename().c_str());
-        if (global_presets.presets.empty() && !stat(PKGLIBDIR "/presets.xml", &st))
-            global_presets.load(PKGLIBDIR "/presets.xml");
+        global_presets.load_defaults();
     }
     catch(synth::preset_exception &e)
     {
diff --git a/src/modules.cpp b/src/modules.cpp
index 2a91c4d..81ed974 100644
--- a/src/modules.cpp
+++ b/src/modules.cpp
@@ -270,6 +270,7 @@ std::string synth::get_builtin_modules_rdf()
     rdf += ::flanger.generate_rdf();
     rdf += ::reverb.generate_rdf();
     rdf += ::filter.generate_rdf();
+    rdf += ::vintage_delay.generate_rdf();
     rdf += ::monosynth.generate_rdf();
     
     return rdf;
diff --git a/src/preset.cpp b/src/preset.cpp
index 41eb23d..3eeb605 100644
--- a/src/preset.cpp
+++ b/src/preset.cpp
@@ -22,9 +22,11 @@
 #include <fcntl.h>
 #include <stdlib.h>
 #include <errno.h>
+#include <sys/stat.h>
 
 #include <expat.h>
 #include <calf/preset.h>
+#include <calf/giface.h>
 
 using namespace synth;
 using namespace std;
@@ -46,6 +48,28 @@ std::string plugin_preset::to_xml()
     return ss.str();
 }
 
+void plugin_preset::activate(plugin_ctl_iface *plugin)
+{
+    map<string, int> names;
+    int count = plugin->get_param_count();
+    // this is deliberately done in two separate loops - if you wonder why, just think for a while :)
+    for (int i = 0; i < count; i++)
+        names[plugin->get_param_props(i)->name] = i;
+    for (int i = 0; i < count; i++)
+        names[plugin->get_param_props(i)->short_name] = i;
+    // no support for unnamed parameters... tough luck :)
+    for (unsigned int i = 0; i < min(param_names.size(), values.size()); i++)
+    {
+        map<string, int>::iterator pos = names.find(param_names[i]);
+        if (pos == names.end()) {
+            // XXXKF should have a mechanism for notifying a GUI
+            printf("Warning: unknown parameter %s for plugin %s\n", param_names[i].c_str(), this->plugin.c_str());
+            continue;
+        }
+        plugin->set_param_value(pos->second, values[i]);
+    }
+}
+    
 string synth::preset_list::get_preset_filename()
 {
     const char *home = getenv("HOME");
@@ -143,6 +167,27 @@ void preset_list::xml_end_element_handler(void *user_data, const char *name)
     throw preset_exception("Invalid XML element close: %s", name, 0);
 }
 
+bool preset_list::load_defaults()
+{
+    try {
+        struct stat st;
+        if (!stat(preset_list::get_preset_filename().c_str(), &st)) {
+            load(preset_list::get_preset_filename().c_str());
+            if (!presets.empty())
+                return true;
+        }
+        if (presets.empty() && !stat(PKGLIBDIR "/presets.xml", &st)) {
+            load(PKGLIBDIR "/presets.xml");
+            return true;
+        }
+    }
+    catch(preset_exception &ex)
+    {
+        return false;
+    }
+    return false;
+}
+
 void preset_list::load(const char *filename)
 {
     state = START;
diff --git a/src/preset_gui.cpp b/src/preset_gui.cpp
index 0005326..22e15e9 100644
--- a/src/preset_gui.cpp
+++ b/src/preset_gui.cpp
@@ -90,24 +90,7 @@ void synth::activate_preset(GtkAction *action, activate_preset_params *params)
     plugin_preset &p = global_presets.presets[params->preset];
     if (p.plugin != gui->effect_name)
         return;
-    map<string, int> names;
-    int count = gui->plugin->get_param_count();
-    // this is deliberately done in two separate loops - if you wonder why, just think for a while :)
-    for (int i = 0; i < count; i++)
-        names[gui->plugin->get_param_props(i)->name] = i;
-    for (int i = 0; i < count; i++)
-        names[gui->plugin->get_param_props(i)->short_name] = i;
-    // no support for unnamed parameters... tough luck :)
-    for (unsigned int i = 0; i < min(p.param_names.size(), p.values.size()); i++)
-    {
-        map<string, int>::iterator pos = names.find(p.param_names[i]);
-        if (pos == names.end()) {
-            // XXXKF should have a mechanism for notifying a GUI
-            printf("Warning: unknown parameter %s for plugin %s\n", p.param_names[i].c_str(), gui->effect_name);
-            continue;
-        }
-        gui->plugin->set_param_value(pos->second, p.values[i]);
-    }
+    p.activate(gui->plugin);
     gui->refresh();
 }
 

-- 
calf audio plugins packaging



More information about the pkg-multimedia-commits mailing list