Vital
Loading...
Searching...
No Matches
wave_fold_modifier.h
Go to the documentation of this file.
1/*
2Summary:
3WaveFoldModifier applies a nonlinear wave-folding effect to a wavetable’s time-domain waveform. By scaling and folding the waveform through sine and arcsine functions, it adds harmonic complexity and can create interesting timbral variations. Adjusting the fold boost parameter in keyframes and interpolating between them allows dynamic control over the amount of wave folding across the wavetable.
4 */
5
6#pragma once
7
8#include "JuceHeader.h"
10
20public:
29 public:
35
36 void copy(const WavetableKeyframe* keyframe) override;
37 void interpolate(const WavetableKeyframe* from_keyframe,
38 const WavetableKeyframe* to_keyframe, float t) override;
39 void render(vital::WaveFrame* wave_frame) override;
40 json stateToJson() override;
41 void jsonToState(json data) override;
42
49
57 void setWaveFoldBoost(float boost) { wave_fold_boost_ = boost; }
58
59 protected:
61
62 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WaveFoldModifierKeyframe)
63 };
64
69 virtual ~WaveFoldModifier() { }
70
71 WavetableKeyframe* createKeyframe(int position) override;
72 void render(vital::WaveFrame* wave_frame, float position) override;
74
81 WaveFoldModifierKeyframe* getKeyframe(int index);
82
83protected:
85
86 JUCE_DECLARE_NON_COPYABLE_WITH_LEAK_DETECTOR(WaveFoldModifier)
87};
A keyframe class that stores the fold boost parameter for wave-folding at a given position.
Definition wave_fold_modifier.h:28
void render(vital::WaveFrame *wave_frame) override
Renders the waveform of this keyframe into a WaveFrame.
Definition wave_fold_modifier.cpp:31
void copy(const WavetableKeyframe *keyframe) override
Copies the state from another keyframe of the same type.
Definition wave_fold_modifier.cpp:16
virtual ~WaveFoldModifierKeyframe()
Definition wave_fold_modifier.h:34
void setWaveFoldBoost(float boost)
Sets a new wave fold boost factor.
Definition wave_fold_modifier.h:57
json stateToJson() override
Serializes the state of this keyframe to a JSON object.
Definition wave_fold_modifier.cpp:45
WaveFoldModifierKeyframe()
Constructs a keyframe with a default wave fold boost value of 1.0.
Definition wave_fold_modifier.cpp:11
void jsonToState(json data) override
Restores the keyframe's state from a JSON object.
Definition wave_fold_modifier.cpp:51
float getWaveFoldBoost()
Gets the current wave fold boost factor.
Definition wave_fold_modifier.h:48
float wave_fold_boost_
The factor by which the wave is folded.
Definition wave_fold_modifier.h:60
void interpolate(const WavetableKeyframe *from_keyframe, const WavetableKeyframe *to_keyframe, float t) override
Linearly interpolates between two keyframes.
Definition wave_fold_modifier.cpp:21
A WavetableComponent that applies a wave-folding transformation to a waveform.
Definition wave_fold_modifier.h:19
WaveFoldModifier()
Constructs a WaveFoldModifier with no additional initialization.
Definition wave_fold_modifier.h:68
WaveFoldModifierKeyframe * getKeyframe(int index)
Retrieves a WaveFoldModifierKeyframe at a given index.
Definition wave_fold_modifier.cpp:73
WavetableKeyframe * createKeyframe(int position) override
Creates a new keyframe at a given position.
Definition wave_fold_modifier.cpp:56
WavetableComponentFactory::ComponentType getType() override
Returns the type of this WavetableComponent.
Definition wave_fold_modifier.cpp:69
void render(vital::WaveFrame *wave_frame, float position) override
Renders the waveform at a given position into a WaveFrame.
Definition wave_fold_modifier.cpp:63
WaveFoldModifierKeyframe compute_frame_
A keyframe for intermediate computations.
Definition wave_fold_modifier.h:84
virtual ~WaveFoldModifier()
Definition wave_fold_modifier.h:69
ComponentType
Enumerates all known WavetableComponents, including sources and modifiers.
Definition wavetable_component_factory.h:28
A base class representing a component in a wavetable synthesis chain.
Definition wavetable_component.h:32
Represents a single state of a waveform at a specific position in a wavetable.
Definition wavetable_keyframe.h:35
Represents a single frame of a wavetable, containing both time-domain and frequency-domain data.
Definition wave_frame.h:16
nlohmann::json json
Definition line_generator.h:7