Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

adplug: update upstream library and add OPL synth options #3129

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,206 changes: 646 additions & 560 deletions osx/deadbeef.xcodeproj/project.pbxproj

Large diffs are not rendered by default.

81 changes: 59 additions & 22 deletions plugins/adplug/adplug-db.cpp
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
/*
DeaDBeeF ADPLUG plugin
Copyright (C) 2009-2014 Oleksiy Yakovenko <[email protected]>
Copyright (C) 2024 Thomas Jepp <[email protected]>

This software is provided 'as-is', without any express or implied
warranty. In no event will the authors be held liable for any damages
Expand All @@ -27,8 +28,12 @@
#include <deadbeef/deadbeef.h>
#include <deadbeef/strdupa.h>
#include "adplug.h"
#include "opl.h"
#include "emuopl.h"
#include "kemuopl.h"
#include "nemuopl.h"
#include "temuopl.h"
#include "wemuopl.h"
#include "surroundopl.h"
#include "silentopl.h"

Expand Down Expand Up @@ -66,35 +71,67 @@ adplug_open (uint32_t hints) {
return _info;
}

Copl*
adplug_create_opl(int samplerate, bool is16bit, bool stereo) {
COPLprops aprops, bprops;
int synth = deadbeef->conf_get_int("adplug.synth", 0);

Copl* opl;

switch (synth) {
case 0: // NukedOPL3
default:
opl = new CNemuopl(samplerate);
trace("adplug: created CNemuopl instance\n");
break;

case 1: // DOSBox OPL3
opl = new CWemuopl(samplerate, is16bit, stereo);
trace("adplug: created CWemuopl instance\n");
break;

case 2: // Tatsuyuki Satoh's OPL2 emulator
opl = new CTemuopl(samplerate, is16bit, stereo);
trace("adplug: created CTemuopl instance\n");
break;

case 3: // Ken Silverman's OPL emulator
aprops.opl = new CKemuopl(samplerate, is16bit, false);
aprops.use16bit = is16bit;
aprops.stereo = false;
bprops.opl = new CKemuopl(samplerate, is16bit, false);
bprops.use16bit = is16bit;
bprops.stereo = false;
opl = new CSurroundopl(&aprops, &bprops, is16bit);
trace("adplug: created CKemuopl instance\n");
break;

case 4: // Simon Peter's OPL emulator
aprops.opl = new CEmuopl(samplerate, is16bit, false);
aprops.use16bit = is16bit;
aprops.stereo = false;
bprops.opl = new CEmuopl(samplerate, is16bit, false);
bprops.use16bit = is16bit;
bprops.stereo = false;
opl = new CSurroundopl(&aprops, &bprops, is16bit);
trace("adplug: created Cemuopl instance\n");
break;

}

return opl;
}

int
adplug_init (DB_fileinfo_t *_info, DB_playItem_t *it) {
// prepare to decode the track
// return -1 on failure
adplug_info_t *info = (adplug_info_t *)_info;

int samplerate = deadbeef->conf_get_int ("synth.samplerate", 44100);
int samplerate = deadbeef->conf_get_int ("adplug.samplerate", 49716);
int bps = 16; // NOTE: there's no need to support 8bit input, because adplug simply downgrades 16bit signal to 8bits
int channels = 2;
if (deadbeef->conf_get_int ("adplug.surround", 1)) {
if (deadbeef->conf_get_int ("adplug.use_ken", 0)) {
Copl *a = new CKemuopl(samplerate, bps == 16, false);
Copl *b = new CKemuopl(samplerate, bps == 16, false);
info->opl = new CSurroundopl(a, b, bps == 16);
}
else {
Copl *a = new CEmuopl(samplerate, bps == 16, false);
Copl *b = new CEmuopl(samplerate, bps == 16, false);
info->opl = new CSurroundopl(a, b, bps == 16);
}
}
else {
if (deadbeef->conf_get_int ("adplug.use_ken", 0)) {
info->opl = new CKemuopl (samplerate, bps == 16, channels == 2);
}
else {
info->opl = new CEmuopl (samplerate, bps == 16, channels == 2);
}
}
info->opl = adplug_create_opl(samplerate, bps == 16, channels == 2);
deadbeef->pl_lock ();
const char *uri = strdupa (deadbeef->pl_find_meta (it, ":URI"));
deadbeef->pl_unlock ();
Expand All @@ -119,7 +156,7 @@ adplug_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;

trace ("adplug_init ok (songlength=%d, duration=%f, totalsamples=%d)\n", info->decoder->songlength (info->subsong), deadbeef->pl_get_item_duration (it), info->totalsamples);
trace ("adplug_init ok (samplerate=%d, bps=%d, channels=%d, songlength=%d, duration=%f, totalsamples=%d)\n", samplerate, bps, channels, info->decoder->songlength (info->subsong), deadbeef->pl_get_item_duration (it), info->totalsamples);

return 0;
}
Expand Down
Loading
Loading