1 /* nekobee DSSI software synthesizer GUI
3 * Copyright (C) 2004 Sean Bolton
5 * This program is free software; you can redistribute it and/or
6 * modify it under the terms of the GNU General Public License as
7 * published by the Free Software Foundation; either version 2 of
8 * the License, or (at your option) any later version.
10 * This program is distributed in the hope that it will be
11 * useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR
13 * PURPOSE. See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public
16 * License along with this program; if not, write to the Free
17 * Software Foundation, Inc., 59 Temple Place, Suite 330, Boston,
28 #include <gdk/gdkkeysyms.h>
31 #include "newslider.h"
34 #include "nekobee_ports.h"
35 #include "nekobee_synth.h"
36 #include "new_callbacks.h"
37 #include "new_interface.h"
39 GtkWidget
*main_window
;
40 GtkWidget
*save_file_selection
;
42 GtkWidget
*osc1_waveform_pixmap
;
44 GtkObject
*tuning_adj
;
45 GtkObject
*polyphony_adj
;
46 GtkWidget
*monophonic_option_menu
;
47 GtkWidget
*glide_option_menu
;
48 GtkObject
*bendrange_adj
;
50 GtkObject
*voice_widget
[XSYNTH_PORTS_COUNT
];
52 #if GTK_CHECK_VERSION(2, 0, 0)
53 #define GTK20SIZEGROUP GtkSizeGroup
55 #define GTK20SIZEGROUP gpointer
59 create_voice_knob(GtkWidget
*main_window
, int index
, GtkWidget
*fixed
,
60 gint column
, gint row
, const char *text
)
63 GtkObject
*adjustment
;
65 adjustment
= gtk_adjustment_new (0, 0, 10, 0.005, 1, 0);
66 voice_widget
[index
] = adjustment
;
68 knob
= gtk_knob_new (GTK_ADJUSTMENT (adjustment
));
69 gtk_widget_ref (knob
);
70 gtk_object_set_data_full (GTK_OBJECT (main_window
), text
, knob
,
71 (GtkDestroyNotify
) gtk_widget_unref
);
72 gtk_widget_show (knob
);
73 gtk_fixed_put (GTK_FIXED (fixed
), knob
, column
, row
);
78 create_voice_slider(GtkWidget
*main_window
, int index
, GtkWidget
*fixed
,
79 gint column
, gint row
, const char *text
)
82 GtkObject
*adjustment
;
84 adjustment
= gtk_adjustment_new (0, 0, 10, 0.005, 1, 0);
85 voice_widget
[index
] = adjustment
;
87 knob
= gtk_slider_new (GTK_ADJUSTMENT (adjustment
));
88 gtk_widget_ref (knob
);
89 gtk_object_set_data_full (GTK_OBJECT (main_window
), text
, knob
,
90 (GtkDestroyNotify
) gtk_widget_unref
);
91 gtk_widget_show (knob
);
92 gtk_fixed_put (GTK_FIXED (fixed
), knob
, column
, row
);
99 create_main_window (const char *tag
)
104 GdkPixmap
*bg_map
= NULL
;
108 main_window
= gtk_window_new (GTK_WINDOW_TOPLEVEL
);
109 gtk_object_set_data (GTK_OBJECT (main_window
), "main_window", main_window
);
110 gtk_window_set_title (GTK_WINDOW (main_window
), tag
);
112 // gjcp - FIXME - put these somewhere in a header
113 gtk_widget_set_size_request (main_window
, 600, 108);
114 gtk_window_set_default_size (GTK_WINDOW (main_window
), 600, 108);
115 gtk_window_set_resizable (GTK_WINDOW (main_window
), FALSE
);
117 gtk_widget_realize(main_window
); /* window must be realized for create_*_pixmap() */
119 // load the background up
120 bg_buf
= gdk_pixbuf_new_from_file(INSTALL_DIR
"/bg.png", NULL
);
121 gdk_pixbuf_render_pixmap_and_mask(bg_buf
, &bg_map
, NULL
, 255);
122 bg_style
= gtk_style_copy(gtk_widget_get_style(main_window
));
123 bg_style
->bg_pixmap
[GTK_STATE_NORMAL
] = bg_map
;
124 gtk_widget_set_style(main_window
, bg_style
);
126 // rather than the table layout I'm going to use fixed
127 fixed
= gtk_fixed_new ();
128 gtk_widget_show (fixed
);
129 gtk_container_add (GTK_CONTAINER (main_window
), fixed
);
133 for (i
= 0; i
< XSYNTH_PORTS_COUNT
; i
++) voice_widget
[i
] = NULL
;
135 // tuning can go from -12 to +12, so needs special poking
136 create_voice_knob(main_window
, XSYNTH_PORT_TUNING
, fixed
, 26, 46, "Tuning");
137 GTK_ADJUSTMENT(voice_widget
[XSYNTH_PORT_TUNING
])->lower
= -12.0f
;
138 GTK_ADJUSTMENT(voice_widget
[XSYNTH_PORT_TUNING
])->upper
= 12.0f
;
139 gtk_adjustment_changed (GTK_ADJUSTMENT(voice_widget
[XSYNTH_PORT_TUNING
]));
141 // wave switch also needs special poking
142 create_voice_slider(main_window
, XSYNTH_PORT_WAVEFORM
, fixed
, 116, 43, "Waveform");
143 GTK_ADJUSTMENT(voice_widget
[XSYNTH_PORT_WAVEFORM
])->upper
= 1.0f
;
144 GTK_ADJUSTMENT(voice_widget
[XSYNTH_PORT_WAVEFORM
])->step_increment
= 1.0f
;
145 gtk_adjustment_changed (GTK_ADJUSTMENT(voice_widget
[XSYNTH_PORT_WAVEFORM
]));
147 create_voice_knob(main_window
, XSYNTH_PORT_CUTOFF
, fixed
, 170, 46, "Cutoff");
148 create_voice_knob(main_window
, XSYNTH_PORT_RESONANCE
, fixed
, 242, 46, "Resonance");
149 create_voice_knob(main_window
, XSYNTH_PORT_ENVMOD
, fixed
, 314, 46, "Envmod");
150 create_voice_knob(main_window
, XSYNTH_PORT_DECAY
, fixed
, 386, 46, "Decay");
151 create_voice_knob(main_window
, XSYNTH_PORT_ACCENT
, fixed
, 458, 46, "Accent");
152 create_voice_knob(main_window
, XSYNTH_PORT_VOLUME
, fixed
, 530, 46, "Volume");
154 gtk_signal_connect(GTK_OBJECT(main_window
), "destroy",
155 GTK_SIGNAL_FUNC(gtk_main_quit
), NULL
);
156 gtk_signal_connect (GTK_OBJECT (main_window
), "delete_event",
157 (GtkSignalFunc
)on_delete_event_wrapper
,
158 (gpointer
)on_menu_quit_activate
);
161 /* connect patch edit widgets */
162 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_TUNING
]),
163 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
164 (gpointer
)XSYNTH_PORT_TUNING
);
165 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_WAVEFORM
]),
166 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
167 (gpointer
)XSYNTH_PORT_WAVEFORM
);
168 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_CUTOFF
]),
169 "value_changed", GTK_SIGNAL_FUNC (on_voice_slider_change
),
170 (gpointer
)XSYNTH_PORT_CUTOFF
);
171 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_RESONANCE
]),
172 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
173 (gpointer
)XSYNTH_PORT_RESONANCE
);
175 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_ENVMOD
]),
176 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
177 (gpointer
)XSYNTH_PORT_ENVMOD
);
178 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_DECAY
]),
179 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
180 (gpointer
)XSYNTH_PORT_DECAY
);
181 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_ACCENT
]),
182 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
183 (gpointer
)XSYNTH_PORT_ACCENT
);
184 gtk_signal_connect (GTK_OBJECT (voice_widget
[XSYNTH_PORT_VOLUME
]),
185 "value_changed", GTK_SIGNAL_FUNC(on_voice_slider_change
),
186 (gpointer
)XSYNTH_PORT_VOLUME
);
190 create_windows(const char *instance_tag
)
194 /* build a nice identifier string for the window titles */
195 if (strlen(instance_tag
) == 0) {
196 strcpy(tag
, "nekobee");
197 } else if (strstr(instance_tag
, "nekobee-DSSI") ||
198 strstr(instance_tag
, "nekobee-dssi")) {
199 if (strlen(instance_tag
) > 49) {
200 snprintf(tag
, 50, "...%s", instance_tag
+ strlen(instance_tag
) - 46); /* hope the unique info is at the end */
202 strcpy(tag
, instance_tag
);
205 if (strlen(instance_tag
) > 37) {
206 snprintf(tag
, 50, "nekobee ...%s", instance_tag
+ strlen(instance_tag
) - 34);
208 snprintf(tag
, 50, "nekobee %s", instance_tag
);
212 create_main_window(tag
);