1 // ------------------------------------------------------------------------
2 // eca-chainsetup-edit.h: Chainsetup edit object
3 // Copyright (C) 2009,2012 Kai Vehmanen
4 //
5 // Attributes:
6 //     eca-style-version: 3
7 //
8 // This program is free software; you can redistribute it and/or modify
9 // it under the terms of the GNU General Public License as published by
10 // the Free Software Foundation; either version 2 of the License, or
11 // (at your option) any later version.
12 //
13 // This program is distributed in the hope that it will be useful,
14 // but WITHOUT ANY WARRANTY; without even the implied warranty of
15 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
16 // GNU General Public License for more details.
17 //
18 // You should have received a copy of the GNU General Public License
19 // along with this program; if not, write to the Free Software
20 // Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307  USA
21 // ------------------------------------------------------------------------
22 
23 #ifndef INCLUDED_ECA_CHAINSETUP_EDIT_H
24 #define INCLUDED_ECA_CHAINSETUP_EDIT_H
25 
26 class CHAIN;
27 class ECA_CHAINSETUP;
28 
29 namespace ECA {
30   enum Chainsetup_edit_type {
31 
32     edit_c_bypass = 0,
33     edit_c_muting,
34     edit_cop_add,
35     edit_cop_bypass,
36     edit_cop_set_param,
37     edit_ctrl_add,
38     edit_ctrl_set_param,
39   };
40 
41   /*
42    * Chainsetup edit objects are defined for all operations
43    * that can be performed either from the real-time engine
44    * (if modifying chainsetup that is currently run), or
45    * from the non-real-time control thread (modifying
46    * selected but not running chainsetup).
47    *
48    * Using edit objects avoids duplicated code to describe
49    * and parse the needed actions in both ECA_ENGINE and
50    * ECA_CONTROL.
51    */
52 
53   struct chainsetup_edit {
54 
55     Chainsetup_edit_type type;
56     const ECA_CHAINSETUP *cs_ptr;
57 
58     /* FIXME: should a version tag be added as way to invalidate
59      *        edit objects in case chainsetup is modified */
60 
61     union {
62       struct {
63 	int chain;     /**< @see ECA_CHAINSETUP::get_chain_index() */
64 	int val;
65       } c_bypass;
66 
67       struct {
68 	int chain;     /**< @see ECA_CHAINSETUP::get_chain_index() */
69 	int val;
70       } c_muting;
71 
72       struct {
73 	int chain;     /**< @see ECA_CHAINSETUP::get_chain_index() */
74 	int op;        /**< @see CHAIN::set_parameter() */
75 	int param;     /**< @see CHAIN::set_parameter() */
76 	double value;  /**< @see CHAIN::set_parameter() */
77       } cop_set_param;
78 
79       struct {
80 	int chain;     /**< @see ECA_CHAINSETUP::get_chain_index() */
81 	int op;        /**< @see CHAIN::bypass_operator() */
82 	int bypass;    /**< @see CHAIN::bypass_operator() */
83       } cop_bypass;
84 
85       struct {
86         int chain;     /**< @see ECA_CHAINSETUP::get_chain_index() */
87       } c_generic_param;
88 
89       struct {
90 	int chain;     /**< @see ECA_CHAINSETUP::get_chain_index() */
91 	int op;        /**< @see CHAIN::set_controller_parameter() */
92 	int param;     /**< @see CHAIN::set_controller_parameter() */
93 	double value;  /**< @see CHAIN::set_controller_parameter() */
94       } ctrl_set_param;
95     } m;
96 
97     bool need_chain_reinit;
98     std::string param; /**< arbitrary string parameter, semantics
99                           depend on 'type' */
100   };
101 
102   typedef struct chainsetup_edit chainsetup_edit_t;
103 }
104 
105 #endif /* INCLUDED_ECA_CHAINSETUP_EDIT_H */
106