diff options
| author | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-08-24 20:29:41 +0000 |
|---|---|---|
| committer | trialuser02 <trialuser02@90c681e8-e032-0410-971d-27865f9a5e38> | 2010-08-24 20:29:41 +0000 |
| commit | 69719bc16622f5870f73eb3986be09a1af41f936 (patch) | |
| tree | 46d8db13de6610cebd46796b46fe21689eb88e74 | |
| parent | bb154a0c8f4ae405b07ccc7a610c4b1c239026d4 (diff) | |
| download | qmmp-69719bc16622f5870f73eb3986be09a1af41f936.tar.gz qmmp-69719bc16622f5870f73eb3986be09a1af41f936.tar.bz2 qmmp-69719bc16622f5870f73eb3986be09a1af41f936.zip | |
equalizer: added 96 kHz samplerate support, added effects priority
git-svn-id: http://svn.code.sf.net/p/qmmp-dev/code/trunk/qmmp@1850 90c681e8-e032-0410-971d-27865f9a5e38
25 files changed, 113 insertions, 90 deletions
diff --git a/src/plugins/Effect/srconverter/effectsrconverterfactory.cpp b/src/plugins/Effect/srconverter/effectsrconverterfactory.cpp index 92c3f8832..0b96922a5 100644 --- a/src/plugins/Effect/srconverter/effectsrconverterfactory.cpp +++ b/src/plugins/Effect/srconverter/effectsrconverterfactory.cpp @@ -31,6 +31,7 @@ const EffectProperties EffectSRConverterFactory::properties() const properties.shortName = "SRC"; properties.hasSettings = true; properties.hasAbout = true; + properties.priority = EffectProperties::EFFECT_PRIORITY_HIGH; return properties; } diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_cs.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_cs.ts index ce157440d..e12b7ce62 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_cs.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_cs.ts @@ -9,17 +9,17 @@ <translation>Modul SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>O modulu SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Modul Qmmp pro konverzi vzorkovací frekvence</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autor: Ilja Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_de.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_de.ts index 802c0c9fe..4970f6dc6 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_de.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_de.ts @@ -9,17 +9,17 @@ <translation>SRC-Modul</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Über „Sample Rate Converter“-Modul</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Qmmp „Sample Rate Converter“-Modul</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autor: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_es.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_es.ts index 0cfcb37e9..49e2f712a 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_es.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_es.ts @@ -9,17 +9,17 @@ <translation>Módulo SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Acerca del módulo de conversión de frecuencia</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Módulo de conversión de frecuencia para Qmmp</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Escrito por: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_it.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_it.ts index 18dce5300..78f9ff1c5 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_it.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_it.ts @@ -9,17 +9,17 @@ <translation>Modulo SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Info sul modulo di conversione campionamento</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Modulo di conversione campionamento Qmmp</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autore: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_ja.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_ja.ts index 50faa910f..c8000ad17 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_ja.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_ja.ts @@ -9,17 +9,17 @@ <translation>SRC プラグイン</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>サンプルレートコンバータプラグインについて</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>QMMP サンプルレートコンバータプラグイン</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>制作: Илья Котов (Ilya Kotov) <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_lt.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_lt.ts index 18f3c52f7..b67c0c9b3 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_lt.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_lt.ts @@ -9,17 +9,17 @@ <translation>SRC įskiepis</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Apie SRC įskiepį</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Qmmp SRC įskiepis</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Sukurta: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_nl.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_nl.ts index 9bd43f7cb..1e2d343a9 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_nl.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_nl.ts @@ -9,17 +9,17 @@ <translation>SRC Module</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Over de Sample Rate Converter Module</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Sample Rate Converter Plugin voor Qmmp</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autor: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_pl.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_pl.ts index 8e90b6110..29d55aaab 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_pl.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_pl.ts @@ -9,17 +9,17 @@ <translation>Wtyczka SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>O wtyczce Sample Rate Converter</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Wtyczka Sample Rate Converter dla Qmmp</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Autor: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_ru.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_ru.ts index aee92874e..37f203968 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_ru.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_ru.ts @@ -9,17 +9,17 @@ <translation>Модуль SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>О модуле передискретизации</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Модуль передискретизации для Qmmp</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Разработчик: Илья Котов <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_tr.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_tr.ts index e8301a82e..f301b8330 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_tr.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_tr.ts @@ -9,17 +9,17 @@ <translation>SRC Eklentisi</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Örnekleme Oranı Dönüştürücü Eklentisi Hakkında</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Qmmp Örnekleme Oranı Dönüştürücü Eklentisi</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Yazan: Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_uk_UA.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_uk_UA.ts index f6fc0a187..7202a6c37 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_uk_UA.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_uk_UA.ts @@ -9,17 +9,17 @@ <translation>Модуль SRC</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>Про модуль Sample Rate Converter</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Модуль Sample Rate Converter для Qmmp</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>Розробник: Ілля Котов <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_CN.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_CN.ts index 3dcd1cd54..b64815ae3 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_CN.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_CN.ts @@ -9,17 +9,17 @@ <translation>SRC 插件</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>关于取样率转换插件</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Qmmp 取样率转换插件</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>作者:Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_TW.ts b/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_TW.ts index 7e46d50ad..79cdb82a7 100644 --- a/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_TW.ts +++ b/src/plugins/Effect/srconverter/translations/srconverter_plugin_zh_TW.ts @@ -9,17 +9,17 @@ <translation>SRC 插件</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="50"/> + <location filename="../effectsrconverterfactory.cpp" line="51"/> <source>About Sample Rate Converter Plugin</source> <translation>關於取樣率轉換插件</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="51"/> + <location filename="../effectsrconverterfactory.cpp" line="52"/> <source>Qmmp Sample Rate Converter Plugin</source> <translation>Qmmp 取樣率轉換插件</translation> </message> <message> - <location filename="../effectsrconverterfactory.cpp" line="52"/> + <location filename="../effectsrconverterfactory.cpp" line="53"/> <source>Writen by: Ilya Kotov <forkotov02@hotmail.ru></source> <translation>作者:Ilya Kotov <forkotov02@hotmail.ru></translation> </message> diff --git a/src/plugins/Output/alsa/outputalsa.cpp b/src/plugins/Output/alsa/outputalsa.cpp index 39d2edf03..faec7f714 100644 --- a/src/plugins/Output/alsa/outputalsa.cpp +++ b/src/plugins/Output/alsa/outputalsa.cpp @@ -209,7 +209,7 @@ bool OutputALSA::initialize() qint64 OutputALSA::latency() { - return m_prebuf_fill * 1000 / sampleRate() / numChannels() / sampleSize(); + return m_prebuf_fill * 1000 / sampleRate() / channels() / sampleSize(); } void OutputALSA::drain() diff --git a/src/qmmp/effect.cpp b/src/qmmp/effect.cpp index d4c030c57..6bdc9eb3a 100644 --- a/src/qmmp/effect.cpp +++ b/src/qmmp/effect.cpp @@ -106,6 +106,11 @@ void Effect::checkFactories() } } +bool effectCompareFunc(Effect *e1, Effect *e2) +{ + return e1->factory()->properties().priority > e2->factory()->properties().priority; +} + QList<Effect*> Effect::create() { checkFactories(); @@ -119,6 +124,7 @@ QList<Effect*> Effect::create() effects.last()->m_factory = factory; } } + qSort(effects.begin(), effects.end(), effectCompareFunc); return effects; } diff --git a/src/qmmp/effectfactory.h b/src/qmmp/effectfactory.h index 3ab46d4cd..1471d9af8 100644 --- a/src/qmmp/effectfactory.h +++ b/src/qmmp/effectfactory.h @@ -1,5 +1,5 @@ /*************************************************************************** - * Copyright (C) 2007-2009 by Ilya Kotov * + * Copyright (C) 2007-2010 by Ilya Kotov * * forkotov02@hotmail.ru * * * * This program is free software; you can redistribute it and/or modify * @@ -34,17 +34,28 @@ class EffectProperties { public: /*! + * This enum describes effect preferd position. + */ + enum Priority + { + EFFECT_PRIORITY_LOW = 0, /*!< Low priority */ + EFFECT_PRIORITY_DEFAULT, /*!< Default priority */ + EFFECT_PRIORITY_HIGH /*!< High priority */ + }; + /*! * Constructor */ EffectProperties() { hasAbout = false; hasSettings = false; + priority = EFFECT_PRIORITY_DEFAULT; } QString name; /*!< Effect plugin full name */ QString shortName; /*!< Effect plugin short name for internal usage */ bool hasAbout; /*!< Should be \b true if plugin has about dialog, otherwise returns \b false */ bool hasSettings; /*!< Should be \b true if plugin has settings dialog, otherwise returns \b false */ + int priority; /*!< Effect priority. Effecs with higher priority are applied first */ }; /*! @brief Effect plugin interface (effect factory). * @author Ilya Kotov <forkotov02@hotmail.ru> diff --git a/src/qmmp/equ/iir.c b/src/qmmp/equ/iir.c index 9d826b86c..2384fef63 100644 --- a/src/qmmp/equ/iir.c +++ b/src/qmmp/equ/iir.c @@ -42,7 +42,7 @@ unsigned int blength = 0; /* * Global vars */ -int rate; +unsigned int rate; int band_count; void set_preamp(int chn, float val) @@ -51,7 +51,7 @@ void set_preamp(int chn, float val) } /* Init the filters */ -void init_iir() +void init_iir(unsigned int srate) { calc_coeffs(); #if 0 @@ -60,7 +60,7 @@ void init_iir() band_count = 10; - rate = 44100; + rate = srate; iir_cf = get_coeffs(&band_count, rate); clean_history(); diff --git a/src/qmmp/equ/iir.h b/src/qmmp/equ/iir.h index 9d8300f38..750ec5bd0 100644 --- a/src/qmmp/equ/iir.h +++ b/src/qmmp/equ/iir.h @@ -51,7 +51,7 @@ /* * Function prototypes */ -void init_iir(); +void init_iir(unsigned int srate); void clean_history(); void set_gain(int index, int chn, float val); void set_preamp(int chn, float val); @@ -71,7 +71,7 @@ __inline__ int round_ppc(float x); extern float preamp[EQ_CHANNELS]; extern sIIRCoefficients *iir_cf; -extern int rate; +extern unsigned int rate; extern int band_count; #ifdef BENCHMARK diff --git a/src/qmmp/equ/iir_cfs.c b/src/qmmp/equ/iir_cfs.c index f8e6f88a6..298f6bdbf 100644 --- a/src/qmmp/equ/iir_cfs.c +++ b/src/qmmp/equ/iir_cfs.c @@ -34,6 +34,7 @@ static sIIRCoefficients iir_cforiginal10_44100[10] __attribute__((aligned)); static sIIRCoefficients iir_cforiginal10_48000[10] __attribute__((aligned)); static sIIRCoefficients iir_cf10_44100[10] __attribute__((aligned)); static sIIRCoefficients iir_cf10_48000[10] __attribute__((aligned)); +static sIIRCoefficients iir_cf10_96000[10] __attribute__((aligned)); static sIIRCoefficients iir_cf15_44100[15] __attribute__((aligned)); static sIIRCoefficients iir_cf15_48000[15] __attribute__((aligned)); static sIIRCoefficients iir_cf25_44100[25] __attribute__((aligned)); @@ -107,6 +108,7 @@ struct { { iir_cforiginal10_48000, band_original_f010, 1.0, 10, 48000.0 }, { iir_cf10_44100, band_f010, 1.0, 10, 44100.0 }, { iir_cf10_48000, band_f010, 1.0, 10, 48000.0 }, + { iir_cf10_96000, band_f010, 1.0, 10, 96000.0 }, { iir_cf15_44100, band_f015, 2.0/3.0, 15, 44100.0 }, { iir_cf15_48000, band_f015, 2.0/3.0, 15, 48000.0 }, { iir_cf25_44100, band_f025, 1.0/3.0, 25, 44100.0 }, @@ -121,7 +123,7 @@ struct { *************/ /* Get the coeffs for a given number of bands and sampling frequency */ -sIIRCoefficients* get_coeffs(int *bands, int sfreq) +sIIRCoefficients* get_coeffs(int *bands, unsigned int sfreq) { sIIRCoefficients *iir_cf = 0; switch(sfreq) @@ -146,6 +148,9 @@ sIIRCoefficients* get_coeffs(int *bands, int sfreq) break; } break; + case 96000: + iir_cf = iir_cf10_96000; + default: switch(*bands) { diff --git a/src/qmmp/equ/iir_cfs.h b/src/qmmp/equ/iir_cfs.h index c4cc4a0fd..33fe66a20 100644 --- a/src/qmmp/equ/iir_cfs.h +++ b/src/qmmp/equ/iir_cfs.h @@ -33,7 +33,7 @@ typedef struct float dummy; // Word alignment }sIIRCoefficients; -sIIRCoefficients* get_coeffs(int *bands, int sfreq); //, bool use_xmms_original_freqs); +sIIRCoefficients* get_coeffs(int *bands, unsigned int sfreq); //, bool use_xmms_original_freqs); void calc_coeffs(); #endif diff --git a/src/qmmp/output.cpp b/src/qmmp/output.cpp index 15ce18593..c859a928a 100644 --- a/src/qmmp/output.cpp +++ b/src/qmmp/output.cpp @@ -135,12 +135,17 @@ void Output::setStateHandler(StateHandler *handler) m_handler = handler; } +AudioParameters Output::audioParameters() const +{ + return AudioParameters(m_frequency, m_channels, m_format); +} + quint32 Output::sampleRate() { return m_frequency; } -int Output::numChannels() +int Output::channels() { return m_channels; } diff --git a/src/qmmp/output.h b/src/qmmp/output.h index f00d2d79d..c12aed0e4 100644 --- a/src/qmmp/output.h +++ b/src/qmmp/output.h @@ -19,7 +19,7 @@ class Output; #include "outputfactory.h" #include "visualfactory.h" #include "statehandler.h" - +#include "audioparameters.h" #include "recycler.h" class QTimer; @@ -93,13 +93,17 @@ public: */ void setStateHandler(StateHandler *handler); /*! + * Returns selected audio parameters. + */ + AudioParameters audioParameters() const; + /*! * Returns samplerate. */ quint32 sampleRate(); /*! * Returns channels number. */ - int numChannels(); + int channels(); /*! * Returns selected audio format. */ @@ -183,7 +187,6 @@ private: unsigned char *m_visBuffer; qint64 m_visBufferSize; - static void checkFactories(); static void registerFactory(OutputFactory *); //TODO use QMap instead diff --git a/src/qmmp/qmmpaudioengine.cpp b/src/qmmp/qmmpaudioengine.cpp index dc5c4462c..3d92b8f76 100644 --- a/src/qmmp/qmmpaudioengine.cpp +++ b/src/qmmp/qmmpaudioengine.cpp @@ -39,7 +39,7 @@ extern "C" } QmmpAudioEngine::QmmpAudioEngine(QObject *parent) - : AbstractEngine(parent), m_factory(0), m_output(0), m_eqInited(false), + : AbstractEngine(parent), m_factory(0), m_output(0), m_useEq(false), m_eqEnabled(false) { m_output_buf = new unsigned char[QMMP_BUFFER_SIZE]; @@ -90,7 +90,8 @@ bool QmmpAudioEngine::play() return false; if(m_output) delete m_output; - if(!(m_output = createOutput(m_decoders.head()))) + prepareEffects(m_decoders.head()); + if(!(m_output = createOutput())) return false; start(); return true; @@ -291,18 +292,7 @@ qint64 QmmpAudioEngine::produceSound(char *data, qint64 size, quint32 brate, int { uint sz = size < m_bks ? size : m_bks; m_replayGain->applyReplayGain(data, sz); - if (m_useEq && m_decoder->audioParameters().format() == Qmmp::PCM_S16LE) - { - if (!m_eqInited) - { - init_iir(); - m_eqInited = true; - } - iir((void*) data, sz, chan); - } - Buffer *b = m_output->recycler()->get(); - memcpy(b->data, data, sz); b->nbytes = sz; b->rate = brate; @@ -311,6 +301,9 @@ qint64 QmmpAudioEngine::produceSound(char *data, qint64 size, quint32 brate, int effect->applyEffect(b); } m_output->recycler()->add(); + + if (m_useEq) + iir((void*) b->data, b->nbytes, chan); size -= sz; memmove(data, data + sz, size); return sz; @@ -341,7 +334,7 @@ void QmmpAudioEngine::updateEqSettings() set_gain(i,1, 0.03*value+0.000999999*value*value); } if(m_decoder) - m_useEq = m_eqEnabled && m_decoder->audioParameters().format() == Qmmp::PCM_S16LE; + m_useEq = m_eqEnabled && m_ap.format() == Qmmp::PCM_S16LE; mutex()->unlock(); } @@ -423,7 +416,8 @@ void QmmpAudioEngine::run() //m_seekTime = m_inputs.value(m_decoder)->offset(); m_replayGain->setReplayGainInfo(m_decoder->replayGainInfo()); //use current output if possible - if(m_decoder->audioParameters() == m_ap) + prepareEffects(m_decoder); + if(m_ap == m_output->audioParameters()) { emit playbackFinished(); StateHandler::instance()->dispatch(Qmmp::Stopped); //fake stop/start cycle @@ -448,7 +442,7 @@ void QmmpAudioEngine::run() m_output->wait(); delete m_output; - m_output = createOutput(m_decoder); + m_output = createOutput(); if(m_output) { m_output->start(); @@ -560,13 +554,8 @@ void QmmpAudioEngine::sendMetaData() } } -Output *QmmpAudioEngine::createOutput(Decoder *d) +Output *QmmpAudioEngine::createOutput() { - m_blockedEffects.clear(); - while(!m_effects.isEmpty()) //delete effects - delete m_effects.takeFirst(); - - m_ap = d->audioParameters(); Output *output = Output::create(0); if(!output) { @@ -582,31 +571,34 @@ Output *QmmpAudioEngine::createOutput(Decoder *d) StateHandler::instance()->dispatch(Qmmp::FatalError); return false; } + output->configure(m_ap.sampleRate(), m_ap.channels(), m_ap.format()); + return output; +} + +void QmmpAudioEngine::prepareEffects(Decoder *d) +{ + m_blockedEffects.clear(); + while(!m_effects.isEmpty()) //delete effects + delete m_effects.takeFirst(); + m_effects = Effect::create(); - AudioParameters ap = m_ap; - m_replayGain->setSampleSize(m_ap.sampleSize()); - if(!m_eqInited) - { - init_iir(); - m_eqInited = true; - } - m_useEq = m_eqEnabled && ap.format() == Qmmp::PCM_S16LE; + m_ap = d->audioParameters(); if(m_settings->use16BitOutput()) m_effects.prepend (new AudioConverter()); foreach(Effect *effect, m_effects) { - effect->configure(ap.sampleRate(), ap.channels(), ap.format()); - if (ap != effect->audioParameters()) + effect->configure(m_ap.sampleRate(), m_ap.channels(), m_ap.format()); + if (m_ap != effect->audioParameters()) { m_blockedEffects << effect; //list of effects which require restart - ap = effect->audioParameters(); + m_ap = effect->audioParameters(); } } - m_chan = ap.channels(); - output->configure(ap.sampleRate(), ap.channels(), ap.format()); - return output; + m_chan = m_ap.channels(); + m_useEq = m_eqEnabled && m_ap.format() == Qmmp::PCM_S16LE; + init_iir(m_ap.sampleRate()); } //static members diff --git a/src/qmmp/qmmpaudioengine.h b/src/qmmp/qmmpaudioengine.h index 097e34697..bf924e5fa 100644 --- a/src/qmmp/qmmpaudioengine.h +++ b/src/qmmp/qmmpaudioengine.h @@ -70,14 +70,14 @@ private: void addOffset(); qint64 produceSound(char *data, qint64 size, quint32 brate, int chan); void sendMetaData(); - Output *createOutput(Decoder *d); + Output *createOutput(); + void prepareEffects(Decoder *d); DecoderFactory *m_factory; QList <Effect*> m_effects; QList <Effect*> m_blockedEffects; Output *m_output; - bool m_eqInited; bool m_useEq; bool m_eqEnabled; bool m_done, m_finish, m_user_stop; |
