mirror of
https://github.com/clangen/musikcube.git
synced 2025-01-30 06:32:36 +00:00
Added a stubbed Shibatch SuperEQ DSP plugin. Sources were taken/stolen from the DeaDBeeF project, which is more or less a straight port of the original, with added support for floating point samples.
This commit is contained in:
parent
d5924f936f
commit
b190afd805
@ -97,6 +97,7 @@ add_subdirectory(src/plugins/nullout)
|
||||
add_subdirectory(src/plugins/server)
|
||||
add_subdirectory(src/plugins/httpdatastream)
|
||||
add_subdirectory(src/plugins/stockencoders)
|
||||
add_subdirectory(src/plugins/supereqdsp)
|
||||
|
||||
if (${FFMPEG_DECODER} MATCHES "true")
|
||||
add_subdirectory(src/plugins/ffmpegdecoder)
|
||||
@ -217,13 +218,13 @@ if (GENERATE_DEB MATCHES "1")
|
||||
endif()
|
||||
|
||||
set(DEPENDENCIES "libboost-thread${DEB_BOOST_VERSION}, libboost-system${DEB_BOOST_VERSION}, libboost-filesystem${DEB_BOOST_VERSION}, libmicrohttpd${DEB_MICROHTTPD_VERSION}, libcurl${DEB_LIBCURL_VERSION}, libogg0, libvorbis0a, libvorbisfile3, libncursesw5, libasound2, libpulse0, pulseaudio, libmp3lame0, libev4,")
|
||||
|
||||
|
||||
if (${FFMPEG_DECODER} MATCHES "true")
|
||||
set(DEPENDENCIES "${DEPENDENCIES} libavcodec-extra, libavutil55, libavformat57, libswresample2")
|
||||
else()
|
||||
set(DEPENDENCIES "${DEPENDENCIES} libflac8, libfaad2")
|
||||
endif()
|
||||
|
||||
|
||||
set(CPACK_GENERATOR "DEB")
|
||||
set(CPACK_PACKAGE_DESCRIPTION "musikcube, a terminal-based music player and library")
|
||||
set(CPACK_PACKAGE_VERSION_MAJOR "${musikcube_VERSION_MAJOR}")
|
||||
|
@ -61,7 +61,7 @@ Stream::Stream(int samplesPerChannel, double bufferLengthSeconds, unsigned int o
|
||||
, capabilities(0)
|
||||
, rawBuffer(nullptr) {
|
||||
if ((this->options & NoDSP) == 0) {
|
||||
streams::GetDspPlugins();
|
||||
dsps = streams::GetDspPlugins();
|
||||
}
|
||||
|
||||
this->decoderBuffer = new Buffer();
|
||||
|
@ -41,7 +41,7 @@ namespace musik { namespace core { namespace sdk {
|
||||
class IDSP {
|
||||
public:
|
||||
virtual void Release() = 0;
|
||||
virtual bool Process(IBuffer *buffer) = 0;
|
||||
virtual bool Process(IBuffer* buffer) = 0;
|
||||
};
|
||||
|
||||
} } }
|
||||
|
9
src/plugins/supereqdsp/CMakeLists.txt
Normal file
9
src/plugins/supereqdsp/CMakeLists.txt
Normal file
@ -0,0 +1,9 @@
|
||||
set (nullout_SOURCES
|
||||
supereq/Equ.cpp
|
||||
supereq/Fftsg_fl.c
|
||||
supereqdsp_plugin.cpp
|
||||
SuperEqDsp.cpp
|
||||
)
|
||||
|
||||
add_library(supereqdsp SHARED ${nullout_SOURCES})
|
||||
target_link_libraries(supereqdsp ${musikcube_LINK_LIBS})
|
86
src/plugins/supereqdsp/SuperEqDsp.cpp
Normal file
86
src/plugins/supereqdsp/SuperEqDsp.cpp
Normal file
@ -0,0 +1,86 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007-2017 musikcube team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include "SuperEqDsp.h"
|
||||
|
||||
#include <core/sdk/constants.h>
|
||||
#include <core/sdk/IPreferences.h>
|
||||
#include <core/sdk/ISchema.h>
|
||||
|
||||
using namespace musik::core::sdk;
|
||||
|
||||
SuperEqDsp::SuperEqDsp() {
|
||||
|
||||
}
|
||||
|
||||
SuperEqDsp::~SuperEqDsp() {
|
||||
if (this->supereq) {
|
||||
equ_quit(this->supereq);
|
||||
delete this->supereq;
|
||||
}
|
||||
}
|
||||
|
||||
void SuperEqDsp::Release() {
|
||||
delete this;
|
||||
}
|
||||
|
||||
bool SuperEqDsp::Process(IBuffer* buffer) {
|
||||
int channels = buffer->Channels();
|
||||
|
||||
if (!this->supereq) {
|
||||
this->supereq = new SuperEqState();
|
||||
equ_init(this->supereq, 10, channels);
|
||||
|
||||
void *params = paramlist_alloc();
|
||||
float bands[18];
|
||||
|
||||
for (int i = 0; i < 18; i++) {
|
||||
bands[i] = 1.0f; //i > 9 ? -0.0f : 1.0f;
|
||||
}
|
||||
|
||||
equ_makeTable(
|
||||
this->supereq,
|
||||
bands,
|
||||
params,
|
||||
buffer->SampleRate());
|
||||
|
||||
paramlist_free(params);
|
||||
}
|
||||
|
||||
return equ_modifySamples_float(
|
||||
this->supereq,
|
||||
(char*) buffer->BufferPointer(),
|
||||
buffer->Samples() / channels,
|
||||
channels) != 0;
|
||||
}
|
51
src/plugins/supereqdsp/SuperEqDsp.h
Normal file
51
src/plugins/supereqdsp/SuperEqDsp.h
Normal file
@ -0,0 +1,51 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007-2017 musikcube team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
#pragma once
|
||||
|
||||
#include <core/sdk/IDSP.h>
|
||||
#include "supereq/Equ.h"
|
||||
|
||||
using namespace musik::core::sdk;
|
||||
|
||||
class SuperEqDsp : public IDSP {
|
||||
public:
|
||||
SuperEqDsp();
|
||||
~SuperEqDsp();
|
||||
|
||||
virtual void Release() override;
|
||||
virtual bool Process(IBuffer *buffer) override;
|
||||
|
||||
private:
|
||||
SuperEqState* supereq {nullptr};
|
||||
};
|
33
src/plugins/supereqdsp/supereq/COPYING
Normal file
33
src/plugins/supereqdsp/supereq/COPYING
Normal file
@ -0,0 +1,33 @@
|
||||
SuperEQ DSP plugin for DeaDBeeF Player
|
||||
Copyright (C) 2009-2014 Alexey Yakovenko <waker@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
|
||||
|
||||
The original SuperEQ code:
|
||||
|
||||
Shibatch Super Equalizer ver 0.03 for winamp
|
||||
written by Naoki Shibata shibatch@users.sourceforge.net
|
||||
This program(except FFT part) is distributed under LGPL. See LGPL.txt for
|
||||
details.
|
||||
|
||||
|
||||
Ooura FFT implementation
|
||||
|
||||
Copyright Takuya OOURA, 1996-2001
|
||||
http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html
|
||||
|
||||
You may use, copy, modify and distribute this code for any purpose (include commercial use) and without fee.
|
||||
Please refer to this package when you modify this code.
|
446
src/plugins/supereqdsp/supereq/Equ.cpp
Normal file
446
src/plugins/supereqdsp/supereq/Equ.cpp
Normal file
@ -0,0 +1,446 @@
|
||||
/*
|
||||
SuperEQ DSP plugin for DeaDBeeF Player
|
||||
Copyright (C) 2009-2014 Alexey Yakovenko <waker@users.sourceforge.net>
|
||||
Original SuperEQ code (C) Naoki Shibata <shibatch@users.sf.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <math.h>
|
||||
#include <assert.h>
|
||||
#include "paramlist.hpp"
|
||||
#include "Equ.h"
|
||||
|
||||
extern "C" void rdft(int, int, REAL *, int *, REAL *);
|
||||
void rfft(int n,int isign,REAL *x)
|
||||
{
|
||||
static int ipsize = 0,wsize=0;
|
||||
static int *ip = NULL;
|
||||
static REAL *w = NULL;
|
||||
int newipsize,newwsize;
|
||||
if (n == 0) {
|
||||
free(ip); ip = NULL; ipsize = 0;
|
||||
free(w); w = NULL; wsize = 0;
|
||||
return;
|
||||
}
|
||||
|
||||
n = 1 << n;
|
||||
|
||||
|
||||
newipsize = 2+sqrt(n/2);
|
||||
if (newipsize > ipsize) {
|
||||
ipsize = newipsize;
|
||||
ip = (int *)realloc(ip,sizeof(int)*ipsize);
|
||||
ip[0] = 0;
|
||||
}
|
||||
|
||||
newwsize = n/2;
|
||||
if (newwsize > wsize) {
|
||||
wsize = newwsize;
|
||||
w = (REAL *)realloc(w,sizeof(REAL)*wsize);
|
||||
}
|
||||
|
||||
rdft(n,isign,x,ip,w);
|
||||
}
|
||||
|
||||
#define PI 3.1415926535897932384626433832795
|
||||
|
||||
#define DITHERLEN 65536
|
||||
|
||||
#define M 15
|
||||
static REAL fact[M+1];
|
||||
static REAL aa = 96;
|
||||
static REAL iza = 0;
|
||||
|
||||
#define NBANDS 17
|
||||
static REAL bands[NBANDS] = {
|
||||
65.406392,92.498606,130.81278,184.99721,261.62557,369.99442,523.25113,
|
||||
739.9884 ,1046.5023,1479.9768,2093.0045,2959.9536,4186.0091,5919.9072,
|
||||
8372.0181,11839.814,16744.036
|
||||
};
|
||||
|
||||
static REAL alpha(REAL a)
|
||||
{
|
||||
if (a <= 21) return 0;
|
||||
if (a <= 50) return 0.5842*pow(a-21,0.4)+0.07886*(a-21);
|
||||
return 0.1102*(a-8.7);
|
||||
}
|
||||
|
||||
static REAL izero(REAL x)
|
||||
{
|
||||
REAL ret = 1;
|
||||
int m;
|
||||
|
||||
for(m=1;m<=M;m++)
|
||||
{
|
||||
REAL t;
|
||||
t = pow(x/2,m)/fact[m];
|
||||
ret += t*t;
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void *equ_malloc (int size) {
|
||||
return malloc (size);
|
||||
}
|
||||
|
||||
void equ_free (void *mem) {
|
||||
free (mem);
|
||||
}
|
||||
|
||||
extern "C" void equ_init(SuperEqState *state, int wb, int channels)
|
||||
{
|
||||
int i,j;
|
||||
|
||||
if (state->lires1 != NULL) free(state->lires1);
|
||||
if (state->lires2 != NULL) free(state->lires2);
|
||||
if (state->irest != NULL) free(state->irest);
|
||||
if (state->fsamples != NULL) free(state->fsamples);
|
||||
if (state->finbuf != NULL) free(state->finbuf);
|
||||
if (state->outbuf != NULL) free(state->outbuf);
|
||||
if (state->ditherbuf != NULL) free(state->ditherbuf);
|
||||
|
||||
|
||||
memset (state, 0, sizeof (SuperEqState));
|
||||
state->channels = channels;
|
||||
state->enable = 1;
|
||||
|
||||
state->winlen = (1 << (wb-1))-1;
|
||||
state->winlenbit = wb;
|
||||
state->tabsize = 1 << wb;
|
||||
state->fft_bits = wb;
|
||||
|
||||
state->lires1 = (REAL *)equ_malloc(sizeof(REAL)*state->tabsize * state->channels);
|
||||
state->lires2 = (REAL *)equ_malloc(sizeof(REAL)*state->tabsize * state->channels);
|
||||
state->irest = (REAL *)equ_malloc(sizeof(REAL)*state->tabsize);
|
||||
state->fsamples = (REAL *)equ_malloc(sizeof(REAL)*state->tabsize);
|
||||
state->finbuf = (REAL *)equ_malloc(state->winlen*state->channels*sizeof(REAL));
|
||||
state->outbuf = (REAL *)equ_malloc(state->tabsize*state->channels*sizeof(REAL));
|
||||
state->ditherbuf = (REAL *)equ_malloc(sizeof(REAL)*DITHERLEN);
|
||||
|
||||
memset (state->lires1, 0, sizeof(REAL)*state->tabsize * state->channels);
|
||||
memset (state->lires2, 0, sizeof(REAL)*state->tabsize * state->channels);
|
||||
memset (state->irest, 0, sizeof(REAL)*state->tabsize);
|
||||
memset (state->fsamples, 0, sizeof(REAL)*state->tabsize);
|
||||
memset (state->finbuf, 0, state->winlen*state->channels*sizeof(REAL));
|
||||
memset (state->outbuf, 0, state->tabsize*state->channels*sizeof(REAL));
|
||||
memset (state->ditherbuf, 0, sizeof(REAL)*DITHERLEN);
|
||||
|
||||
state->lires = state->lires1;
|
||||
state->cur_ires = 1;
|
||||
state->chg_ires = 1;
|
||||
|
||||
for(i=0;i<DITHERLEN;i++)
|
||||
state->ditherbuf[i] = (float(rand())/RAND_MAX-0.5);
|
||||
|
||||
if (fact[0] < 1) {
|
||||
for(i=0;i<=M;i++)
|
||||
{
|
||||
fact[i] = 1;
|
||||
for(j=1;j<=i;j++) fact[i] *= j;
|
||||
}
|
||||
iza = izero(alpha(aa));
|
||||
}
|
||||
}
|
||||
|
||||
// -(N-1)/2 <= n <= (N-1)/2
|
||||
static REAL win(REAL n,int N)
|
||||
{
|
||||
return izero(alpha(aa)*sqrt(1-4*n*n/((N-1)*(N-1))))/iza;
|
||||
}
|
||||
|
||||
static REAL sinc(REAL x)
|
||||
{
|
||||
return x == 0 ? 1 : sin(x)/x;
|
||||
}
|
||||
|
||||
static REAL hn_lpf(int n,REAL f,REAL fs)
|
||||
{
|
||||
REAL t = 1/fs;
|
||||
REAL omega = 2*PI*f;
|
||||
return 2*f*t*sinc(n*omega*t);
|
||||
}
|
||||
|
||||
static REAL hn_imp(int n)
|
||||
{
|
||||
return n == 0 ? 1.0 : 0.0;
|
||||
}
|
||||
|
||||
static REAL hn(int n,paramlist ¶m2,REAL fs)
|
||||
{
|
||||
paramlistelm *e;
|
||||
REAL ret,lhn;
|
||||
|
||||
lhn = hn_lpf(n,param2.elm->upper,fs);
|
||||
ret = param2.elm->gain*lhn;
|
||||
|
||||
for(e=param2.elm->next;e->next != NULL && e->upper < fs/2;e = e->next)
|
||||
{
|
||||
REAL lhn2 = hn_lpf(n,e->upper,fs);
|
||||
ret += e->gain*(lhn2-lhn);
|
||||
lhn = lhn2;
|
||||
}
|
||||
|
||||
ret += e->gain*(hn_imp(n)-lhn);
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
void process_param(REAL *bc,paramlist *param,paramlist ¶m2,REAL fs,int ch)
|
||||
{
|
||||
paramlistelm **pp,*p,*e,*e2;
|
||||
int i;
|
||||
|
||||
delete param2.elm;
|
||||
param2.elm = NULL;
|
||||
|
||||
for(i=0,pp=¶m2.elm;i<=NBANDS;i++,pp = &(*pp)->next)
|
||||
{
|
||||
(*pp) = new paramlistelm;
|
||||
(*pp)->lower = i == 0 ? 0 : bands[i-1];
|
||||
(*pp)->upper = i == NBANDS ? fs : bands[i ];
|
||||
(*pp)->gain = bc[i];
|
||||
}
|
||||
|
||||
for(e = param->elm;e != NULL;e = e->next)
|
||||
{
|
||||
if (e->lower >= e->upper) continue;
|
||||
|
||||
for(p=param2.elm;p != NULL;p = p->next)
|
||||
if (p->upper > e->lower) break;
|
||||
|
||||
while(p != NULL && p->lower < e->upper)
|
||||
{
|
||||
if (e->lower <= p->lower && p->upper <= e->upper) {
|
||||
p->gain *= pow(10,e->gain/20);
|
||||
p = p->next;
|
||||
continue;
|
||||
}
|
||||
if (p->lower < e->lower && e->upper < p->upper) {
|
||||
e2 = new paramlistelm;
|
||||
e2->lower = e->upper;
|
||||
e2->upper = p->upper;
|
||||
e2->gain = p->gain;
|
||||
e2->next = p->next;
|
||||
p->next = e2;
|
||||
|
||||
e2 = new paramlistelm;
|
||||
e2->lower = e->lower;
|
||||
e2->upper = e->upper;
|
||||
e2->gain = p->gain * pow(10,e->gain/20);
|
||||
e2->next = p->next;
|
||||
p->next = e2;
|
||||
|
||||
p->upper = e->lower;
|
||||
|
||||
p = p->next->next->next;
|
||||
continue;
|
||||
}
|
||||
if (p->lower < e->lower) {
|
||||
e2 = new paramlistelm;
|
||||
e2->lower = e->lower;
|
||||
e2->upper = p->upper;
|
||||
e2->gain = p->gain * pow(10,e->gain/20);
|
||||
e2->next = p->next;
|
||||
p->next = e2;
|
||||
|
||||
p->upper = e->lower;
|
||||
p = p->next->next;
|
||||
continue;
|
||||
}
|
||||
if (e->upper < p->upper) {
|
||||
e2 = new paramlistelm;
|
||||
e2->lower = e->upper;
|
||||
e2->upper = p->upper;
|
||||
e2->gain = p->gain;
|
||||
e2->next = p->next;
|
||||
p->next = e2;
|
||||
|
||||
p->upper = e->upper;
|
||||
p->gain = p->gain * pow(10,e->gain/20);
|
||||
p = p->next->next;
|
||||
continue;
|
||||
}
|
||||
abort();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
extern "C" void equ_makeTable(SuperEqState *state, REAL *lbc,void *_param,REAL fs)
|
||||
{
|
||||
paramlist *param = (paramlist *)_param;
|
||||
int i,cires = state->cur_ires;
|
||||
REAL *nires;
|
||||
|
||||
if (fs <= 0) return;
|
||||
|
||||
paramlist param2;
|
||||
|
||||
for (int ch = 0; ch < state->channels; ch++) {
|
||||
process_param(lbc,param,param2,fs,ch);
|
||||
|
||||
for(i=0;i<state->winlen;i++)
|
||||
state->irest[i] = hn(i-state->winlen/2,param2,fs)*win(i-state->winlen/2,state->winlen);
|
||||
|
||||
for(;i<state->tabsize;i++)
|
||||
state->irest[i] = 0;
|
||||
|
||||
rfft(state->fft_bits,1,state->irest);
|
||||
|
||||
nires = cires == 1 ? state->lires2 : state->lires1;
|
||||
nires += ch * state->tabsize;
|
||||
|
||||
for(i=0;i<state->tabsize;i++)
|
||||
nires[i] = state->irest[i];
|
||||
}
|
||||
state->chg_ires = cires == 1 ? 2 : 1;
|
||||
}
|
||||
|
||||
extern "C" void equ_quit(SuperEqState *state)
|
||||
{
|
||||
equ_free(state->lires1);
|
||||
equ_free(state->lires2);
|
||||
equ_free(state->irest);
|
||||
equ_free(state->fsamples);
|
||||
equ_free(state->finbuf);
|
||||
equ_free(state->outbuf);
|
||||
equ_free(state->ditherbuf);
|
||||
|
||||
state->lires1 = NULL;
|
||||
state->lires2 = NULL;
|
||||
state->irest = NULL;
|
||||
state->fsamples = NULL;
|
||||
state->finbuf = NULL;
|
||||
state->outbuf = NULL;
|
||||
|
||||
rfft(0,0,NULL);
|
||||
}
|
||||
|
||||
extern "C" void equ_clearbuf(SuperEqState *state)
|
||||
{
|
||||
int i;
|
||||
|
||||
state->nbufsamples = 0;
|
||||
for(i=0;i<state->tabsize*state->channels;i++) state->outbuf[i] = 0;
|
||||
}
|
||||
|
||||
extern "C" int equ_modifySamples_float (SuperEqState *state, char *buf,int nsamples,int nch)
|
||||
{
|
||||
int i,p,ch;
|
||||
REAL *ires;
|
||||
float amax = 1.0f;
|
||||
float amin = -1.0f;
|
||||
static float hm1 = 0, hm2 = 0;
|
||||
|
||||
if (state->chg_ires) {
|
||||
state->cur_ires = state->chg_ires;
|
||||
state->lires = state->cur_ires == 1 ? state->lires1 : state->lires2;
|
||||
state->chg_ires = 0;
|
||||
}
|
||||
|
||||
p = 0;
|
||||
|
||||
while(state->nbufsamples+nsamples >= state->winlen)
|
||||
{
|
||||
for(i=0;i<(state->winlen-state->nbufsamples)*nch;i++)
|
||||
{
|
||||
state->finbuf[state->nbufsamples*nch+i] = ((float *)buf)[i+p*nch];
|
||||
float s = state->outbuf[state->nbufsamples*nch+i];
|
||||
//if (dither) s += ditherbuf[(ditherptr++) & (DITHERLEN-1)];
|
||||
if (s < amin) s = amin;
|
||||
if (amax < s) s = amax;
|
||||
((float *)buf)[i+p*nch] = s;
|
||||
}
|
||||
for(i=state->winlen*nch;i<state->tabsize*nch;i++)
|
||||
state->outbuf[i-state->winlen*nch] = state->outbuf[i];
|
||||
|
||||
|
||||
p += state->winlen-state->nbufsamples;
|
||||
nsamples -= state->winlen-state->nbufsamples;
|
||||
state->nbufsamples = 0;
|
||||
|
||||
for(ch=0;ch<nch;ch++)
|
||||
{
|
||||
ires = state->lires + ch * state->tabsize;
|
||||
|
||||
for(i=0;i<state->winlen;i++)
|
||||
state->fsamples[i] = state->finbuf[nch*i+ch];
|
||||
|
||||
for(i=state->winlen;i<state->tabsize;i++)
|
||||
state->fsamples[i] = 0;
|
||||
|
||||
if (state->enable) {
|
||||
rfft(state->fft_bits,1,state->fsamples);
|
||||
|
||||
state->fsamples[0] = ires[0]*state->fsamples[0];
|
||||
state->fsamples[1] = ires[1]*state->fsamples[1];
|
||||
|
||||
for(i=1;i<state->tabsize/2;i++)
|
||||
{
|
||||
REAL re,im;
|
||||
|
||||
re = ires[i*2 ]*state->fsamples[i*2] - ires[i*2+1]*state->fsamples[i*2+1];
|
||||
im = ires[i*2+1]*state->fsamples[i*2] + ires[i*2 ]*state->fsamples[i*2+1];
|
||||
|
||||
state->fsamples[i*2 ] = re;
|
||||
state->fsamples[i*2+1] = im;
|
||||
}
|
||||
|
||||
rfft(state->fft_bits,-1,state->fsamples);
|
||||
} else {
|
||||
for(i=state->winlen-1+state->winlen/2;i>=state->winlen/2;i--) state->fsamples[i] = state->fsamples[i-state->winlen/2]*state->tabsize/2;
|
||||
for(;i>=0;i--) state->fsamples[i] = 0;
|
||||
}
|
||||
|
||||
for(i=0;i<state->winlen;i++) state->outbuf[i*nch+ch] += state->fsamples[i]/state->tabsize*2;
|
||||
|
||||
for(i=state->winlen;i<state->tabsize;i++) state->outbuf[i*nch+ch] = state->fsamples[i]/state->tabsize*2;
|
||||
}
|
||||
}
|
||||
|
||||
for(i=0;i<nsamples*nch;i++)
|
||||
{
|
||||
state->finbuf[state->nbufsamples*nch+i] = ((float *)buf)[i+p*nch];
|
||||
float s = state->outbuf[state->nbufsamples*nch+i];
|
||||
if (state->dither) {
|
||||
float u;
|
||||
s -= hm1;
|
||||
u = s;
|
||||
// s += ditherbuf[(ditherptr++) & (DITHERLEN-1)];
|
||||
if (s < amin) s = amin;
|
||||
if (amax < s) s = amax;
|
||||
hm1 = s - u;
|
||||
((float *)buf)[i+p*nch] = s;
|
||||
} else {
|
||||
if (s < amin) s = amin;
|
||||
if (amax < s) s = amax;
|
||||
((float *)buf)[i+p*nch] = s;
|
||||
}
|
||||
}
|
||||
|
||||
p += nsamples;
|
||||
state->nbufsamples += nsamples;
|
||||
|
||||
return p;
|
||||
}
|
||||
|
||||
extern "C" void *paramlist_alloc (void) {
|
||||
return (void *)(new paramlist);
|
||||
}
|
||||
extern "C" void paramlist_free (void *pl) {
|
||||
delete ((paramlist *)pl);
|
||||
}
|
56
src/plugins/supereqdsp/supereq/Equ.h
Normal file
56
src/plugins/supereqdsp/supereq/Equ.h
Normal file
@ -0,0 +1,56 @@
|
||||
/*
|
||||
DeaDBeeF - The Ultimate Music Player
|
||||
Copyright (C) 2009-2013 Alexey Yakovenko <waker@users.sourceforge.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#ifndef __EQU_H
|
||||
#define __EQU_H
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
typedef float REAL;
|
||||
typedef struct {
|
||||
REAL *lires,*lires1,*lires2;
|
||||
REAL *irest;
|
||||
REAL *fsamples;
|
||||
REAL *ditherbuf;
|
||||
int ditherptr;
|
||||
volatile int chg_ires,cur_ires;
|
||||
int winlen,winlenbit,tabsize,nbufsamples;
|
||||
REAL *finbuf;
|
||||
REAL *outbuf;
|
||||
int dither;
|
||||
int channels;
|
||||
int enable;
|
||||
int fft_bits;
|
||||
} SuperEqState;
|
||||
|
||||
void *paramlist_alloc (void);
|
||||
void paramlist_free (void *);
|
||||
void equ_makeTable(SuperEqState *state, float *lbc,void *param,float fs);
|
||||
int equ_modifySamples(SuperEqState *state, char *buf,int nsamples,int nch,int bps);
|
||||
int equ_modifySamples_float (SuperEqState *state, char *buf,int nsamples,int nch);
|
||||
void equ_clearbuf(SuperEqState *state);
|
||||
void equ_init(SuperEqState *state, int wb, int channels);
|
||||
void equ_quit(SuperEqState *state);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
2650
src/plugins/supereqdsp/supereq/Fftsg_fl.c
Normal file
2650
src/plugins/supereqdsp/supereq/Fftsg_fl.c
Normal file
File diff suppressed because it is too large
Load Diff
30
src/plugins/supereqdsp/supereq/dsp_superequ.txt
Normal file
30
src/plugins/supereqdsp/supereq/dsp_superequ.txt
Normal file
@ -0,0 +1,30 @@
|
||||
|
||||
Shibatch Super Equalizer ver 0.03 for winamp
|
||||
written by Naoki Shibata shibatch@users.sourceforge.net
|
||||
|
||||
Shibatch Super Equalizer is a graphic and parametric equalizer plugin
|
||||
for winamp. This plugin uses 16383th order FIR filter with FFT algorithm.
|
||||
It's equalization is very precise. Equalization setting can be done
|
||||
for each channel separately.
|
||||
|
||||
Processes of internal equalizer in winamp are actually done by each
|
||||
input plugin, so the results may differ for each input plugin.
|
||||
With this plugin, this problem can be avoided.
|
||||
|
||||
This plugin is optimized for processors which have cache equal to or
|
||||
greater than 128k bytes(16383*2*sizeof(float) = 128k). This plugin
|
||||
won't work efficiently with K6 series processors(buy Athlon!!!).
|
||||
|
||||
Do not forget pressing "preview" button after changing setting.
|
||||
|
||||
http://shibatch.sourceforge.net/
|
||||
|
||||
***
|
||||
|
||||
This program(except FFT part) is distributed under LGPL. See LGPL.txt for
|
||||
details.
|
||||
|
||||
FFT part is a routine made by Mr.Ooura. This routine is a freeware. Contact
|
||||
Mr.Ooura for details of distributing licenses.
|
||||
|
||||
http://www.kurims.kyoto-u.ac.jp/~ooura/fft.html
|
127
src/plugins/supereqdsp/supereq/paramlist.hpp
Normal file
127
src/plugins/supereqdsp/supereq/paramlist.hpp
Normal file
@ -0,0 +1,127 @@
|
||||
/*
|
||||
SuperEQ DSP plugin for DeaDBeeF Player
|
||||
Copyright (C) 2009-2014 Alexey Yakovenko <waker@users.sourceforge.net>
|
||||
Original SuperEQ code (C) Naoki Shibata <shibatch@users.sf.net>
|
||||
|
||||
This program is free software; you can redistribute it and/or
|
||||
modify it under the terms of the GNU General Public License
|
||||
as published by the Free Software Foundation; either version 2
|
||||
of the License, or (at your option) any later version.
|
||||
|
||||
This program is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program; if not, write to the Free Software
|
||||
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*/
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
class paramlistelm {
|
||||
public:
|
||||
class paramlistelm *next;
|
||||
|
||||
float lower,upper,gain,gain2;
|
||||
int sortindex;
|
||||
|
||||
paramlistelm(void) {
|
||||
lower = upper = gain = 0;
|
||||
next = NULL;
|
||||
};
|
||||
|
||||
~paramlistelm() {
|
||||
delete next;
|
||||
next = NULL;
|
||||
};
|
||||
};
|
||||
|
||||
class paramlist {
|
||||
public:
|
||||
class paramlistelm *elm;
|
||||
|
||||
paramlist(void) {
|
||||
elm = NULL;
|
||||
}
|
||||
|
||||
~paramlist() {
|
||||
delete elm;
|
||||
elm = NULL;
|
||||
}
|
||||
|
||||
void copy(paramlist &src)
|
||||
{
|
||||
delete elm;
|
||||
elm = NULL;
|
||||
|
||||
paramlistelm **p,*q;
|
||||
for(p=&elm,q=src.elm;q != NULL;q = q->next,p = &(*p)->next)
|
||||
{
|
||||
*p = new paramlistelm;
|
||||
(*p)->lower = q->lower;
|
||||
(*p)->upper = q->upper;
|
||||
(*p)->gain = q->gain;
|
||||
}
|
||||
}
|
||||
|
||||
paramlistelm *newelm(void)
|
||||
{
|
||||
paramlistelm **e;
|
||||
for(e = &elm;*e != NULL;e = &(*e)->next) ;
|
||||
*e = new paramlistelm;
|
||||
|
||||
return *e;
|
||||
}
|
||||
|
||||
int getnelm(void)
|
||||
{
|
||||
int i;
|
||||
paramlistelm *e;
|
||||
|
||||
for(e = elm,i = 0;e != NULL;e = e->next,i++) ;
|
||||
|
||||
return i;
|
||||
}
|
||||
|
||||
void delelm(paramlistelm *p)
|
||||
{
|
||||
paramlistelm **e;
|
||||
for(e = &elm;*e != NULL && p != *e;e = &(*e)->next) ;
|
||||
if (*e == NULL) return;
|
||||
*e = (*e)->next;
|
||||
p->next = NULL;
|
||||
delete p;
|
||||
}
|
||||
|
||||
void sortelm(void)
|
||||
{
|
||||
int i=0;
|
||||
|
||||
if (elm == NULL) return;
|
||||
|
||||
for(paramlistelm *r = elm;r != NULL;r = r->next) r->sortindex = i++;
|
||||
|
||||
paramlistelm **p,**q;
|
||||
|
||||
for(p=&elm->next;*p != NULL;)
|
||||
{
|
||||
for(q=&elm;*q != *p;q = &(*q)->next)
|
||||
if ((*p)->lower < (*q)->lower ||
|
||||
((*p)->lower == (*q)->lower && (*p)->sortindex < (*q)->sortindex)) break;
|
||||
|
||||
if (p == q) {p = &(*p)->next; continue;}
|
||||
|
||||
paramlistelm **pn = p;
|
||||
paramlistelm *pp = *p;
|
||||
*p = (*p)->next;
|
||||
pp->next = *q;
|
||||
*q = pp;
|
||||
|
||||
p = pn;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
74
src/plugins/supereqdsp/supereqdsp_plugin.cpp
Normal file
74
src/plugins/supereqdsp/supereqdsp_plugin.cpp
Normal file
@ -0,0 +1,74 @@
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
//
|
||||
// Copyright (c) 2007-2017 musikcube team
|
||||
//
|
||||
// All rights reserved.
|
||||
//
|
||||
// Redistribution and use in source and binary forms, with or without
|
||||
// modification, are permitted provided that the following conditions are met:
|
||||
//
|
||||
// * Redistributions of source code must retain the above copyright notice,
|
||||
// this list of conditions and the following disclaimer.
|
||||
//
|
||||
// * Redistributions in binary form must reproduce the above copyright
|
||||
// notice, this list of conditions and the following disclaimer in the
|
||||
// documentation and/or other materials provided with the distribution.
|
||||
//
|
||||
// * Neither the name of the author nor the names of other contributors may
|
||||
// be used to endorse or promote products derived from this software
|
||||
// without specific prior written permission.
|
||||
//
|
||||
// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
|
||||
// AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
||||
// IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
||||
// ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
|
||||
// LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||
// CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
|
||||
// SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
|
||||
// INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
|
||||
// CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
|
||||
// ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
// POSSIBILITY OF SUCH DAMAGE.
|
||||
//
|
||||
//////////////////////////////////////////////////////////////////////////////
|
||||
|
||||
#include <core/sdk/constants.h>
|
||||
#include <core/sdk/IPlugin.h>
|
||||
#include <core/sdk/ISchema.h>
|
||||
#include <core/sdk/IDSP.h>
|
||||
#include "SuperEqDsp.h"
|
||||
|
||||
#ifdef WIN32
|
||||
#define DLLEXPORT __declspec(dllexport)
|
||||
#else
|
||||
#define DLLEXPORT
|
||||
#endif
|
||||
|
||||
class SuperEqPlugin : public musik::core::sdk::IPlugin {
|
||||
public:
|
||||
virtual void Release() { delete this; }
|
||||
virtual const char* Name() { return "SuperEq IDSP"; }
|
||||
virtual const char* Version() { return "0.1.0"; }
|
||||
virtual const char* Author() { return "Naoki Shibata, Alexey Yakovenko, clangen"; }
|
||||
virtual const char* Guid() { return "6f0ed53b-0f13-4220-9b0a-ca496b6421cc"; }
|
||||
virtual bool Configurable() { return false; }
|
||||
virtual void Configure() { }
|
||||
virtual void Reload() { }
|
||||
virtual int SdkVersion() { return musik::core::sdk::SdkVersion; }
|
||||
};
|
||||
|
||||
#ifdef WIN32
|
||||
BOOL APIENTRY DllMain(HMODULE hModule, DWORD ul_reason_for_call, LPVOID lpReserved) {
|
||||
return true;
|
||||
}
|
||||
#endif
|
||||
|
||||
extern "C" DLLEXPORT musik::core::sdk::IPlugin* GetPlugin() {
|
||||
return new SuperEqPlugin();
|
||||
}
|
||||
|
||||
extern "C" DLLEXPORT musik::core::sdk::IDSP* GetDSP() {
|
||||
return new SuperEqDsp();
|
||||
}
|
||||
|
||||
extern "C" DLLEXPORT musik::core::sdk::ISchema* GetSchema();
|
Loading…
x
Reference in New Issue
Block a user