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