MythTV  master
videovisualmonoscope.cpp
Go to the documentation of this file.
1 // MythTV
2 #include "videovisualmonoscope.h"
3 
4 #ifdef USING_OPENGL
6 #endif
7 #ifdef USING_VULKAN
9 #endif
10 
12  : VideoVisual(Audio, Render),
13  m_fade(Fade)
14 {
15 }
16 
18 {
19  return m_fade ? FADE_NAME : SIMPLE_NAME;
20 }
21 
23 {
24  m_hue = 0.0;
25  m_area = Area;
26  m_rate = 1.0;
27  m_lastTime = nowAsDuration<std::chrono::milliseconds>();
28  m_lineWidth = qMax(1.0F, m_area.height() * 0.004F);
29 }
30 
32 {
33  if (!Buffer)
34  return false;
35 
36  QMutexLocker locker(mutex());
37  auto * node = GetNode();
38 
39  if (m_area.isEmpty() || !node)
40  return false;
41 
42  float y = (static_cast<float>(m_area.height()) / 2.0F) + m_area.top();
43  float x = m_area.left();
44  float xstep = static_cast<float>(m_area.width()) / (NUM_SAMPLES - 1);
45 
46  double index = 0;
47  double const step = static_cast<double>(node->m_length) / NUM_SAMPLES;
48  for (size_t i = 0; i < NUM_SAMPLES; i++)
49  {
50  auto indexTo = static_cast<long>(index + step);
51  if (indexTo == static_cast<long>(index))
52  indexTo = static_cast<long>(index + 1);
53 
54  double value = 0.0;
55  for (auto s = static_cast<long>(index); s < indexTo && s < node->m_length; s++)
56  {
57  double temp = (static_cast<double>(node->m_left[s]) +
58  (node->m_right ? static_cast<double>(node->m_right[s]) : 0.0) *
59  (static_cast<double>(m_area.height())) ) / 65536.0;
60  value = temp > 0.0 ? qMax(temp, value) : qMin(temp, value);
61  }
62 
63  index += step;
64  Buffer[i * 2] = x;
65  Buffer[i * 2 + 1] = y + static_cast<float>(value);
66  x += xstep;
67  }
68  return true;
69 }
70 
72 {
73  // try and give a similar rate of transitions for different playback speeds
74  auto timenow = nowAsDuration<std::chrono::milliseconds>();
75  m_rate = (timenow - m_lastTime).count();
76  m_lastTime = timenow;
77  m_hue += m_rate / 7200.0F;
78  if (m_hue > 1.0F)
79  m_hue -= static_cast<uint>(m_hue);
80 }
81 
83 {
84  public:
85  const QString& name() const override
86  {
87  static QString s_name(FADE_NAME);
88  return s_name;
89  }
90 
91  VideoVisual* Create(AudioPlayer* Audio, MythRender* Render) const override
92  {
93 #ifdef USING_OPENGL
94  auto * render1 = dynamic_cast<MythRenderOpenGL*>(Render);
95  if (render1)
96  return new MythVisualMonoScopeOpenGL(Audio, Render, true);
97 #endif
98 #ifdef USING_VULKAN
99  auto * render2 = dynamic_cast<MythRenderVulkan*>(Render);
100  if (render2)
101  return new MythVisualMonoScopeVulkan(Audio, Render, true);
102 #endif
103  return nullptr;
104  }
105 
106  bool SupportedRenderer(RenderType Type) override;
108 
110 {
111  return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
112 }
113 
115 {
116  public:
117  const QString& name() const override
118  {
119  static QString s_name(SIMPLE_NAME);
120  return s_name;
121  }
122 
123  VideoVisual* Create(AudioPlayer* Audio, MythRender* Render) const override
124  {
125 #ifdef USING_OPENGL
126  auto * render1 = dynamic_cast<MythRenderOpenGL*>(Render);
127  if (render1)
128  return new MythVisualMonoScopeOpenGL(Audio, Render, false);
129 #endif
130 #ifdef USING_VULKAN
131  auto * render2 = dynamic_cast<MythRenderVulkan*>(Render);
132  if (render2)
133  return new MythVisualMonoScopeVulkan(Audio, Render, false);
134 #endif
135  return nullptr;
136  }
137 
138  bool SupportedRenderer(RenderType Type) override;
140 
142 {
143  return ((Type == kRenderOpenGL) || (Type == kRenderVulkan));
144 }
VideoVisualMonoScope::UpdateVertices
bool UpdateVertices(float *Buffer)
Definition: videovisualmonoscope.cpp:31
videovisualmonoscope.h
VideoVisualMonoScopeFactory::name
const QString & name() const override
Definition: videovisualmonoscope.cpp:85
MythVisualMonoScopeVulkan
Definition: mythvisualmonoscopevulkan.h:25
AudioPlayer
Definition: audioplayer.h:28
mythvisualmonoscopevulkan.h
SIMPLE_NAME
#define SIMPLE_NAME
Definition: videovisualmonoscope.h:9
kRenderOpenGL
@ kRenderOpenGL
Definition: mythrender_base.h:19
kRenderVulkan
@ kRenderVulkan
Definition: mythrender_base.h:20
FADE_NAME
#define FADE_NAME
Definition: videovisualmonoscope.h:8
NUM_SAMPLES
#define NUM_SAMPLES
Definition: videovisualmonoscope.h:7
VideoVisualMonoScopeFactory::Create
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
Definition: videovisualmonoscope.cpp:91
VideoVisualSimpleScopeFactory::SupportedRenderer
bool SupportedRenderer(RenderType Type) override
Definition: videovisualmonoscope.cpp:141
VideoVisualMonoScopeFactory
VideoVisualMonoScopeFactory VideoVisualMonoScopeFactory
VideoVisualMonoScope::m_lastTime
std::chrono::milliseconds m_lastTime
Definition: videovisualmonoscope.h:23
VideoVisualMonoScopeFactory::SupportedRenderer
bool SupportedRenderer(RenderType Type) override
Definition: videovisualmonoscope.cpp:109
VideoVisualFactory
Definition: videovisual.h:77
VideoVisualSimpleScopeFactory
Definition: videovisualmonoscope.cpp:114
MythTV::Visual::mutex
QMutex * mutex()
Definition: visual.h:26
mythvisualmonoscopeopengl.h
VideoVisualMonoScopeFactory
Definition: videovisualmonoscope.cpp:82
RenderType
RenderType
Definition: mythrender_base.h:15
uint
unsigned int uint
Definition: compat.h:144
VideoVisualMonoScope::m_lineWidth
float m_lineWidth
Definition: videovisualmonoscope.h:26
MythRenderOpenGL
Definition: mythrenderopengl.h:99
Buffer
Definition: MythExternControl.h:36
VideoVisualSimpleScopeFactory::Create
VideoVisual * Create(AudioPlayer *Audio, MythRender *Render) const override
Definition: videovisualmonoscope.cpp:123
MythRender
Definition: mythrender_base.h:23
VideoVisualMonoScope::Name
QString Name() override
Definition: videovisualmonoscope.cpp:17
MythVisualMonoScopeOpenGL
Definition: mythvisualmonoscopeopengl.h:13
VideoVisualSimpleScopeFactory::name
const QString & name() const override
Definition: videovisualmonoscope.cpp:117
VideoVisual
Definition: videovisual.h:42
MythRenderVulkan
Definition: mythrendervulkan.h:54
VideoVisualSimpleScopeFactory
VideoVisualSimpleScopeFactory VideoVisualSimpleScopeFactory
VideoVisualMonoScope::m_hue
float m_hue
Definition: videovisualmonoscope.h:24
VideoVisual::m_area
QRect m_area
Definition: videovisual.h:71
VideoVisualMonoScope::m_rate
float m_rate
Definition: videovisualmonoscope.h:25
VideoVisual::GetNode
VisualNode * GetNode(void)
Definition: videovisual.cpp:82
VideoVisualMonoScope::m_fade
bool m_fade
Definition: videovisualmonoscope.h:28
VideoVisualMonoScope::InitCommon
void InitCommon(QRect Area)
Definition: videovisualmonoscope.cpp:22
VideoVisualMonoScope::UpdateTime
void UpdateTime()
Definition: videovisualmonoscope.cpp:71
VideoVisualMonoScope::VideoVisualMonoScope
VideoVisualMonoScope(AudioPlayer *Audio, MythRender *Render, bool Fade)
Definition: videovisualmonoscope.cpp:11