MythTV  master
freesurround.h
Go to the documentation of this file.
1 /*
2 Copyright (C) 2007 Christian Kothe, Mark Spieth
3 
4 This program is free software; you can redistribute it and/or
5 modify it under the terms of the GNU General Public License
6 as published by the Free Software Foundation; either version 2
7 of the License, or (at your option) any later version.
8 
9 This program is distributed in the hope that it will be useful,
10 but WITHOUT ANY WARRANTY; without even the implied warranty of
11 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 GNU General Public License for more details.
13 
14 You should have received a copy of the GNU General Public License
15 along with this program; if not, write to the Free Software
16 Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17 */
18 
19 #ifndef FREESURROUND_H
20 #define FREESURROUND_H
21 
22 #include "compat.h" // instead of sys/types.h, for MinGW compatibility
23 
24 #define SURROUND_BUFSIZE 8192
25 
27 {
28 public:
30  {
35  };
36 public:
37  FreeSurround(uint srate, bool moviemode, SurroundMode mode);
38  ~FreeSurround();
39 
40  // put frames in buffer, returns number of frames used
41  uint putFrames(void* buffer, uint numFrames, uint numChannels);
42  // get a number of frames
43  uint receiveFrames(void *buffer, uint maxFrames);
44  // flush unprocessed samples
45  void flush();
46  uint numUnprocessedFrames() const;
47  uint numFrames() const;
48 
49  long long getLatency();
50  uint frameLatency() const;
51 
52  static uint framesPerBlock();
53 
54 protected:
55  void process_block();
56  void open();
57  void close();
58  void SetParams();
59 
60 private:
61 
62  // the changeable parameters
64  int32_t center_width; // presence of the center channel
65  int32_t dimension; // dimension
66  float coeff_a { 0.8165 }; // surround mixing coefficients
67  float coeff_b { 0.5774 }; // surround mixing coefficients
68  int32_t phasemode { 0 }; // phase shifting mode
69  int32_t steering { 1 }; // steering mode (0=simple, 1=linear)
70  int32_t front_sep { 100 }; // front stereo separation
71  int32_t rear_sep { 100 }; // rear stereo separation
72  // (default) constructor
73  explicit fsurround_params(int32_t center_width=100, int32_t dimension=0);
75 
76  // additional settings
78 
79  // info about the current setup
80  struct buffers *m_bufs {nullptr}; // our buffers
81  class fsurround_decoder *m_decoder {nullptr}; // the surround decoder
82  int m_inCount {0}; // amount in lt,rt
83  int m_outCount {0}; // amount in output bufs
84  bool m_processed {true}; // whether processing is enabled for latency calc
85  int m_processedSize {0}; // amount processed
86  SurroundMode m_surroundMode {SurroundModePassive}; // 1 of 3 surround modes supported
87  int m_latencyFrames {0}; // number of frames of incurred latency
88  int m_channels {0};
89 };
90 
91 #endif
FreeSurround::SurroundModeActiveLinear
@ SurroundModeActiveLinear
Definition: freesurround.h:33
FreeSurround::fsurround_params::coeff_a
float coeff_a
Definition: freesurround.h:66
FreeSurround::fsurround_params::dimension
int32_t dimension
Definition: freesurround.h:65
FreeSurround::SetParams
void SetParams()
Definition: freesurround.cpp:120
FreeSurround::SurroundMode
SurroundMode
Definition: freesurround.h:30
FreeSurround::fsurround_params::steering
int32_t steering
Definition: freesurround.h:69
FreeSurround::m_decoder
class fsurround_decoder * m_decoder
Definition: freesurround.h:81
FreeSurround::getLatency
long long getLatency()
Definition: freesurround.cpp:408
FreeSurround::SurroundModeActiveSimple
@ SurroundModeActiveSimple
Definition: freesurround.h:32
FreeSurround::fsurround_params::phasemode
int32_t phasemode
Definition: freesurround.h:68
FreeSurround::close
void close()
Definition: freesurround.cpp:437
FreeSurround::numFrames
uint numFrames() const
Definition: freesurround.cpp:448
FreeSurround::open
void open()
Definition: freesurround.cpp:424
FreeSurround::SurroundModePassiveHall
@ SurroundModePassiveHall
Definition: freesurround.h:34
FreeSurround
Definition: freesurround.h:27
FreeSurround::fsurround_params
Definition: freesurround.h:63
FreeSurround::fsurround_params::front_sep
int32_t front_sep
Definition: freesurround.h:70
FreeSurround::putFrames
uint putFrames(void *buffer, uint numFrames, uint numChannels)
Definition: freesurround.cpp:147
FreeSurround::numUnprocessedFrames
uint numUnprocessedFrames() const
Definition: freesurround.cpp:443
FreeSurround::m_surroundMode
SurroundMode m_surroundMode
Definition: freesurround.h:86
FreeSurround::process_block
void process_block()
Definition: freesurround.cpp:393
FreeSurround::fsurround_params::rear_sep
int32_t rear_sep
Definition: freesurround.h:71
FreeSurround::SurroundModePassive
@ SurroundModePassive
Definition: freesurround.h:31
FreeSurround::fsurround_params::center_width
int32_t center_width
Definition: freesurround.h:64
compat.h
FreeSurround::fsurround_params::fsurround_params
fsurround_params(int32_t center_width=100, int32_t dimension=0)
Definition: freesurround.cpp:131
FreeSurround::framesPerBlock
static uint framesPerBlock()
Definition: freesurround.cpp:460
FreeSurround::frameLatency
uint frameLatency() const
Definition: freesurround.cpp:453
FreeSurround::m_outCount
int m_outCount
Definition: freesurround.h:83
FreeSurround::flush
void flush()
Definition: freesurround.cpp:416
uint
unsigned int uint
Definition: compat.h:140
FreeSurround::m_processed
bool m_processed
Definition: freesurround.h:84
FreeSurround::m_channels
int m_channels
Definition: freesurround.h:88
fsurround_decoder
Definition: el_processor.h:23
buffers
Definition: freesurround.cpp:51
FreeSurround::fsurround_params::coeff_b
float coeff_b
Definition: freesurround.h:67
FreeSurround::m_srate
uint m_srate
Definition: freesurround.h:77
FreeSurround::m_inCount
int m_inCount
Definition: freesurround.h:82
FreeSurround::m_processedSize
int m_processedSize
Definition: freesurround.h:85
FreeSurround::FreeSurround
FreeSurround(uint srate, bool moviemode, SurroundMode mode)
Definition: freesurround.cpp:75
FreeSurround::m_bufs
struct buffers * m_bufs
Definition: freesurround.h:80
FreeSurround::m_latencyFrames
int m_latencyFrames
Definition: freesurround.h:87
FreeSurround::receiveFrames
uint receiveFrames(void *buffer, uint maxFrames)
Definition: freesurround.cpp:312
FreeSurround::~FreeSurround
~FreeSurround()
Definition: freesurround.cpp:138
FreeSurround::m_params
struct FreeSurround::fsurround_params m_params