MythTV
master
mythplugins
mythmusic
mythmusic
mythgoom.cpp
Go to the documentation of this file.
1
#include "
mythgoom.h
"
2
3
// C++
4
#include <algorithm>
5
#include <cmath>
6
#include <cstdlib>
7
#include <iostream>
8
9
// Qt
10
#include <QCoreApplication>
11
#include <QPainter>
12
13
// MythTV
14
#include <
libmyth/mythcontext.h
>
15
#include <
libmythbase/compat.h
>
16
#include <
libmythbase/mythlogging.h
>
17
18
// Goom
19
#include "
libmythtv/visualisations/goom/goom_tools.h
"
20
#include "
libmythtv/visualisations/goom/goom_core.h
"
21
22
Goom::Goom
()
23
{
24
m_fps
= 20;
25
26
goom_init
(800, 600, 0);
27
28
m_scalew
=
gCoreContext
->
GetNumSetting
(
"VisualScaleWidth"
, 2);
29
m_scaleh
=
gCoreContext
->
GetNumSetting
(
"VisualScaleHeight"
, 2);
30
31
// we allow 1, 2 or 4 for the scale since goom likes its resolution to be a multiple of 2
32
if
(
m_scaleh
== 3 ||
m_scaleh
> 4)
33
m_scaleh
= 4;
34
m_scaleh
= std::max(
m_scaleh
, 1);
35
36
if
(
m_scalew
== 3 ||
m_scalew
> 4)
37
m_scalew
= 4;
38
m_scalew
= std::max(
m_scalew
, 1);
39
}
40
41
Goom::~Goom
()
42
{
43
goom_close
();
44
}
45
46
void
Goom::resize
(
const
QSize &newsize)
47
{
48
m_size
= newsize;
49
50
m_size
.setHeight((
m_size
.height() / 2) * 2);
51
m_size
.setWidth((
m_size
.width() / 2) * 2);
52
53
// only scale the resolution if it is > 256
54
// this ensures the small visualisers don't look too blocky
55
if
(
m_size
.width() > 256)
56
goom_set_resolution
(
m_size
.width() /
m_scalew
,
m_size
.height() /
m_scaleh
, 0);
57
else
58
goom_set_resolution
(
m_size
.width(),
m_size
.height(), 0);
59
}
60
61
bool
Goom::process
(
VisualNode
*node)
62
{
63
if
(!node || node->
m_length
== 0)
64
return
false
;
65
66
int
numSamps = 512;
67
if
(node->
m_length
< 512)
68
numSamps = node->
m_length
;
69
70
GoomDualData
data;
71
72
int
i = 0;
73
for
(i = 0; i < numSamps; i++)
74
{
75
data[0][i] = node->
m_left
[i];
76
if
(node->
m_right
)
77
data[1][i] = node->
m_right
[i];
78
else
79
data[1][i] = data[0][i];
80
}
81
82
m_buffer
=
goom_update
(data, 0);
83
84
return
false
;
85
}
86
87
bool
Goom::draw
(QPainter *
p
,
const
QColor &
back
)
88
{
89
p
->fillRect(0, 0,
m_size
.width(),
m_size
.height(),
back
);
90
91
if
(!
m_buffer
)
92
return
true
;
93
94
int
width =
m_size
.width();
95
int
height =
m_size
.height();
96
97
if
(
m_size
.width() > 256)
98
{
99
width /=
m_scalew
;
100
height /=
m_scaleh
;
101
}
102
103
auto
*image =
new
QImage((uchar*)
m_buffer
, width, height, width * 4, QImage::Format_RGB32);
104
105
p
->drawImage(QRect(0, 0,
m_size
.width(),
m_size
.height()), *image);
106
107
delete
image;
108
109
return
true
;
110
}
111
112
static
class
GoomFactory
:
public
VisFactory
113
{
114
public
:
115
const
QString &
name
(
void
)
const
override
// VisFactory
116
{
117
static
QString s_name = QCoreApplication::translate(
"Visualizers"
,
118
"Goom"
);
119
return
s_name;
120
}
121
122
uint
plugins
(QStringList *list)
const
override
// VisFactory
123
{
124
*list <<
name
();
125
return
1;
126
}
127
128
VisualBase
*
create
([[maybe_unused]]
MainVisual
*parent,
129
[[maybe_unused]]
const
QString &pluginName)
const
override
// VisFactory
130
{
131
return
new
Goom
();
132
}
133
}
GoomFactory
;
GoomDualData
std::array< GoomSingleData, 2 > GoomDualData
Definition:
goom_core.h:13
back
static guint32 * back
Definition:
goom_core.cpp:25
VisualNode
Definition:
videovisual.h:25
Goom::m_buffer
unsigned int * m_buffer
Definition:
mythgoom.h:20
Goom::resize
void resize(const QSize &size) override
Definition:
mythgoom.cpp:46
Goom
Definition:
mythgoom.h:6
Goom::Goom
Goom(void)
Definition:
mythgoom.cpp:22
VisualBase
Definition:
visualize.h:61
VisualNode::m_left
short * m_left
Definition:
videovisual.h:37
goom_set_resolution
void goom_set_resolution(guint32 resx, guint32 resy, int cinemascope)
Definition:
goom_core.cpp:104
mythlogging.h
hardwareprofile.config.p
p
Definition:
config.py:33
VisualNode::m_right
short * m_right
Definition:
videovisual.h:38
compat.h
GoomFactory::create
VisualBase * create([[maybe_unused]] MainVisual *parent, [[maybe_unused]] const QString &pluginName) const override
Definition:
mythgoom.cpp:128
GoomFactory
Definition:
mythgoom.cpp:112
goom_core.h
VisFactory
Definition:
visualize.h:91
goom_init
void goom_init(guint32 resx, guint32 resy, int cinemascope)
Definition:
goom_core.cpp:64
Goom::m_scaleh
int m_scaleh
Definition:
mythgoom.h:22
gCoreContext
MythCoreContext * gCoreContext
This global variable contains the MythCoreContext instance for the app.
Definition:
mythcorecontext.cpp:55
MythCoreContext::GetNumSetting
int GetNumSetting(const QString &key, int defaultval=0)
Definition:
mythcorecontext.cpp:916
mythgoom.h
goom_update
guint32 * goom_update(GoomDualData &data, int forceMode)
Definition:
goom_core.cpp:133
goom_close
void goom_close()
Definition:
goom_core.cpp:846
MainVisual
Definition:
mainvisual.h:34
Goom::m_scalew
int m_scalew
Definition:
mythgoom.h:21
VisualNode::m_length
long m_length
Definition:
videovisual.h:39
VisualBase::m_fps
int m_fps
Definition:
visualize.h:87
Goom::process
bool process(VisualNode *node) override
Definition:
mythgoom.cpp:61
Goom::draw
bool draw(QPainter *p, const QColor &back) override
Definition:
mythgoom.cpp:87
GoomFactory
GoomFactory GoomFactory
GoomFactory::plugins
uint plugins(QStringList *list) const override
Definition:
mythgoom.cpp:122
GoomFactory::name
const QString & name(void) const override
Definition:
mythgoom.cpp:115
goom_tools.h
Goom::~Goom
~Goom() override
Definition:
mythgoom.cpp:41
mythcontext.h
Goom::m_size
QSize m_size
Definition:
mythgoom.h:15
uint
unsigned int uint
Definition:
freesurround.h:24
Generated on Sun Jan 5 2025 03:16:12 for MythTV by
1.8.17