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