summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--plugins/gme/cgme.c35
-rw-r--r--plugins/gtkui/gtkui.c1
-rw-r--r--plugins/gtkui/widgets.c44
-rw-r--r--plugins/gtkui/widgets.h3
-rw-r--r--plugins/sid/csid.cpp67
5 files changed, 91 insertions, 59 deletions
diff --git a/plugins/gme/cgme.c b/plugins/gme/cgme.c
index a3e9452a..53fa6eb8 100644
--- a/plugins/gme/cgme.c
+++ b/plugins/gme/cgme.c
@@ -36,12 +36,13 @@ static DB_decoder_t plugin;
static DB_functions_t *deadbeef;
static int conf_fadeout = 10;
static int conf_loopcount = 2;
+static int chip_voices = 0xff;
+static int chip_voices_changed = 0;
typedef struct {
DB_fileinfo_t info;
Music_Emu *emu;
int reallength;
- uint32_t cgme_voicemask;
float duration; // of current song
} gme_fileinfo_t;
@@ -156,7 +157,8 @@ cgme_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
trace ("failed with error %d\n", res);
return -1;
}
- gme_mute_voices (info->emu, info->cgme_voicemask);
+ chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
+ gme_mute_voices (info->emu, chip_voices^0xff);
gme_start_track (info->emu, deadbeef->pl_find_meta_int (it, ":TRACKNUM", 0));
#ifdef GME_VERSION_055
@@ -200,6 +202,13 @@ cgme_read (DB_fileinfo_t *_info, char *bytes, int size) {
// DON'T ajust size, buffer must always be po2
//size = t * (float)info->samplerate * 4;
}
+
+ if (chip_voices_changed) {
+ chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
+ chip_voices_changed = 0;
+ gme_mute_voices (info->emu, chip_voices^0xff);
+ }
+
if (gme_play (info->emu, size/2, (short*)bytes)) {
return 0;
}
@@ -412,25 +421,6 @@ static const char * exts[]=
"ay","gbs","gym","hes","kss","nsf","nsfe","sap","spc","vgm","vgz",NULL
};
-#if 0
-static int
-cgme_numvoices (void) {
- if (!emu) {
- return 0;
- }
- return gme_voice_count (emu);
-}
-
-static 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);
- }
-}
-#endif
-
static int
cgme_start (void) {
conf_fadeout = deadbeef->conf_get_int ("gme.fadeout", 10);
@@ -449,6 +439,9 @@ cgme_message (uint32_t id, uintptr_t ctx, uint32_t p1, uint32_t p2) {
case DB_EV_CONFIGCHANGED:
conf_fadeout = deadbeef->conf_get_int ("gme.fadeout", 10);
conf_loopcount = deadbeef->conf_get_int ("gme.loopcount", 2);
+ if (chip_voices != deadbeef->conf_get_int ("chip.voices", 0xff)) {
+ chip_voices_changed = 1;
+ }
break;
}
return 0;
diff --git a/plugins/gtkui/gtkui.c b/plugins/gtkui/gtkui.c
index 6657bea3..6c83a1a4 100644
--- a/plugins/gtkui/gtkui.c
+++ b/plugins/gtkui/gtkui.c
@@ -933,6 +933,7 @@ gtkui_thread (void *ctx) {
w_reg_widget (_("Seekbar"), 0, w_seekbar_create, "seekbar", NULL);
w_reg_widget (_("Playback controls"), 0, w_playtb_create, "playtb", NULL);
w_reg_widget (_("Volume bar"), 0, w_volumebar_create, "volumebar", NULL);
+ w_reg_widget (_("Chiptune voices"), 0, w_ctvoices_create, "ctvoices", NULL);
mainwin = create_mainwin ();
diff --git a/plugins/gtkui/widgets.c b/plugins/gtkui/widgets.c
index ea41174b..8e12e9bd 100644
--- a/plugins/gtkui/widgets.c
+++ b/plugins/gtkui/widgets.c
@@ -212,6 +212,11 @@ typedef struct {
GtkWidget *volumebar;
} w_volumebar_t;
+typedef struct {
+ ddb_gtkui_widget_t base;
+ GtkWidget *voices[8];
+} w_ctvoices_t;
+
static int design_mode;
static ddb_gtkui_widget_t *rootwidget;
@@ -3674,3 +3679,42 @@ w_volumebar_create (void) {
w_override_signals (w->base.widget, w);
return (ddb_gtkui_widget_t*)w;
}
+
+// chiptune voice ctl
+static void
+on_voice_toggled (GtkToggleButton *togglebutton, gpointer user_data) {
+ w_ctvoices_t *w = user_data;
+ int voices = 0;
+ for (int i = 0; i < 8; i++) {
+ int active = gtk_toggle_button_get_active (GTK_TOGGLE_BUTTON (w->voices[i]));
+ voices |= active << i;
+ }
+ deadbeef->conf_set_int ("chip.voices", voices);
+ deadbeef->sendmessage (DB_EV_CONFIGCHANGED, 0, 0, 0);
+}
+
+ddb_gtkui_widget_t *
+w_ctvoices_create (void) {
+ w_ctvoices_t *w = malloc (sizeof (w_ctvoices_t));
+ memset (w, 0, sizeof (w_ctvoices_t));
+ w->base.widget = gtk_event_box_new ();
+ GtkWidget *hbox = gtk_hbox_new (FALSE, 0);
+ gtk_widget_show (hbox);
+ gtk_container_add (GTK_CONTAINER (w->base.widget), hbox);
+
+ GtkWidget *label = gtk_label_new_with_mnemonic (_("Voices:"));
+ gtk_widget_show (label);
+ gtk_box_pack_start (GTK_BOX (hbox), label, FALSE, FALSE, 0);
+
+ int voices = deadbeef->conf_get_int ("chip.voices", 0xff);
+ for (int i = 0; i < 8; i++) {
+ w->voices[i] = gtk_check_button_new ();
+ gtk_widget_show (w->voices[i]);
+ gtk_box_pack_start (GTK_BOX (hbox), w->voices[i], FALSE, FALSE, 0);
+ gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (w->voices[i]), voices & (1<<i));
+ g_signal_connect ((gpointer) w->voices[i], "toggled", G_CALLBACK (on_voice_toggled), w);
+ }
+
+ w_override_signals (w->base.widget, w);
+ return (ddb_gtkui_widget_t*)w;
+}
diff --git a/plugins/gtkui/widgets.h b/plugins/gtkui/widgets.h
index e9392325..8521e25d 100644
--- a/plugins/gtkui/widgets.h
+++ b/plugins/gtkui/widgets.h
@@ -131,4 +131,7 @@ w_playtb_create (void);
ddb_gtkui_widget_t *
w_volumebar_create (void);
+ddb_gtkui_widget_t *
+w_ctvoices_create (void);
+
#endif
diff --git a/plugins/sid/csid.cpp b/plugins/sid/csid.cpp
index 5eb717b6..c4b2744b 100644
--- a/plugins/sid/csid.cpp
+++ b/plugins/sid/csid.cpp
@@ -48,8 +48,6 @@ typedef struct {
float duration; // of the current song
} sid_info_t;
-static uint32_t csid_voicemask;
-
static inline void
le_int16 (int16_t in, unsigned char *out) {
char *pin = (char *)&in;
@@ -78,6 +76,9 @@ static int sldb_loaded;
static sldb_t *sldb;
static int sldb_disable;
+static int chip_voices = 0xff;
+static int chip_voices_changed = 0;
+
static void
sldb_load()
{
@@ -279,6 +280,20 @@ csid_open (uint32_t hints) {
return _info;
}
+static void
+csid_mute_voices (sid_info_t *info, int chip_voices) {
+ int maxsids = info->sidplay->info ().maxsids;
+ for (int k = 0; k < maxsids; k++) {
+ sidemu *emu = info->resid->getsidemu (k);
+ if (emu) {
+ for (int i = 0; i < 3; i++) {
+ bool mute = chip_voices & (1 << i) ? false : true;
+ emu->voice (i, mute ? 0x00 : 0xff, mute);
+ }
+ }
+ }
+}
+
int
csid_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
sid_info_t *info = (sid_info_t *)_info;
@@ -328,16 +343,8 @@ csid_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
_info->fmt.channelmask = _info->fmt.channels == 1 ? DDB_SPEAKER_FRONT_LEFT : (DDB_SPEAKER_FRONT_LEFT | DDB_SPEAKER_FRONT_RIGHT);
_info->readpos = 0;
- int maxsids = info->sidplay->info ().maxsids;
- for (int k = 0; k < maxsids; k++) {
- sidemu *emu = info->resid->getsidemu (k);
- if (emu) {
- for (int i = 0; i < 3; i++) {
- bool mute = csid_voicemask & (1 << i) ? true : false;
- emu->voice (i, mute ? 0x00 : 0xff, mute);
- }
- }
- }
+ chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
+ csid_mute_voices (info, chip_voices);
return 0;
}
@@ -359,6 +366,12 @@ csid_read (DB_fileinfo_t *_info, char *bytes, int size) {
return 0;
}
+ if (chip_voices_changed) {
+ chip_voices = deadbeef->conf_get_int ("chip.voices", 0xff);
+ chip_voices_changed = 0;
+ csid_mute_voices (info, chip_voices);
+ }
+
int rd = info->sidplay->play (bytes, size);
int samplesize = (_info->fmt.bps>>3) * _info->fmt.channels;
@@ -549,32 +562,6 @@ csid_insert (ddb_playlist_t *plt, DB_playItem_t *after, const char *fname) {
return after;
}
-#if 0
-int
-csid_numvoices (DB_fileinfo_t *_info) {
- return 3;
-}
-
-void
-csid_mutevoice (DB_fileinfo_t *_info, int voice, int mute) {
- sid_info_t *info = (sid_info_t *)_info;
- csid_voicemask &= ~ (1<<voice);
- csid_voicemask |= ((mute ? 1 : 0) << voice);
- if (info->resid) {
- int maxsids = info->sidplay->info ().maxsids;
- for (int k = 0; k < maxsids; k++) {
- sidemu *emu = info->resid->getsidemu (k);
- if (emu) {
- for (int i = 0; i < 3; i++) {
- bool mute = csid_voicemask & (1 << i) ? true : false;
- emu->voice (i, mute ? 0x00 : 0xff, mute);
- }
- }
- }
- }
-}
-#endif
-
static int
sid_configchanged (void) {
int conf_hvsc_enable = deadbeef->conf_get_int ("hvsc_enable", 0);
@@ -590,6 +577,10 @@ sid_configchanged (void) {
sldb_loaded = 0;
}
+ if (chip_voices != deadbeef->conf_get_int ("chip.voices", 0xff)) {
+ chip_voices_changed = 1;
+ }
+
return 0;
}