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 "libmythbase/compat.h" // instead of sys/types.h, for MinGW compatibility
23 
24 static constexpr uint16_t SURROUND_BUFSIZE { 8192 };
25 
26 class Q_DECL_EXPORT FreeSurround
27 {
28 public:
30  {
34  SurroundModePassiveHall
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);
74  } m_params;
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::dimension
int32_t dimension
Definition: freesurround.h:65
FreeSurround::SurroundMode
SurroundMode
Definition: freesurround.h:29
FreeSurround::SurroundModeActiveSimple
@ SurroundModeActiveSimple
Definition: freesurround.h:32
FreeSurround
Definition: freesurround.h:26
SURROUND_BUFSIZE
static constexpr uint16_t SURROUND_BUFSIZE
Definition: freesurround.h:24
FreeSurround::fsurround_params
Definition: freesurround.h:63
close
#define close
Definition: compat.h:43
FreeSurround::SurroundModePassive
@ SurroundModePassive
Definition: freesurround.h:31
FreeSurround::fsurround_params::center_width
int32_t center_width
Definition: freesurround.h:64
compat.h
uint
unsigned int uint
Definition: compat.h:81
fsurround_decoder
Definition: el_processor.h:23
buffers
Definition: freesurround.cpp:50
FreeSurround::m_srate
uint m_srate
Definition: freesurround.h:77
uint16_t
unsigned short uint16_t
Definition: iso6937tables.h:3