summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-07-31 16:13:59 +0200
committerGravatar Alexey Yakovenko <wakeroid@gmail.com>2009-07-31 16:13:59 +0200
commitbeccecbc98af693c3ecfb92573e278d73314c529 (patch)
tree79b1a44c26008c5c273f56b6e5e5b2cd02865835
parent1e7d369b182d10a50fda73038a539a78ed548013 (diff)
initial channel muting support (gme only for now)
-rw-r--r--callbacks.c60
-rw-r--r--callbacks.h20
-rw-r--r--cgme.c24
-rw-r--r--codec.h2
-rw-r--r--deadbeef.glade140
-rw-r--r--interface.c70
6 files changed, 304 insertions, 12 deletions
diff --git a/callbacks.c b/callbacks.c
index 2e31817e..4d301444 100644
--- a/callbacks.c
+++ b/callbacks.c
@@ -403,3 +403,63 @@ on_playlist_drag_leave (GtkWidget *widget,
+
+void
+on_voice1_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ codec_lock ();
+ if (playlist_current.codec && playlist_current.codec->mutevoice) {
+ playlist_current.codec->mutevoice (0, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 0 : 1);
+ }
+ codec_unlock ();
+}
+
+
+void
+on_voice2_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ codec_lock ();
+ if (playlist_current.codec && playlist_current.codec->mutevoice) {
+ playlist_current.codec->mutevoice (1, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 0 : 1);
+ }
+ codec_unlock ();
+}
+
+
+void
+on_voice3_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ codec_lock ();
+ if (playlist_current.codec && playlist_current.codec->mutevoice) {
+ playlist_current.codec->mutevoice (2, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 0 : 1);
+ }
+ codec_unlock ();
+}
+
+
+void
+on_voice4_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ codec_lock ();
+ if (playlist_current.codec && playlist_current.codec->mutevoice) {
+ playlist_current.codec->mutevoice (3, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 0 : 1);
+ }
+ codec_unlock ();
+}
+
+
+void
+on_voice5_clicked (GtkButton *button,
+ gpointer user_data)
+{
+ codec_lock ();
+ if (playlist_current.codec && playlist_current.codec->mutevoice) {
+ playlist_current.codec->mutevoice (4, gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (button)) ? 0 : 1);
+ }
+ codec_unlock ();
+}
+
diff --git a/callbacks.h b/callbacks.h
index bc5a913a..93e0faa4 100644
--- a/callbacks.h
+++ b/callbacks.h
@@ -169,3 +169,23 @@ gboolean
on_playlist_motion_notify_event (GtkWidget *widget,
GdkEventMotion *event,
gpointer user_data);
+
+void
+on_voice1_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_voice2_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_voice3_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_voice4_clicked (GtkButton *button,
+ gpointer user_data);
+
+void
+on_voice5_clicked (GtkButton *button,
+ gpointer user_data);
diff --git a/cgme.c b/cgme.c
index d0d4b833..72193c29 100644
--- a/cgme.c
+++ b/cgme.c
@@ -10,12 +10,14 @@ static Music_Emu *emu;
static int reallength;
static int nzerosamples;
extern int sdl_player_freq; // hack!
+static uint32_t cgme_voicemask = 0;
int
cgme_init (const char *fname, int track, float start, float end) {
if (gme_open_file (fname, &emu, sdl_player_freq)) {
return -1;
}
+ gme_mute_voices (emu, cgme_voicemask);
gme_start_track (emu, track);
track_info_t inf;
gme_track_info (emu, &inf, track);
@@ -91,7 +93,7 @@ int
cgme_add (const char *fname) {
// printf ("adding %s chiptune\n", fname);
Music_Emu *emu;
- if (!gme_open_file (fname, &emu, 44100)) {
+ if (!gme_open_file (fname, &emu, gme_info_only)) {
int cnt = gme_track_count (emu);
for (int i = 0; i < cnt; i++) {
track_info_t inf;
@@ -146,6 +148,22 @@ const char **cgme_getexts (void) {
return exts;
}
+int
+cgme_numvoices (void) {
+ if (!emu) {
+ return 0;
+ }
+ return gme_voice_count (emu);
+}
+
+void
+cgme_mutevoice (int voice, int mute) {
+ cgme_voicemask &= ~ (1<<voice);
+ cgme_voicemask |= ((mute ? 1 : 0) << voice);
+ if (emu) {
+ gme_mute_voices (emu, cgme_voicemask);
+ }
+}
codec_t cgme = {
.init = cgme_init,
@@ -153,6 +171,8 @@ codec_t cgme = {
.read = cgme_read,
.seek = cgme_seek,
.add = cgme_add,
- .getexts = cgme_getexts
+ .getexts = cgme_getexts,
+ .numvoices = cgme_numvoices,
+ .mutevoice = cgme_mutevoice
};
diff --git a/codec.h b/codec.h
index ffb4e8f5..5e86cb78 100644
--- a/codec.h
+++ b/codec.h
@@ -19,6 +19,8 @@ typedef struct codec_s {
int (*seek) (float time);
int (*add) (const char *fname);
const char ** (*getexts) (void);
+ int (*numvoices) (void);
+ void (*mutevoice) (int voice, int mute);
fileinfo_t info;
} codec_t;
diff --git a/deadbeef.glade b/deadbeef.glade
index f5e56d95..37372eba 100644
--- a/deadbeef.glade
+++ b/deadbeef.glade
@@ -457,16 +457,137 @@
<property name="snap_edge">GTK_POS_TOP</property>
<child>
- <widget class="GtkHScale" id="volume">
- <property name="width_request">80</property>
+ <widget class="GtkVBox" id="vbox2">
<property name="visible">True</property>
- <property name="draw_value">False</property>
- <property name="value_pos">GTK_POS_TOP</property>
- <property name="digits">1</property>
- <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
- <property name="inverted">False</property>
- <property name="adjustment">100 0 100 0 0 0</property>
- <signal name="value_changed" handler="on_volume_value_changed" last_modification_time="Fri, 03 Jul 2009 23:43:47 GMT"/>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkHScale" id="volume">
+ <property name="width_request">80</property>
+ <property name="visible">True</property>
+ <property name="draw_value">False</property>
+ <property name="value_pos">GTK_POS_TOP</property>
+ <property name="digits">1</property>
+ <property name="update_policy">GTK_UPDATE_CONTINUOUS</property>
+ <property name="inverted">False</property>
+ <property name="adjustment">100 0 100 0 0 0</property>
+ <signal name="value_changed" handler="on_volume_value_changed" last_modification_time="Fri, 03 Jul 2009 23:43:47 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkHBox" id="hbox5">
+ <property name="visible">True</property>
+ <property name="homogeneous">False</property>
+ <property name="spacing">0</property>
+
+ <child>
+ <widget class="GtkCheckButton" id="voice1">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_voice1_clicked" last_modification_time="Fri, 31 Jul 2009 13:54:09 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="voice2">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_voice2_clicked" last_modification_time="Fri, 31 Jul 2009 13:54:14 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="voice3">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_voice3_clicked" last_modification_time="Fri, 31 Jul 2009 13:54:18 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="voice4">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_voice4_clicked" last_modification_time="Fri, 31 Jul 2009 13:54:22 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+
+ <child>
+ <widget class="GtkCheckButton" id="voice5">
+ <property name="visible">True</property>
+ <property name="label" translatable="yes"></property>
+ <property name="use_underline">True</property>
+ <property name="relief">GTK_RELIEF_NORMAL</property>
+ <property name="focus_on_click">True</property>
+ <property name="active">True</property>
+ <property name="inconsistent">False</property>
+ <property name="draw_indicator">True</property>
+ <signal name="clicked" handler="on_voice5_clicked" last_modification_time="Fri, 31 Jul 2009 14:04:00 GMT"/>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">False</property>
+ <property name="fill">False</property>
+ </packing>
+ </child>
+ </widget>
+ <packing>
+ <property name="padding">0</property>
+ <property name="expand">True</property>
+ <property name="fill">True</property>
+ </packing>
+ </child>
</widget>
</child>
</widget>
@@ -515,6 +636,7 @@
<child>
<widget class="GtkHBox" id=" ">
+ <property name="border_width">3</property>
<property name="visible">True</property>
<property name="homogeneous">False</property>
<property name="spacing">0</property>
diff --git a/interface.c b/interface.c
index b0fbf2e6..e1831c8f 100644
--- a/interface.c
+++ b/interface.c
@@ -73,7 +73,14 @@ create_mainwin (void)
GtkWidget *image6;
GtkWidget *label3;
GtkWidget *handlebox3;
+ GtkWidget *vbox2;
GtkWidget *volume;
+ GtkWidget *hbox5;
+ GtkWidget *voice1;
+ GtkWidget *voice2;
+ GtkWidget *voice3;
+ GtkWidget *voice4;
+ GtkWidget *voice5;
GtkWidget *handlebox4;
GtkWidget *playpos;
GtkWidget *_;
@@ -273,13 +280,51 @@ create_mainwin (void)
gtk_box_pack_start (GTK_BOX (hbox2), handlebox3, FALSE, TRUE, 0);
gtk_container_set_border_width (GTK_CONTAINER (handlebox3), 1);
+ vbox2 = gtk_vbox_new (FALSE, 0);
+ gtk_widget_show (vbox2);
+ gtk_container_add (GTK_CONTAINER (handlebox3), vbox2);
+
volume = gtk_hscale_new (GTK_ADJUSTMENT (gtk_adjustment_new (100, 0, 100, 0, 0, 0)));
gtk_widget_show (volume);
- gtk_container_add (GTK_CONTAINER (handlebox3), volume);
+ gtk_box_pack_start (GTK_BOX (vbox2), volume, TRUE, TRUE, 0);
gtk_widget_set_size_request (volume, 80, -1);
GTK_WIDGET_UNSET_FLAGS (volume, GTK_CAN_FOCUS);
gtk_scale_set_draw_value (GTK_SCALE (volume), FALSE);
+ hbox5 = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox5);
+ gtk_box_pack_start (GTK_BOX (vbox2), hbox5, TRUE, TRUE, 0);
+
+ voice1 = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (voice1);
+ gtk_box_pack_start (GTK_BOX (hbox5), voice1, FALSE, FALSE, 0);
+ GTK_WIDGET_UNSET_FLAGS (voice1, GTK_CAN_FOCUS);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (voice1), TRUE);
+
+ voice2 = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (voice2);
+ gtk_box_pack_start (GTK_BOX (hbox5), voice2, FALSE, FALSE, 0);
+ GTK_WIDGET_UNSET_FLAGS (voice2, GTK_CAN_FOCUS);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (voice2), TRUE);
+
+ voice3 = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (voice3);
+ gtk_box_pack_start (GTK_BOX (hbox5), voice3, FALSE, FALSE, 0);
+ GTK_WIDGET_UNSET_FLAGS (voice3, GTK_CAN_FOCUS);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (voice3), TRUE);
+
+ voice4 = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (voice4);
+ gtk_box_pack_start (GTK_BOX (hbox5), voice4, FALSE, FALSE, 0);
+ GTK_WIDGET_UNSET_FLAGS (voice4, GTK_CAN_FOCUS);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (voice4), TRUE);
+
+ voice5 = gtk_check_button_new_with_mnemonic ("");
+ gtk_widget_show (voice5);
+ gtk_box_pack_start (GTK_BOX (hbox5), voice5, FALSE, FALSE, 0);
+ GTK_WIDGET_UNSET_FLAGS (voice5, GTK_CAN_FOCUS);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (voice5), TRUE);
+
handlebox4 = gtk_handle_box_new ();
gtk_widget_show (handlebox4);
gtk_box_pack_start (GTK_BOX (hbox2), handlebox4, FALSE, TRUE, 0);
@@ -296,6 +341,7 @@ create_mainwin (void)
_ = gtk_hbox_new (FALSE, 0);
gtk_widget_show (_);
gtk_box_pack_start (GTK_BOX (vbox1), _, TRUE, TRUE, 0);
+ gtk_container_set_border_width (GTK_CONTAINER (_), 3);
playlist = gtk_drawing_area_new ();
gtk_widget_show (playlist);
@@ -367,6 +413,21 @@ create_mainwin (void)
g_signal_connect ((gpointer) volume, "value_changed",
G_CALLBACK (on_volume_value_changed),
NULL);
+ g_signal_connect ((gpointer) voice1, "clicked",
+ G_CALLBACK (on_voice1_clicked),
+ NULL);
+ g_signal_connect ((gpointer) voice2, "clicked",
+ G_CALLBACK (on_voice2_clicked),
+ NULL);
+ g_signal_connect ((gpointer) voice3, "clicked",
+ G_CALLBACK (on_voice3_clicked),
+ NULL);
+ g_signal_connect ((gpointer) voice4, "clicked",
+ G_CALLBACK (on_voice4_clicked),
+ NULL);
+ g_signal_connect ((gpointer) voice5, "clicked",
+ G_CALLBACK (on_voice5_clicked),
+ NULL);
g_signal_connect ((gpointer) playpos, "value_changed",
G_CALLBACK (on_playpos_value_changed),
NULL);
@@ -461,7 +522,14 @@ create_mainwin (void)
GLADE_HOOKUP_OBJECT (mainwin, image6, "image6");
GLADE_HOOKUP_OBJECT (mainwin, label3, "label3");
GLADE_HOOKUP_OBJECT (mainwin, handlebox3, "handlebox3");
+ GLADE_HOOKUP_OBJECT (mainwin, vbox2, "vbox2");
GLADE_HOOKUP_OBJECT (mainwin, volume, "volume");
+ GLADE_HOOKUP_OBJECT (mainwin, hbox5, "hbox5");
+ GLADE_HOOKUP_OBJECT (mainwin, voice1, "voice1");
+ GLADE_HOOKUP_OBJECT (mainwin, voice2, "voice2");
+ GLADE_HOOKUP_OBJECT (mainwin, voice3, "voice3");
+ GLADE_HOOKUP_OBJECT (mainwin, voice4, "voice4");
+ GLADE_HOOKUP_OBJECT (mainwin, voice5, "voice5");
GLADE_HOOKUP_OBJECT (mainwin, handlebox4, "handlebox4");
GLADE_HOOKUP_OBJECT (mainwin, playpos, "playpos");
GLADE_HOOKUP_OBJECT (mainwin, _, "_");