libpromeki main
PROfessional MEdia toolKIt
 
Loading...
Searching...
No Matches
testpatternnode.h
Go to the documentation of this file.
1
8#pragma once
9
18
20
40class TestPatternNode : public MediaNode {
41 PROMEKI_OBJECT(TestPatternNode, MediaNode)
42 public:
57
64
70
73
74 // ---- Video configuration ----
75
80 void setPattern(Pattern p) { _pattern = p; return; }
81
83 Pattern pattern() const { return _pattern; }
84
89 void setVideoDesc(const VideoDesc &desc) { _videoDesc = desc; return; }
90
92 const VideoDesc &videoDesc() const { return _videoDesc; }
93
101 _solidR = r; _solidG = g; _solidB = b;
102 return;
103 }
104
105 // ---- Motion ----
106
112 void setMotion(double speed) { _motion = speed; return; }
113
115 double motion() const { return _motion; }
116
117 // ---- Timecode ----
118
121
123 const TimecodeGenerator &timecodeGenerator() const { return _tcGen; }
124
129 void setStartTimecode(const Timecode &tc) { _tcGen.setTimecode(tc); return; }
130
135 void setDropFrame(bool df) { _tcGen.setDropFrame(df); return; }
136
138 Timecode currentTimecode() const { return _tcGen.timecode(); }
139
141 uint64_t frameCount() const { return _frameCount; }
142
143 // ---- Audio ----
144
149 void setAudioDesc(const AudioDesc &desc) { _audioDesc = desc; return; }
150
152 const AudioDesc &audioDesc() const { return _audioDesc; }
153
158 void setAudioEnabled(bool enable) { _audioEnabled = enable; return; }
159
161 bool audioEnabled() const { return _audioEnabled; }
162
167 void setAudioMode(AudioMode mode) { _audioMode = mode; return; }
168
170 AudioMode audioMode() const { return _audioMode; }
171
178
183 void setToneFrequency(double hz) { _toneFreq = hz; return; }
184
189 void setToneAmplitude(double amplitude) { _toneAmplitude = amplitude; return; }
190
195 void setLtcLevel(float level) { _ltcLevel = level; return; }
196
201 void setLtcChannel(int chan) { _ltcChannel = chan; return; }
202
203 // ---- Lifecycle overrides ----
204
205 Error configure() override;
206 Error start() override;
207 void process() override;
208 void stop() override;
209
210 // ---- Extended stats ----
211
213
214 private:
215 // Video config
216 Pattern _pattern = ColorBars;
217 VideoDesc _videoDesc;
218 uint16_t _solidR = 0;
219 uint16_t _solidG = 0;
220 uint16_t _solidB = 0;
221 double _motion = 0.0;
222 double _motionOffset = 0.0;
223
224 // Timecode
225 TimecodeGenerator _tcGen;
226 uint64_t _frameCount = 0;
227
228 // Audio config
229 AudioDesc _audioDesc;
230 bool _audioEnabled = true;
231 AudioMode _audioMode = Tone;
232 double _toneFreq = 1000.0;
233 double _toneAmplitude = 0.5;
234 float _ltcLevel = 0.5f;
235 int _ltcChannel = 0;
236 List<AudioGen::Config> _channelConfigs;
237
238 // Runtime state
239 AudioGen *_audioGen = nullptr;
240 LtcEncoder *_ltcEncoder = nullptr;
241 ImageDesc _imageDesc;
242 size_t _samplesPerFrame = 0;
243
244 // Pattern rendering
245 void renderPattern(Image &img, double motionOffset);
246 void renderColorBars(Image &img, double offset, bool full);
247 void renderRamp(Image &img, double offset);
248 void renderGrid(Image &img, double offset);
249 void renderCrosshatch(Image &img, double offset);
250 void renderCheckerboard(Image &img, double offset);
251 void renderZonePlate(Image &img, double phase);
252 void renderNoise(Image &img);
253 void renderSolid(Image &img, uint16_t r, uint16_t g, uint16_t b);
254};
255
Describes an audio format including sample type, rate, and channel count.
Definition audiodesc.h:28
Audio signal generator for producing test tones and silence.
Definition audiogen.h:22
Lightweight error code wrapper for the promeki library.
Definition error.h:39
Describes the format and layout of a single image.
Definition imagedesc.h:33
Raster image with pixel format, planes, and metadata.
Definition image.h:48
Dynamic array container wrapping std::vector.
Definition list.h:40
Encodes timecode values into LTC (Linear Timecode) audio samples.
Definition ltcencoder.h:35
Base class for all pipeline processing nodes.
Definition medianode.h:81
Base object for promeki.
Definition objectbase.h:129
ObjectBase * parent() const
Returns the parent object, if one. nullptr if none.
Definition objectbase.h:258
Source node that generates video and audio test patterns.
Definition testpatternnode.h:40
void setToneAmplitude(double amplitude)
Sets the amplitude for all tone channels.
Definition testpatternnode.h:189
virtual ~TestPatternNode()
Destructor.
AudioMode audioMode() const
Returns the current audio mode.
Definition testpatternnode.h:170
TimecodeGenerator & timecodeGenerator()
Returns a mutable reference to the internal timecode generator.
Definition testpatternnode.h:120
void setStartTimecode(const Timecode &tc)
Sets the starting timecode.
Definition testpatternnode.h:129
void setLtcLevel(float level)
Sets the LTC output amplitude.
Definition testpatternnode.h:195
void setVideoDesc(const VideoDesc &desc)
Sets the video description (frame rate, resolution, pixel format).
Definition testpatternnode.h:89
TestPatternNode(ObjectBase *parent=nullptr)
Constructs a TestPatternNode.
void process() override
Processes one cycle of data.
void setToneFrequency(double hz)
Sets all channels to a sine tone at the given frequency.
Definition testpatternnode.h:183
void stop() override
Stops processing.
void setPattern(Pattern p)
Sets the video test pattern.
Definition testpatternnode.h:80
const AudioDesc & audioDesc() const
Returns the audio description.
Definition testpatternnode.h:152
Map< String, Variant > extendedStats() const override
Returns additional node-specific statistics.
Pattern
Video test pattern type.
Definition testpatternnode.h:44
@ Black
Solid black.
Definition testpatternnode.h:53
@ Ramp
Luminance gradient ramp.
Definition testpatternnode.h:47
@ Noise
Random pixel noise.
Definition testpatternnode.h:54
@ Crosshatch
Diagonal crosshatch lines.
Definition testpatternnode.h:49
@ ZonePlate
Circular zone plate.
Definition testpatternnode.h:55
@ White
Solid white.
Definition testpatternnode.h:52
@ Checkerboard
Alternating black/white squares.
Definition testpatternnode.h:50
@ ColorBars75
SMPTE 75% color bars.
Definition testpatternnode.h:46
@ ColorBars
SMPTE 100% color bars.
Definition testpatternnode.h:45
@ SolidColor
Solid fill with configured color.
Definition testpatternnode.h:51
@ Grid
White grid lines on black.
Definition testpatternnode.h:48
void setSolidColor(uint16_t r, uint16_t g, uint16_t b)
Sets the solid color for SolidColor pattern.
Definition testpatternnode.h:100
double motion() const
Returns the motion speed.
Definition testpatternnode.h:115
void setAudioEnabled(bool enable)
Enables or disables audio generation.
Definition testpatternnode.h:158
Error configure() override
Validates ports and allocates resources.
AudioMode
Audio generation mode.
Definition testpatternnode.h:59
@ Silence
Silence.
Definition testpatternnode.h:61
@ LTC
LTC timecode audio.
Definition testpatternnode.h:62
@ Tone
Sine tone (configurable frequency).
Definition testpatternnode.h:60
uint64_t frameCount() const
Returns the total number of frames generated.
Definition testpatternnode.h:141
void setAudioDesc(const AudioDesc &desc)
Sets the audio description.
Definition testpatternnode.h:149
void setChannelConfig(size_t chan, AudioGen::Config config)
Sets per-channel audio configuration (Tone mode).
void setLtcChannel(int chan)
Sets which channel carries LTC.
Definition testpatternnode.h:201
Pattern pattern() const
Returns the current pattern.
Definition testpatternnode.h:83
void setDropFrame(bool df)
Enables or disables drop-frame timecode.
Definition testpatternnode.h:135
Timecode currentTimecode() const
Returns the current timecode value.
Definition testpatternnode.h:138
bool audioEnabled() const
Returns true if audio generation is enabled.
Definition testpatternnode.h:161
const VideoDesc & videoDesc() const
Returns the video description.
Definition testpatternnode.h:92
void setMotion(double speed)
Sets the pattern motion speed.
Definition testpatternnode.h:112
void setAudioMode(AudioMode mode)
Sets the audio generation mode.
Definition testpatternnode.h:167
Error start() override
Begins processing.
const TimecodeGenerator & timecodeGenerator() const
Returns a const reference to the internal timecode generator.
Definition testpatternnode.h:123
General-purpose timecode generator.
Definition timecodegenerator.h:37
void setDropFrame(bool df)
Enables or disables drop-frame counting.
Timecode timecode() const
Returns the current timecode value.
Definition timecodegenerator.h:106
void setTimecode(const Timecode &tc)
Sets the current timecode value.
Class for holding and manipulating timecode.
Definition timecode.h:45
Describes a video format including frame rate, image layers, audio channels, and metadata.
Definition videodesc.h:25
#define PROMEKI_NAMESPACE_BEGIN
Starts a promeki namespace block.
Definition namespace.h:14
#define PROMEKI_NAMESPACE_END
Ends a promeki namespace block.
Definition namespace.h:19
Per-channel configuration for the audio generator.
Definition audiogen.h:31