Vital
Loading...
Searching...
No Matches
wavetable_component_factory.cpp
Go to the documentation of this file.
1/*
2Summary:
3WavetableComponentFactory provides a centralized means to instantiate various WavetableComponents, both sources and modifiers, and to map between enumerated types, string names, and constructed objects. This makes it easier to integrate new components, handle component-specific UI or preset logic, and maintain a clean separation of concerns for creation and naming of WavetableComponents.
4 */
5
7#include "file_source.h"
9#include "phase_modifier.h"
10#include "shepard_tone_source.h"
11#include "slew_limit_modifier.h"
12#include "wave_frame.h"
13#include "wave_fold_modifier.h"
14#include "wave_line_source.h"
15#include "wave_source.h"
16#include "wave_warp_modifier.h"
18
20 // Creates a WavetableComponent instance based on the given enumerated type.
21 switch (type) {
22 case kWaveSource:
23 return new WaveSource();
24 case kLineSource:
25 return new WaveLineSource();
26 case kFileSource:
27 return new FileSource();
29 return new ShepardToneSource();
30 case kPhaseModifier:
31 return new PhaseModifier();
32 case kWaveWindow:
33 return new WaveWindowModifier();
35 return new FrequencyFilterModifier();
36 case kSlewLimiter:
37 return new SlewLimitModifier();
38 case kWaveFolder:
39 return new WaveFoldModifier();
40 case kWaveWarp:
41 return new WaveWarpModifier();
42 default:
43 VITAL_ASSERT(false);
44 return nullptr;
45 }
46}
47
49 // Creates a WavetableComponent instance from a string name.
50 if (type == "Wave Source")
51 return new WaveSource();
52 if (type == "Line Source")
53 return new WaveLineSource();
54 if (type == "Audio File Source")
55 return new FileSource();
56 if (type == "Shepard Tone Source")
57 return new ShepardToneSource();
58 if (type == "Phase Shift")
59 return new PhaseModifier();
60 if (type == "Wave Window")
61 return new WaveWindowModifier();
62 if (type == "Frequency Filter")
63 return new FrequencyFilterModifier();
64 if (type == "Slew Limiter")
65 return new SlewLimitModifier();
66 if (type == "Wave Folder")
67 return new WaveFoldModifier();
68 if (type == "Wave Warp")
69 return new WaveWarpModifier();
70
71 VITAL_ASSERT(false);
72 return nullptr;
73}
74
76 // Maps enumerated types to their human-readable names.
77 switch (type) {
78 case kWaveSource:
79 return "Wave Source";
80 case kLineSource:
81 return "Line Source";
82 case kFileSource:
83 return "Audio File Source";
85 return "Shepard Tone Source";
86 case kPhaseModifier:
87 return "Phase Shift";
88 case kWaveWindow:
89 return "Wave Window";
91 return "Frequency Filter";
92 case kSlewLimiter:
93 return "Slew Limiter";
94 case kWaveFolder:
95 return "Wave Folder";
96 case kWaveWarp:
97 return "Wave Warp";
98 default:
99 return "";
100 }
101}
A WavetableComponent that uses an external audio sample as its source.
Definition file_source.h:23
A WavetableComponent that applies frequency-domain filtering to a wavetable frame.
Definition frequency_filter_modifier.h:18
A WavetableComponent that modifies the phase of frequency components in a wavetable frame.
Definition phase_modifier.h:19
A WaveSource that constructs a special looped waveform reminiscent of a Shepard tone.
Definition shepard_tone_source.h:18
A WavetableComponent that applies slew-rate limiting to a wave’s time-domain signal.
Definition slew_limit_modifier.h:18
A WavetableComponent that applies a wave-folding transformation to a waveform.
Definition wave_fold_modifier.h:19
A WavetableComponent that generates waveforms from a series of line segments.
Definition wave_line_source.h:23
A WavetableComponent that acts as a direct source of waveforms.
Definition wave_source.h:25
A WavetableComponent that applies nonlinear horizontal and vertical warping to a waveform.
Definition wave_warp_modifier.h:24
A WavetableComponent that applies a windowing function to a waveform’s head and tail.
Definition wave_window_modifier.h:19
static WavetableComponent * createComponent(ComponentType type)
Creates a new WavetableComponent instance of a given enumerated type.
Definition wavetable_component_factory.cpp:19
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
@ kWaveFolder
Modifier that applies wave folding.
Definition wavetable_component_factory.h:40
@ kWaveWindow
Modifier that applies window functions to the wave.
Definition wavetable_component_factory.h:37
@ kWaveSource
A basic wave source.
Definition wavetable_component_factory.h:29
@ kFrequencyFilter
Modifier that filters frequency components.
Definition wavetable_component_factory.h:38
@ kPhaseModifier
Modifier that shifts phase.
Definition wavetable_component_factory.h:36
@ kFileSource
A file-based audio source.
Definition wavetable_component_factory.h:31
@ kWaveWarp
Modifier that warps the waveform.
Definition wavetable_component_factory.h:41
@ kLineSource
A line-based wave source.
Definition wavetable_component_factory.h:30
@ kShepardToneSource
Definition wavetable_component_factory.h:33
@ kSlewLimiter
Modifier that limits slew rate.
Definition wavetable_component_factory.h:39
static std::string getComponentName(ComponentType type)
Gets the human-readable name of a component from its enumerated type.
Definition wavetable_component_factory.cpp:75
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
#define VITAL_ASSERT(x)
Definition common.h:11