Cinder  0.8.6
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Pages
ConverterR8brain.h
Go to the documentation of this file.
1 /*
2  Copyright (c) 2014, The Cinder Project
3 
4  This code is intended to be used with the Cinder C++ library, http://libcinder.org
5 
6  Redistribution and use in source and binary forms, with or without modification, are permitted provided that
7  the following conditions are met:
8 
9  * Redistributions of source code must retain the above copyright notice, this list of conditions and
10  the following disclaimer.
11  * Redistributions in binary form must reproduce the above copyright notice, this list of conditions and
12  the following disclaimer in the documentation and/or other materials provided with the distribution.
13 
14  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED
15  WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A
16  PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR
17  ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
18  TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
19  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
20  NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
21  POSSIBILITY OF SUCH DAMAGE.
22  */
23 
24 #pragma once
25 
27 
28 #include <vector>
29 #include <memory>
30 
31 namespace r8b {
32  class CDSPResampler24;
33 }
34 
35 namespace cinder { namespace audio { namespace dsp {
36 
39  public:
40 
41  ConverterImplR8brain( size_t sourceSampleRate, size_t destSampleRate, size_t sourceNumChannels, size_t destNumChannels, size_t sourceMaxFramesPerBlock );
42  virtual ~ConverterImplR8brain();
43 
44  std::pair<size_t, size_t> convert( const Buffer *sourceBuffer, Buffer *destBuffer ) override;
45  void clear() override;
46 
47  private:
48  std::pair<size_t, size_t> convertImpl( const Buffer *sourceBuffer, Buffer *destBuffer, int readCount );
49  std::pair<size_t, size_t> convertImplUpMixing( const Buffer *sourceBuffer, Buffer *destBuffer, int readCount );
50  std::pair<size_t, size_t> convertImplDownMixing( const Buffer *sourceBuffer, Buffer *destBuffer, int readCount );
51 
52  std::vector<std::unique_ptr<r8b::CDSPResampler24> > mResamplers;
53  BufferT<double> mBufferd;
54  Buffer mMixingBuffer;
55 };
56 
57 } } } // namespace cinder::audio::dsp
A platform-specific converter that supports samplerate and channel conversion.
Definition: Converter.h:33
virtual ~ConverterImplR8brain()
Definition: ConverterR8brain.cpp:64
void clear() override
Clears the state of the converter, discarding / flushing accumulated samples. Optional for implementa...
Definition: ConverterR8brain.cpp:90
std::pair< size_t, size_t > convert(const Buffer *sourceBuffer, Buffer *destBuffer) override
Definition: ConverterR8brain.cpp:69
ConverterImplR8brain(size_t sourceSampleRate, size_t destSampleRate, size_t sourceNumChannels, size_t destNumChannels, size_t sourceMaxFramesPerBlock)
Definition: ConverterR8brain.cpp:41
Converter implementation using the r8brain samplerate conversion library by designed by Aleksey Vanee...
Definition: ConverterR8brain.h:38