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:
GroupFields
Dynamicsvelocity_scale, velocity_floor, velocity_variance, accent_pattern (per-beat multipliers), downbeat_deemphasis
Timingswing_amount, timing_humanize_sec, quantize_grid_fraction, timing_offset_sec
Note shapingthin_probability (randomly drop soft notes), register_shift_semitones, force_articulation + articulation, fallback_gate_ratio
Timbrefilter_cutoff_mult, detune_cents_delta, stereo_width_override, noise_mix_delta, wobble_amount
Effectswant_reverb (+ room/wet/damping), want_chorus (+ rate/depth/wet), want_delay (+ time/feedback/wet), want_distortion (+ drive)
  • GenrePreset โ€” name, description, tempo_scale, a default_profile and optional bass_profile / percussion_profile (set_bass(), set_percussion()); profile_for(role) falls back to the default. GenrePresetPtr is shared_ptr<const GenrePreset>.

Applying a preset

  • apply_to_melody(melody, preset, role, instrument = nullptr, seed = 1) mutates a Melody deterministically (hash-based randomness from seed): optionally thins soft notes, shifts register, forces an articulation (only if the instrument supports it), and scales each note's expression by the profile's velocity scale, accent pattern and variance, clamped between velocity_floor and 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

FactoryNameDescriptiontempo_scale
presets::classical()ClassicalExpressive human timing, legato phrasing, hall reverb.1.0
presets::jazz()JazzSwung eighths, backbeat accents, loose human timing.1.0
presets::rock()RockStraight rhythm, punchy backbeat accents, driven guitars.1.0
presets::metal()MetalTight/mechanical timing, heavy distortion, tightened low end.1.05
presets::house()HouseQuantized four-on-the-floor groove, bright low end, light shuffle.1.04
presets::techno()TechnoPerfectly quantized, mechanical groove, driving and dark.1.08
presets::drum_and_bass()Drum & BassFast tempo, sub-register bass, shuffled breakbeat feel.1.35
presets::chiptune()ChiptuneBright, quantized, dry 8-bit-style character.1.0
presets::ambient()AmbientSparse, slow, wide, and reverberant.0.85
presets::touhou()TouhouBright, fast, driving fusion feel (melodic+rock elements).1.12
presets::funk()FunkSyncopated, dry, ghost-note-heavy groove that hits hard on beat one.1.0
presets::blues()BluesLoose 12-bar-style shuffle feel, warm light overdrive, relaxed tempo.0.95
presets::reggae()ReggaeOff-beat skank emphasis and a bass that drags behind the beat.0.92
presets::trance()TranceUplifting, quantized, bright and wide, with slow filter movement.1.06
presets::dubstep()DubstepHeavy sub-bass wobble, sparse/spacious percussion, slower half-time feel.0.78
presets::bossa_nova()Bossa NovaGentle syncopation, soft dynamics, nylon-guitar-and-hand-percussion feel.0.97
presets::hardcore()HardcoreVery fast, perfectly mechanical, distorted electronic aggression.1.45
presets::speedcore()SpeedcoreExtreme 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)