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
24using uint = unsigned int;
25
26static constexpr uint16_t SURROUND_BUFSIZE { 8192 };
27
29{
30public:
31 enum SurroundMode : std::uint8_t
32 {
37 };
38public:
39 FreeSurround(uint srate, bool moviemode, SurroundMode mode);
41
42 // put frames in buffer, returns number of frames used
43 uint putFrames(void* buffer, uint numFrames, uint numChannels);
44 // get a number of frames
45 uint receiveFrames(void *buffer, uint maxFrames);
46 // flush unprocessed samples
47 void flush();
49 uint numFrames() const;
50
51 long long getLatency();
52 uint frameLatency() const;
53
54 static uint framesPerBlock();
55
56protected:
57 void process_block();
58 void open();
59 void close();
60 void SetParams();
61
62private:
63
64 // the changeable parameters
66 int32_t center_width { 100 }; // presence of the center channel
67 int32_t dimension { 0 }; // dimension
68 float coeff_a { 0.8165 }; // surround mixing coefficients
69 float coeff_b { 0.5774 }; // surround mixing coefficients
70 int32_t phasemode { 0 }; // phase shifting mode
71 int32_t steering { 1 }; // steering mode (0=simple, 1=linear)
72 int32_t front_sep { 100 }; // front stereo separation
73 int32_t rear_sep { 100 }; // rear stereo separation
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
int m_processedSize
Definition: freesurround.h:85
void process_block()
uint frameLatency() const
@ SurroundModeActiveSimple
Definition: freesurround.h:34
@ SurroundModeActiveLinear
Definition: freesurround.h:35
@ SurroundModePassiveHall
Definition: freesurround.h:36
int m_latencyFrames
Definition: freesurround.h:87
uint numFrames() const
static uint framesPerBlock()
SurroundMode m_surroundMode
Definition: freesurround.h:86
struct FreeSurround::fsurround_params m_params
uint receiveFrames(void *buffer, uint maxFrames)
long long getLatency()
struct buffers * m_bufs
Definition: freesurround.h:80
class fsurround_decoder * m_decoder
Definition: freesurround.h:81
FreeSurround(uint srate, bool moviemode, SurroundMode mode)
uint numUnprocessedFrames() const
bool m_processed
Definition: freesurround.h:84
uint putFrames(void *buffer, uint numFrames, uint numChannels)
unsigned int uint
Definition: freesurround.h:24
static constexpr uint16_t SURROUND_BUFSIZE
Definition: freesurround.h:26
unsigned short uint16_t
Definition: iso6937tables.h:3