Skip to content

Commit

Permalink
merged from lp:~kabelfrickler/mixxx/modplug
Browse files Browse the repository at this point in the history
  • Loading branch information
daschuer committed Apr 3, 2013
2 parents 47fb9a9 + 1e24b43 commit ec6bb3e
Show file tree
Hide file tree
Showing 11 changed files with 1,095 additions and 0 deletions.
1 change: 1 addition & 0 deletions mixxx/SConstruct
Expand Up @@ -48,6 +48,7 @@ available_features = [features.HifiEq,
features.Optimize,
features.FAAD,
features.WavPack,
features.ModPlug,
features.TestSuite,
features.LADSPA,
features.MSVCDebug,
Expand Down
34 changes: 34 additions & 0 deletions mixxx/build/features.py
Expand Up @@ -485,6 +485,40 @@ def sources(self, build):
'%s/RealTime.cpp'])
return sources


class ModPlug(Feature):
def description(self):
return "Modplug module decoder plugin"

def enabled(self, build):
build.flags['modplug'] = util.get_flags(build.env, 'modplug', 0)
if int(build.flags['modplug']):
return True
return False

def add_options(self, build, vars):
vars.Add('modplug', 'Set to 1 to enable libmodplug based module tracker support.', 0)

def configure(self, build, conf):
if not self.enabled(build):
return

build.env.Append(CPPDEFINES = '__MODPLUG__')

have_modplug_h = conf.CheckHeader('libmodplug/modplug.h')
have_modplug = conf.CheckLib(['modplug','libmodplug'], autoadd=True)

if not have_modplug_h:
raise Exception('Could not find libmodplug development headers.')

if not have_modplug:
raise Exception('Could not find libmodplug shared library.')

def sources(self, build):
build.env.Uic4('dlgprefmodplugdlg.ui')
return ['soundsourcemodplug.cpp', 'dlgprefmodplug.cpp']


class FAAD(Feature):
def description(self):
return "FAAD AAC audio file decoder plugin"
Expand Down
28 changes: 28 additions & 0 deletions mixxx/src/dlgpreferences.cpp
Expand Up @@ -37,6 +37,10 @@
#include "dlgprefbpm.h"
#endif

#ifdef __MODPLUG__
#include "dlgprefmodplug.h"
#endif

#include "dlgpreferences.h"
#include "dlgprefsound.h"
#include "controllers/dlgprefmappablecontroller.h"
Expand Down Expand Up @@ -108,6 +112,10 @@ DlgPreferences::DlgPreferences(MixxxApp * mixxx, SkinLoader* pSkinLoader,
#ifdef __SHOUTCAST__
m_wshoutcast = new DlgPrefShoutcast(this, config);
addPageWidget(m_wshoutcast);
#endif
#ifdef __MODPLUG__
m_wmodplug = new DlgPrefModplug(this, config);
addPageWidget(m_wmodplug);
#endif
m_wNoControllers = new DlgPrefNoControllers(this, config);
addPageWidget(m_wNoControllers);
Expand Down Expand Up @@ -152,6 +160,10 @@ DlgPreferences::DlgPreferences(MixxxApp * mixxx, SkinLoader* pSkinLoader,
connect(this, SIGNAL(showDlg()), m_wshoutcast,SLOT(slotUpdate()));
#endif

#ifdef __MODPLUG__
connect(this, SIGNAL(showDlg()), m_wmodplug,SLOT(slotUpdate()));
#endif

#ifdef __VINYLCONTROL__
connect(buttonBox, SIGNAL(accepted()), m_wvinylcontrol, SLOT(slotApply())); //It's important for this to be before the
//connect for wsound...
Expand All @@ -173,6 +185,9 @@ DlgPreferences::DlgPreferences(MixxxApp * mixxx, SkinLoader* pSkinLoader,
#ifdef __SHOUTCAST__
connect(buttonBox, SIGNAL(accepted()), m_wshoutcast,SLOT(slotApply()));
#endif
#ifdef __MODPLUG__
connect(buttonBox, SIGNAL(accepted()), m_wmodplug,SLOT(slotApply()));
#endif

//Update the library when you change the options
/*if (m_pTrack && wplaylist)
Expand Down Expand Up @@ -276,6 +291,15 @@ void DlgPreferences::createIcons()
m_pShoutcastButton->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
m_pShoutcastButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#endif

#ifdef __MODPLUG__
m_pModplugButton = new QTreeWidgetItem(contentsTreeWidget, QTreeWidgetItem::Type);
m_pModplugButton->setIcon(0, QIcon(":/images/preferences/ic_preferences_sampler.png"));
m_pModplugButton->setText(0, tr("Modplug Decoder"));
m_pModplugButton->setTextAlignment(0, Qt::AlignLeft | Qt::AlignVCenter);
m_pModplugButton->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled);
#endif

connect(contentsTreeWidget,
SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)),
this, SLOT(changePage(QTreeWidgetItem *, QTreeWidgetItem*)));
Expand Down Expand Up @@ -320,6 +344,10 @@ void DlgPreferences::changePage(QTreeWidgetItem * current, QTreeWidgetItem * pre
#ifdef __SHOUTCAST__
} else if (current == m_pShoutcastButton) {
pagesWidget->setCurrentWidget(m_wshoutcast->parentWidget()->parentWidget());
#endif
#ifdef __MODPLUG__
} else if (current == m_pModplugButton) {
pagesWidget->setCurrentWidget(m_wmodplug->parentWidget()->parentWidget());
#endif
//Handle selection of controller items
} else if (m_controllerWindowLinks.indexOf(current) >= 0) {
Expand Down
9 changes: 9 additions & 0 deletions mixxx/src/dlgpreferences.h
Expand Up @@ -45,6 +45,9 @@ class ControllerManager;
class SkinLoader;
class PlayerManager;
class VinylControlManager;
#ifdef __MODPLUG__
class DlgPrefModplug;
#endif

/**
*@author Tue & Ken Haste Andersen
Expand Down Expand Up @@ -93,6 +96,9 @@ public slots:
DlgPrefNoVinyl* m_wnovinylcontrol;
DlgPrefShoutcast* m_wshoutcast;
DlgPrefReplayGain* m_wreplaygain;
#ifdef __MODPLUG__
DlgPrefModplug* m_wmodplug;
#endif

/*
QScrollArea* m_sasound;
Expand Down Expand Up @@ -120,6 +126,9 @@ public slots:
QTreeWidgetItem* m_pVinylControlButton;
QTreeWidgetItem* m_pShoutcastButton;
QTreeWidgetItem* m_pReplayGainButton;
#ifdef __MODPLUG__
QTreeWidgetItem* m_pModplugButton;
#endif
QTreeWidgetItem* m_pControllerTreeItem;
QList<QTreeWidgetItem*> m_controllerWindowLinks;

Expand Down
173 changes: 173 additions & 0 deletions mixxx/src/dlgprefmodplug.cpp
@@ -0,0 +1,173 @@

#include <QtDebug>

#include "dlgprefmodplug.h"
#include "ui_dlgprefmodplugdlg.h"

#include "configobject.h"
#include "soundsourcemodplug.h"

#define CONFIG_KEY "[Modplug]"

DlgPrefModplug::DlgPrefModplug(QWidget *parent,
ConfigObject<ConfigValue> *_config) :
QDialog(parent),
m_pUi(new Ui::DlgPrefModplug),
m_pConfig(_config)
{
m_pUi->setupUi(this);
m_pUi->advancedSettings->setVisible(m_pUi->showAdvanced->isChecked());
}

DlgPrefModplug::~DlgPrefModplug()
{
delete m_pUi;
}

void DlgPrefModplug::slotApply()
{
applySettings();
saveSettings();
}

void DlgPrefModplug::slotUpdate()
{
loadSettings();
}

void DlgPrefModplug::loadSettings()
{
m_pUi->memoryLimit->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"PerTrackMemoryLimitMB"),"256").toInt());
m_pUi->oversampling->setChecked(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"OversamplingEnabled"),"1") == QString("1"));
m_pUi->noiseReduction->setChecked(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"NoiseReductionEnabled"),"0") == QString("1"));
m_pUi->stereoSeparation->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"StereoSeparation"),"1").toInt());
m_pUi->maxMixChannels->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"MaxMixChannels"),"128").toInt());
m_pUi->resampleMode->setCurrentIndex(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"ResamplingMode"),"1").toInt());
m_pUi->reverb->setChecked(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"ReverbEnabled"),"0") == QString("1"));
m_pUi->reverbDepth->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"ReverbLevel"),"50").toInt());
m_pUi->reverbDelay->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"ReverbDelay"),"50").toInt());
m_pUi->megabass->setChecked(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"MegabassEnabled"),"0") == QString("1"));
m_pUi->bassDepth->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"MegabassLevel"),"50").toInt());
m_pUi->bassCutoff->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"MegabassCutoff"),"50").toInt());
m_pUi->surround->setChecked(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"SurroundEnabled"),"0") == QString("1"));
m_pUi->surroundDepth->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"SurroundLevel"),"50").toInt());
m_pUi->surroundDelay->setValue(m_pConfig->getValueString(
ConfigKey(CONFIG_KEY,"SurroundDelay"),"50").toInt());
}

void DlgPrefModplug::saveSettings()
{
m_pConfig->set(ConfigKey(CONFIG_KEY,"PerTrackMemoryLimitMB"),
ConfigValue(m_pUi->memoryLimit->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"OversamplingEnabled"),
ConfigValue(m_pUi->oversampling->isChecked()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"NoiseReductionEnabled"),
ConfigValue(m_pUi->noiseReduction->isChecked()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"StereoSeparation"),
ConfigValue(m_pUi->stereoSeparation->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"MaxMixChannels"),
ConfigValue(m_pUi->maxMixChannels->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"ResamplingMode"),
ConfigValue(m_pUi->resampleMode->currentIndex()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"ReverbEnabled"),
ConfigValue(m_pUi->reverb->isChecked()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"ReverbLevel"),
ConfigValue(m_pUi->reverbDepth->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"ReverbDelay"),
ConfigValue(m_pUi->reverbDelay->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"MegabassEnabled"),
ConfigValue(m_pUi->megabass->isChecked()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"MegabassLevel"),
ConfigValue(m_pUi->bassDepth->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"MegabassCutoff"),
ConfigValue(m_pUi->bassCutoff->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"SurroundEnabled"),
ConfigValue(m_pUi->surround->isChecked()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"SurroundLevel"),
ConfigValue(m_pUi->surroundDepth->value()));
m_pConfig->set(ConfigKey(CONFIG_KEY,"SurroundDelay"),
ConfigValue(m_pUi->surroundDelay->value()));
}

void DlgPrefModplug::applySettings()
{
// read ui parameters and configure soundsource
unsigned int bufferSizeLimit = m_pUi->memoryLimit->value() << 20;
ModPlug::ModPlug_Settings settings;

// Note that ModPlug always decodes sound at 44.1kHz, 32 bit, stereo
// and then down-mixes to the settings you choose.
// Currently this is fixed to 16bit 44.1kHz stereo

// Number of channels - 1 for mono or 2 for stereo
settings.mChannels = 2;
// Bits per sample - 8, 16, or 32
settings.mBits = 16;
// Sampling rate - 11025, 22050, or 44100
settings.mFrequency = 44100;

// enabled features flags
settings.mFlags = 0;
if (m_pUi->oversampling->isChecked())
settings.mFlags |= ModPlug::MODPLUG_ENABLE_OVERSAMPLING;
if (m_pUi->noiseReduction->isChecked())
settings.mFlags |= ModPlug::MODPLUG_ENABLE_NOISE_REDUCTION;
if (m_pUi->reverb->isChecked())
settings.mFlags |= ModPlug::MODPLUG_ENABLE_REVERB;
if (m_pUi->megabass->isChecked())
settings.mFlags |= ModPlug::MODPLUG_ENABLE_MEGABASS;
if (m_pUi->surround->isChecked())
settings.mFlags |= ModPlug::MODPLUG_ENABLE_SURROUND;

switch (m_pUi->resampleMode->currentIndex()) {
case 0: // nearest neighbor
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_NEAREST;
break;
case 1: // linear
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_LINEAR;
break;
case 2: // cubic spline
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_SPLINE;
break;
case 3: // 8 tap FIR (also default)
default:
settings.mResamplingMode = ModPlug::MODPLUG_RESAMPLE_FIR;
break;
}

// stereo separation 1(joint)-256(fully separated channels)
settings.mStereoSeparation = m_pUi->stereoSeparation->value();
// maximum number of mix channels (16-256)
settings.mMaxMixChannels = m_pUi->maxMixChannels->value();
// Reverb level 0(quiet)-100(loud)
settings.mReverbDepth = m_pUi->reverbDepth->value();
// Reverb delay in ms, usually 40-200ms
settings.mReverbDelay = m_pUi->reverbDelay->value();
// XBass level 0(quiet)-100(loud)
settings.mBassAmount = m_pUi->bassDepth->value();
// XBass cutoff in Hz 10-100
settings.mBassRange = m_pUi->bassCutoff->value();
// Surround level 0(quiet)-100(heavy)
settings.mSurroundDepth = m_pUi->surroundDepth->value();
// Surround front-rear delay in ms, usually 5-40ms
settings.mSurroundDelay = m_pUi->surroundDelay->value();
// Number of times to loop. Zero prevents looping. -1 loops forever.
settings.mLoopCount = 0;

// apply modplug settings
SoundSourceModPlug::configure(bufferSizeLimit, settings);
}
36 changes: 36 additions & 0 deletions mixxx/src/dlgprefmodplug.h
@@ -0,0 +1,36 @@
// dlgprefmodplug.h - modplug settings dialog
// created 2013 by Stefan Nuernberger <kabelfrickler@gmail.com>

#ifndef DLGPREFMODPLUG_H
#define DLGPREFMODPLUG_H

#include <QDialog>
#include "configobject.h"

namespace Ui {
class DlgPrefModplug;
}

class DlgPrefModplug : public QDialog
{
Q_OBJECT

public:
explicit DlgPrefModplug(QWidget *parent, ConfigObject<ConfigValue> *_config);
~DlgPrefModplug();

public slots:
/** Apply changes to widget */
void slotApply();
void slotUpdate();

void loadSettings();
void saveSettings();
void applySettings();

private:
Ui::DlgPrefModplug *m_pUi;
ConfigObject<ConfigValue> *m_pConfig;
};

#endif // DLGPREFMODPLUG_H

0 comments on commit ec6bb3e

Please sign in to comment.