summaryrefslogtreecommitdiff
path: root/src/audio/spectral_brush.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/audio/spectral_brush.h')
-rw-r--r--src/audio/spectral_brush.h56
1 files changed, 23 insertions, 33 deletions
diff --git a/src/audio/spectral_brush.h b/src/audio/spectral_brush.h
index 3125f35..be27bbb 100644
--- a/src/audio/spectral_brush.h
+++ b/src/audio/spectral_brush.h
@@ -1,6 +1,7 @@
// This file is part of the 64k demo project.
// It implements the "Spectral Brush" primitive for procedural audio generation.
-// Spectral brushes trace Bezier curves through spectrograms with vertical profiles.
+// Spectral brushes trace Bezier curves through spectrograms with vertical
+// profiles.
#pragma once
@@ -8,9 +9,9 @@
// Profile types for vertical distribution around central Bezier curve
enum ProfileType {
- PROFILE_GAUSSIAN = 0, // Smooth harmonic falloff
- PROFILE_DECAYING_SINUSOID = 1, // Resonant/metallic texture
- PROFILE_NOISE = 2 // Random texture/grit
+ PROFILE_GAUSSIAN = 0, // Smooth harmonic falloff
+ PROFILE_DECAYING_SINUSOID = 1, // Resonant/metallic texture
+ PROFILE_NOISE = 2 // Random texture/grit
};
// Evaluate linear Bezier interpolation at given frame
@@ -18,11 +19,11 @@ enum ProfileType {
// control_values: Array of values at control points (freq_hz or amplitude)
// n_points: Number of control points
// frame: Frame number to evaluate at
-// Returns: Interpolated value at frame (linearly interpolated between control points)
+// Returns: Interpolated value at frame (linearly interpolated between control
+// points)
float evaluate_bezier_linear(const float* control_frames,
- const float* control_values,
- int n_points,
- float frame);
+ const float* control_values, int n_points,
+ float frame);
// Draw a spectral brush stroke onto a spectrogram
// Traces a Bezier curve through time-frequency space with a vertical profile
@@ -34,32 +35,24 @@ float evaluate_bezier_linear(const float* control_frames,
// control_amps: Amplitude values at control points (0.0-1.0 typical)
// n_control_points: Number of control points (minimum 2 for a curve)
// profile_type: Type of vertical profile to apply
-// profile_param1: First parameter (sigma for Gaussian, decay for sinusoid, amplitude for noise)
-// profile_param2: Second parameter (unused for Gaussian, frequency for sinusoid, seed for noise)
-void draw_bezier_curve(float* spectrogram,
- int dct_size,
- int num_frames,
+// profile_param1: First parameter (sigma for Gaussian, decay for sinusoid,
+// amplitude for noise) profile_param2: Second parameter (unused for Gaussian,
+// frequency for sinusoid, seed for noise)
+void draw_bezier_curve(float* spectrogram, int dct_size, int num_frames,
const float* control_frames,
- const float* control_freqs_hz,
- const float* control_amps,
- int n_control_points,
- ProfileType profile_type,
- float profile_param1,
- float profile_param2 = 0.0f);
+ const float* control_freqs_hz, const float* control_amps,
+ int n_control_points, ProfileType profile_type,
+ float profile_param1, float profile_param2 = 0.0f);
// Additive variant of draw_bezier_curve (adds to existing spectrogram content)
// Use for compositing multiple profiles (e.g., Gaussian + Noise)
// Parameters same as draw_bezier_curve()
-void draw_bezier_curve_add(float* spectrogram,
- int dct_size,
- int num_frames,
- const float* control_frames,
- const float* control_freqs_hz,
- const float* control_amps,
- int n_control_points,
- ProfileType profile_type,
- float profile_param1,
- float profile_param2 = 0.0f);
+void draw_bezier_curve_add(float* spectrogram, int dct_size, int num_frames,
+ const float* control_frames,
+ const float* control_freqs_hz,
+ const float* control_amps, int n_control_points,
+ ProfileType profile_type, float profile_param1,
+ float profile_param2 = 0.0f);
// Evaluate vertical profile at given distance from central curve
// type: Profile type (Gaussian, Decaying Sinusoid, Noise)
@@ -67,9 +60,7 @@ void draw_bezier_curve_add(float* spectrogram,
// param1: First profile parameter
// param2: Second profile parameter
// Returns: Profile amplitude at given distance (0.0-1.0 range typically)
-float evaluate_profile(ProfileType type,
- float distance,
- float param1,
+float evaluate_profile(ProfileType type, float distance, float param1,
float param2);
// Home-brew deterministic RNG for noise profile
@@ -77,4 +68,3 @@ float evaluate_profile(ProfileType type,
// seed: Input seed value
// Returns: Pseudo-random uint32_t value
uint32_t spectral_brush_rand(uint32_t seed);
-