Music layer (wauvio/ext)
Genre system
Headers ext/genre/genre_types.hpp, genre_apply.hpp, genre_presets.hpp; namespace wauvio::music::genre. A genre preset is a bundle of per-role style rules that rewrite a melody and restyle an instrument.
See it in action: Genre styling
Types
Role { Melodic, Bass, Percussion }.RoleProfileโ the style rules for one role:
| Group | Fields |
|---|---|
| Dynamics | velocity_scale, velocity_floor, velocity_variance, accent_pattern (per-beat multipliers), downbeat_deemphasis |
| Timing | swing_amount, timing_humanize_sec, quantize_grid_fraction, timing_offset_sec |
| Note shaping | thin_probability (randomly drop soft notes), register_shift_semitones, force_articulation + articulation, fallback_gate_ratio |
| Timbre | filter_cutoff_mult, detune_cents_delta, stereo_width_override, noise_mix_delta, wobble_amount |
| Effects | want_reverb (+ room/wet/damping), want_chorus (+ rate/depth/wet), want_delay (+ time/feedback/wet), want_distortion (+ drive) |
GenrePresetโname,description,tempo_scale, adefault_profileand optionalbass_profile/percussion_profile(set_bass(),set_percussion());profile_for(role)falls back to the default.GenrePresetPtrisshared_ptr<const GenrePreset>.
Applying a preset
apply_to_melody(melody, preset, role, instrument = nullptr, seed = 1)mutates aMelodydeterministically (hash-based randomness fromseed): optionally thins soft notes, shifts register, forces an articulation (only if the instrument supports it), and scales each note'sexpressionby the profile's velocity scale, accent pattern and variance, clamped betweenvelocity_floorand 1. Timing fields (swing, humanize, quantize, offset) are not applied here; they are consumed by the MIDI layer โ see MIDI genre.style_instrument(instrument, preset, role)applies the role's timbre and effect wants;capture_style_baseline()/restore_style_baseline()snapshot and restore the instrument's gain, pan, effects and recipe so a preset can be undone.
Built-in presets
| Factory | Name | Description | tempo_scale |
|---|---|---|---|
presets::classical() | Classical | Expressive human timing, legato phrasing, hall reverb. | 1.0 |
presets::jazz() | Jazz | Swung eighths, backbeat accents, loose human timing. | 1.0 |
presets::rock() | Rock | Straight rhythm, punchy backbeat accents, driven guitars. | 1.0 |
presets::metal() | Metal | Tight/mechanical timing, heavy distortion, tightened low end. | 1.05 |
presets::house() | House | Quantized four-on-the-floor groove, bright low end, light shuffle. | 1.04 |
presets::techno() | Techno | Perfectly quantized, mechanical groove, driving and dark. | 1.08 |
presets::drum_and_bass() | Drum & Bass | Fast tempo, sub-register bass, shuffled breakbeat feel. | 1.35 |
presets::chiptune() | Chiptune | Bright, quantized, dry 8-bit-style character. | 1.0 |
presets::ambient() | Ambient | Sparse, slow, wide, and reverberant. | 0.85 |
presets::touhou() | Touhou | Bright, fast, driving fusion feel (melodic+rock elements). | 1.12 |
presets::funk() | Funk | Syncopated, dry, ghost-note-heavy groove that hits hard on beat one. | 1.0 |
presets::blues() | Blues | Loose 12-bar-style shuffle feel, warm light overdrive, relaxed tempo. | 0.95 |
presets::reggae() | Reggae | Off-beat skank emphasis and a bass that drags behind the beat. | 0.92 |
presets::trance() | Trance | Uplifting, quantized, bright and wide, with slow filter movement. | 1.06 |
presets::dubstep() | Dubstep | Heavy sub-bass wobble, sparse/spacious percussion, slower half-time feel. | 0.78 |
presets::bossa_nova() | Bossa Nova | Gentle syncopation, soft dynamics, nylon-guitar-and-hand-percussion feel. | 0.97 |
presets::hardcore() | Hardcore | Very fast, perfectly mechanical, distorted electronic aggression. | 1.45 |
presets::speedcore() | Speedcore | Extreme tempo, hyper-mechanical quantization, maximal distortion. | 2.1 |
Full API listing
wauvio/ext/genre/genre_types.hpp
wauvio::music::genre::enum class Role
enum class Role { Melodic, Bass, Percussion };
wauvio::music::genre::struct RoleProfile
struct RoleProfile
double velocity_scale = 1.0;
double velocity_floor = 0.0;
double velocity_variance = 0.0;
std::vector<double> accent_pattern;
double swing_amount = 0.0;
double timing_humanize_sec = 0.0;
double quantize_grid_fraction = 0.0;
double timing_offset_sec = 0.0;
double downbeat_deemphasis = 0.0;
double thin_probability = 0.0;
int register_shift_semitones = 0;
bool force_articulation = false;
wauvio::music::Articulation articulation = wauvio::music::Articulation::Sustain;
double fallback_gate_ratio = 1.0;
double filter_cutoff_mult = 1.0;
double detune_cents_delta = 0.0;
double stereo_width_override = -1.0;
double noise_mix_delta = 0.0;
double wobble_amount = 0.0;
bool want_reverb = false;
float reverb_room = 0.5f, reverb_wet = 0.25f, reverb_damping = 0.5f;
bool want_chorus = false;
double chorus_rate_hz = 0.5, chorus_depth_ms = 1.5;
float chorus_wet = 0.3f;
bool want_delay = false;
double delay_time_ms = 250.0;
float delay_feedback = 0.3f, delay_wet = 0.25f;
bool want_distortion = false;
float distortion_drive = 2.0f;
wauvio::music::genre::class GenrePreset
class GenrePreset
public:
std::string name;
std::string description;
double tempo_scale = 1.0;
RoleProfile default_profile;
RoleProfile bass_profile;
bool has_bass_profile = false;
RoleProfile percussion_profile;
bool has_percussion_profile = false;
const RoleProfile& profile_for(Role role) const noexcept
GenrePreset& set_bass(RoleProfile p) { bass_profile = std::move(p); has_bass_profile = true; return *this; }
GenrePreset& set_percussion(RoleProfile p) { percussion_profile = std::move(p); has_percussion_profile = true; return *this; }
using GenrePresetPtr = std::shared_ptr<const GenrePreset>;
inline uint64_t splitmix64(uint64_t x) noexcept
inline uint64_t note_hash(uint64_t seed, double t, int midi_note, size_t index, uint64_t salt) noexcept
inline double unit(uint64_t h) noexcept
inline double signed_unit(uint64_t h) noexcept { return unit(h) * 2.0 - 1.0; }
inline int clampi(int v, int lo, int hi) noexcept { return std::max(lo, std::min(hi, v)); }
inline double clampd(double v, double lo, double hi) noexcept { return std::max(lo, std::min(hi, v)); }
inline double accent_multiplier(const std::vector<double>& pattern, int beat_index)
wauvio/ext/genre/genre_apply.hpp
wauvio::music::genre::Free functions, constants and aliases
inline void apply_to_melody(wauvio::music::Melody& melody, const GenrePreset& preset, Role role,
const wauvio::music::Instrument* instrument = nullptr, uint64_t seed = 1)
wauvio::music::genre::struct InstrumentStyleBaseline
struct InstrumentStyleBaseline
float gain = 1.0f, pan = 0.0f;
bool reverb_on = false; wauvio::fx::basic::Reverb reverb_fx;
bool chorus_on = false; wauvio::fx::basic::Chorus chorus_fx;
bool delay_on = false; wauvio::fx::basic::DelayLine delay_fx;
bool eq_on = false; wauvio::filter::ParametricEQ eq_fx;
bool distortion_on = false; float distortion_drive = 2.0f;
bool has_recipe = false;
wauvio::music::TimbreRecipe recipe;
inline InstrumentStyleBaseline capture_style_baseline(const wauvio::music::Instrument& instrument)
inline void restore_style_baseline(wauvio::music::Instrument& instrument, const InstrumentStyleBaseline& b)
inline void style_instrument(wauvio::music::Instrument& instrument, const GenrePreset& preset, Role role)