forked from bartvdbraak/blender
3D Audio GSoC:
Implementation of Julius O. Smith's resampling algorithm for high quality audio resampling. The filter currently is a sinc filter with a 0.9 cutt-off and windowed by a kaiser window (beta = 10). Also includes minor changes in the linear resampler.
This commit is contained in:
parent
c284725a1a
commit
bc1650a226
@ -94,6 +94,10 @@ set(SRC
|
||||
intern/AUD_IFactory.h
|
||||
intern/AUD_IHandle.h
|
||||
intern/AUD_IReader.h
|
||||
intern/AUD_JOSResampleFactory.cpp
|
||||
intern/AUD_JOSResampleFactory.h
|
||||
intern/AUD_JOSResampleReader.cpp
|
||||
intern/AUD_JOSResampleReader.h
|
||||
intern/AUD_LinearResampleFactory.cpp
|
||||
intern/AUD_LinearResampleFactory.h
|
||||
intern/AUD_LinearResampleReader.cpp
|
||||
|
44
intern/audaspace/intern/AUD_JOSResampleFactory.cpp
Normal file
44
intern/audaspace/intern/AUD_JOSResampleFactory.cpp
Normal file
@ -0,0 +1,44 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* Copyright 2009-2011 Jörg Hermann Müller
|
||||
*
|
||||
* This file is part of AudaSpace.
|
||||
*
|
||||
* Audaspace 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.
|
||||
*
|
||||
* AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file audaspace/intern/AUD_JOSResampleFactory.cpp
|
||||
* \ingroup audaspaceintern
|
||||
*/
|
||||
|
||||
|
||||
#include "AUD_JOSResampleFactory.h"
|
||||
#include "AUD_JOSResampleReader.h"
|
||||
|
||||
AUD_JOSResampleFactory::AUD_JOSResampleFactory(AUD_Reference<AUD_IFactory> factory,
|
||||
AUD_DeviceSpecs specs) :
|
||||
AUD_MixerFactory(factory, specs)
|
||||
{
|
||||
}
|
||||
|
||||
AUD_Reference<AUD_IReader> AUD_JOSResampleFactory::createReader()
|
||||
{
|
||||
return new AUD_JOSResampleReader(getReader(), m_specs.specs);
|
||||
}
|
53
intern/audaspace/intern/AUD_JOSResampleFactory.h
Normal file
53
intern/audaspace/intern/AUD_JOSResampleFactory.h
Normal file
@ -0,0 +1,53 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* Copyright 2009-2011 Jörg Hermann Müller
|
||||
*
|
||||
* This file is part of AudaSpace.
|
||||
*
|
||||
* Audaspace 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.
|
||||
*
|
||||
* AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file audaspace/intern/AUD_JOSResampleFactory.h
|
||||
* \ingroup audaspaceintern
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AUD_JOSRESAMPLEFACTORY
|
||||
#define AUD_JOSRESAMPLEFACTORY
|
||||
|
||||
#include "AUD_MixerFactory.h"
|
||||
|
||||
/**
|
||||
* This factory creates a resampling reader that does Julius O. Smith's resampling algorithm.
|
||||
*/
|
||||
class AUD_JOSResampleFactory : public AUD_MixerFactory
|
||||
{
|
||||
private:
|
||||
// hide copy constructor and operator=
|
||||
AUD_JOSResampleFactory(const AUD_JOSResampleFactory&);
|
||||
AUD_JOSResampleFactory& operator=(const AUD_JOSResampleFactory&);
|
||||
|
||||
public:
|
||||
AUD_JOSResampleFactory(AUD_Reference<AUD_IFactory> factory, AUD_DeviceSpecs specs);
|
||||
|
||||
virtual AUD_Reference<AUD_IReader> createReader();
|
||||
};
|
||||
|
||||
#endif //AUD_JOSRESAMPLEFACTORY
|
3596
intern/audaspace/intern/AUD_JOSResampleReader.cpp
Normal file
3596
intern/audaspace/intern/AUD_JOSResampleReader.cpp
Normal file
File diff suppressed because it is too large
Load Diff
100
intern/audaspace/intern/AUD_JOSResampleReader.h
Normal file
100
intern/audaspace/intern/AUD_JOSResampleReader.h
Normal file
@ -0,0 +1,100 @@
|
||||
/*
|
||||
* $Id$
|
||||
*
|
||||
* ***** BEGIN GPL LICENSE BLOCK *****
|
||||
*
|
||||
* Copyright 2009-2011 Jörg Hermann Müller
|
||||
*
|
||||
* This file is part of AudaSpace.
|
||||
*
|
||||
* Audaspace 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.
|
||||
*
|
||||
* AudaSpace 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 Audaspace; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
|
||||
*
|
||||
* ***** END GPL LICENSE BLOCK *****
|
||||
*/
|
||||
|
||||
/** \file audaspace/intern/AUD_JOSResampleReader.h
|
||||
* \ingroup audaspaceintern
|
||||
*/
|
||||
|
||||
|
||||
#ifndef AUD_JOSRESAMPLEREADER
|
||||
#define AUD_JOSRESAMPLEREADER
|
||||
|
||||
#include "AUD_ResampleReader.h"
|
||||
#include "AUD_Buffer.h"
|
||||
|
||||
/**
|
||||
* This resampling reader uses Julius O. Smith's resampling algorithm.
|
||||
*/
|
||||
class AUD_JOSResampleReader : public AUD_ResampleReader
|
||||
{
|
||||
private:
|
||||
static const unsigned int m_nL = 9;
|
||||
static const unsigned int m_nN = 23;
|
||||
static const unsigned int m_Nz = 32;
|
||||
static const unsigned int m_L = 1 << m_nL;
|
||||
static const unsigned int m_NN = 1 << m_nN;
|
||||
static const float m_coeff[];
|
||||
static const float m_diff[];
|
||||
|
||||
/**
|
||||
* The reader channels.
|
||||
*/
|
||||
AUD_Channels m_channels;
|
||||
|
||||
/**
|
||||
* The sample position in the cache.
|
||||
*/
|
||||
unsigned int m_n;
|
||||
|
||||
/**
|
||||
* The subsample position in the cache.
|
||||
*/
|
||||
unsigned int m_P;
|
||||
|
||||
/**
|
||||
* The input data buffer.
|
||||
*/
|
||||
AUD_Buffer m_buffer;
|
||||
|
||||
/**
|
||||
* How many samples in the cache are valid.
|
||||
*/
|
||||
int m_cache_valid;
|
||||
|
||||
// hide copy constructor and operator=
|
||||
AUD_JOSResampleReader(const AUD_JOSResampleReader&);
|
||||
AUD_JOSResampleReader& operator=(const AUD_JOSResampleReader&);
|
||||
|
||||
void reset();
|
||||
|
||||
void updateBuffer(int size, float factor, int samplesize);
|
||||
|
||||
public:
|
||||
/**
|
||||
* Creates a resampling reader.
|
||||
* \param reader The reader to mix.
|
||||
* \param specs The target specification.
|
||||
*/
|
||||
AUD_JOSResampleReader(AUD_Reference<AUD_IReader> reader, AUD_Specs specs);
|
||||
|
||||
virtual void seek(int position);
|
||||
virtual int getLength() const;
|
||||
virtual int getPosition() const;
|
||||
virtual AUD_Specs getSpecs() const;
|
||||
virtual void read(int& length, bool& eos, sample_t* buffer);
|
||||
};
|
||||
|
||||
#endif //AUD_JOSRESAMPLEREADER
|
@ -40,7 +40,6 @@ AUD_LinearResampleReader::AUD_LinearResampleReader(AUD_Reference<AUD_IReader> re
|
||||
AUD_Specs specs) :
|
||||
AUD_ResampleReader(reader, specs.rate),
|
||||
m_channels(reader->getSpecs().channels),
|
||||
m_position(0),
|
||||
m_cache_pos(0),
|
||||
m_cache_ok(false)
|
||||
{
|
||||
|
@ -36,7 +36,7 @@
|
||||
#include "AUD_Buffer.h"
|
||||
|
||||
/**
|
||||
* This resampling reader uses libsamplerate for resampling.
|
||||
* This resampling reader does simple first-order hold resampling.
|
||||
*/
|
||||
class AUD_LinearResampleReader : public AUD_ResampleReader
|
||||
{
|
||||
@ -46,11 +46,6 @@ private:
|
||||
*/
|
||||
AUD_Channels m_channels;
|
||||
|
||||
/**
|
||||
* The current position.
|
||||
*/
|
||||
int m_position;
|
||||
|
||||
/**
|
||||
* The position in the cache.
|
||||
*/
|
||||
|
Loading…
Reference in New Issue
Block a user