Update NTK.
[nondaw.git] / mixer / src / Controller_Module.H
blobde29b851b68fd07ddac1485447ba4dd6844f42ce
2 /*******************************************************************************/
3 /* Copyright (C) 2009 Jonathan Moore Liles                                     */
4 /*                                                                             */
5 /* This program is free software; you can redistribute it and/or modify it     */
6 /* under the terms of the GNU General Public License as published by the       */
7 /* Free Software Foundation; either version 2 of the License, or (at your      */
8 /* option) any later version.                                                  */
9 /*                                                                             */
10 /* This program is distributed in the hope that it will be useful, but WITHOUT */
11 /* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or       */
12 /* FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License for   */
13 /* more details.                                                               */
14 /*                                                                             */
15 /* You should have received a copy of the GNU General Public License along     */
16 /* with This program; see the file COPYING.  If not,write to the Free Software */
17 /* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.  */
18 /*******************************************************************************/
20 #pragma once
22 #include "Module.H"
23 #include <vector>
24 #include "JACK/Port.H"
25 #include "OSC/Endpoint.H"
27 class Fl_Menu_Button;
28 class Fl_Menu_;
30 class Fl_Valuator;
32 class Controller_Module : public Module
35     static void update_cb ( void *v );
36     void update_cb ( void );
38     bool _pad;
40     volatile float control_value;
42     Fl_Menu_Button & menu ( void );
43     static void menu_cb ( Fl_Widget *w, void *v );
44     void menu_cb ( const Fl_Menu_ *m );
46     char *_osc_path;
47     char *_osc_path_cv;
49 public:
51     enum Mode { GUI, CV, OSC, MIDI };
53     enum Type { KNOB,
54                 SLIDER,
55                 SPINNER,
56                 TOGGLE,
57                 SPATIALIZATION };
59     Mode mode ( void ) const { return _mode; }
60     void mode ( Mode v );
62     Type type ( void ) const { return _type; }
64     Controller_Module ( bool is_default = false );
65     virtual ~Controller_Module ( );
67     const char *name ( void ) const { return "Controller"; }
69     int can_support_inputs ( int ) { return 0; }
70     bool configure_inputs ( int ) { return false; }
72     void pad ( bool v ) { _pad = v; }
74     static void cb_handle ( Fl_Widget *w, void *v );
75     void cb_handle ( Fl_Widget *w );
76     static void cb_spatializer_handle ( Fl_Widget *w, void *v );
77     void cb_spatializer_handle ( Fl_Widget *w );
79     void connect_to ( Port *p );
80     bool connect_spatializer_to ( Module *m );
81     void disconnect ( void );
83     void handle_control_changed ( Port *p );
84     void handle_chain_name_changed ( void );
86     virtual void command_remove ( void );
88     LOG_CREATE_FUNC( Controller_Module );
90     void process ( nframes_t nframes );
92     void draw ( void )
93         {
94             draw_box();
95             Fl_Group::draw();
96         }
98     int handle ( int m );
100 //    void set_control_value ( float f ) { control_value = f; }
102 protected:
104     void get ( Log_Entry &e ) const;
105     void set ( Log_Entry &e );
107 private:
109     char *generate_osc_path ( void );
110     void change_osc_path ( char *path );
111     
112     std::vector<JACK::Port> jack_input;
113     Mode _mode;
114     Type _type;
116     Fl_Valuator *control;