~ubuntustudio-dev/ubuntustudio-packaging/jack-rack

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
/*
 *   JACK Rack
 *    
 *   Copyright (C) Robert Ham 2002, 2003 (node@users.sourceforge.net)
 *    
 *   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., 675 Mass Ave, Cambridge, MA 02139, USA.
 */
 
#define _GNU_SOURCE

#include "ac_config.h"

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <unistd.h>

#include <gtk/gtk.h>
#include <ladspa.h>

#ifdef HAVE_GNOME
#include <libgnomeui/libgnomeui.h>
#endif

#include "jack_rack.h"
#include "lock_free_fifo.h"
#include "plugin_slot_callbacks.h"
#include "control_message.h"
#include "globals.h"
#include "file.h"
#include "ui.h"
#include "wet_dry_controls.h"
#include "midi_control.h"

void
slot_change_cb (GtkMenuItem * menuitem, gpointer user_data)
{
  plugin_slot_t * plugin_slot;
  plugin_desc_t * desc;
  
  plugin_slot = user_data;
  
  desc = (plugin_desc_t *) g_object_get_data (G_OBJECT(menuitem), "jack-rack-plugin-desc");

  plugin_slot_send_change_plugin (plugin_slot, desc);
}

void
slot_move_cb (GtkButton * button, gpointer user_data)
{
  plugin_slot_t * plugin_slot;
  gboolean up;

  plugin_slot = user_data;
  up = GPOINTER_TO_INT (g_object_get_data (G_OBJECT(button), "jack-rack-up"));
  
  jack_rack_send_move_plugin_slot (plugin_slot->jack_rack, plugin_slot, up);
}

void
slot_remove_cb (GtkButton * button, gpointer user_data)
{
  plugin_slot_t * plugin_slot;
  
  plugin_slot = (plugin_slot_t *) user_data;
  
  jack_rack_send_remove_plugin_slot (plugin_slot->jack_rack, plugin_slot);
}


gboolean
slot_ablise_cb (GtkWidget * button, GdkEventButton *event, gpointer user_data)
{
  if (event->type == GDK_BUTTON_PRESS)
    {
      switch (event->button)
	    {
	  case 1:
	    {
	      plugin_slot_t * plugin_slot; 
	      gboolean ablise;

          plugin_slot = (plugin_slot_t *) user_data;
	      ablise = settings_get_enabled (plugin_slot->settings) ? FALSE : TRUE;
	    
	      plugin_slot_send_ablise (plugin_slot, ablise);
	    
	      return TRUE;
	    }
	  case 3:
	    {
	      ui_t * ui;
	    
	      plugin_slot_t * plugin_slot; 
	    
	      plugin_slot = (plugin_slot_t *) user_data;
	    
	      ui = plugin_slot->jack_rack->ui;
	    
	      g_object_set_data (G_OBJECT (ui->midi_menu_item), 
			       "jack-rack-ctrl-type",
			       GINT_TO_POINTER(2/*PLUGIN_ENABLE_CONTROL*/)); 
	      g_object_set_data (G_OBJECT (ui->midi_menu_item), 
			       "jack-rack-plugin-slot",
			       plugin_slot);
	      gtk_menu_popup (GTK_MENU (ui->midi_menu), NULL, NULL, NULL, NULL, event->button, event->time);
	    
	      return TRUE;
	    }
      }
    }
  
  return FALSE;
}

gboolean
slot_wet_dry_cb (GtkWidget * button, GdkEventButton *event, gpointer user_data)
{
  if (event->type == GDK_BUTTON_PRESS)
    {
      plugin_slot_t * plugin_slot; 
      gboolean ablise;
    
      plugin_slot = (plugin_slot_t *) user_data;
      ablise = settings_get_wet_dry_enabled (plugin_slot->settings) ? FALSE : TRUE;
  
      plugin_slot_send_ablise_wet_dry (plugin_slot, ablise);
  
      return TRUE;
  }
  
  return FALSE;
}
    	                              

void
slot_wet_dry_control_cb (GtkRange * range, gpointer user_data)
{
  LADSPA_Data value;
  wet_dry_controls_t * wet_dry;
  unsigned long channel;
  
  wet_dry = (wet_dry_controls_t *) user_data;
  channel = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT(range), "jack-rack-wet-dry-channel"));
  value = gtk_range_get_value (range);

  lff_write (wet_dry->fifos + channel, &value);
  
  settings_set_wet_dry_value (wet_dry->plugin_slot->settings, channel, value);
  
  /* set peers */
  if (settings_get_wet_dry_locked (wet_dry->plugin_slot->settings))
    {
      unsigned long c;
      for (c = 0; c < wet_dry->plugin_slot->jack_rack->channels ; c++)
        if (c != channel)
          gtk_range_set_value (GTK_RANGE(wet_dry->controls[c]),
                               gtk_range_get_value (range));
    }
}

void
slot_wet_dry_lock_cb    (GtkToggleButton * button, gpointer user_data)
{
  wet_dry_controls_t * wet_dry;
  
  wet_dry = (wet_dry_controls_t *) user_data;
  
  plugin_slot_set_wet_dry_locked (wet_dry->plugin_slot,
                                  gtk_toggle_button_get_active (button));
}

void
slot_lock_all_cb (GtkToggleButton * button, gpointer user_data)
{
  gboolean lock_all;
  plugin_slot_t * plugin_slot;
  guint lock_copy;
  
  lock_all = gtk_toggle_button_get_active (button);
  plugin_slot = (plugin_slot_t *) user_data;
  lock_copy = GPOINTER_TO_UINT (g_object_get_data (G_OBJECT(button), "jack-rack-lock-copy"));

  plugin_slot_set_lock_all (plugin_slot, lock_all, lock_copy);
  
  g_object_set_data (G_OBJECT(button), "jack-rack-lock-copy", GINT_TO_POINTER (0));
}

/* EOF */