mwg API
    Preparing search index...

    Function normalizeScene

    Generated game music: a scene described as data (mood, tension, key, seed, length, voices) becomes a playable MIDI file, the same one every time. Renderer-free; it builds on core (the seeded generator) and audio (the MIDI file shape and the seed mixing of data sound effects), and what it makes plays through renderMidiToBuffer, a registered engine, or AdaptiveMusic for bar-aligned switches between game states.

    • Makes a scene safe to compose from whatever a save, a share link or a settings screen hands over: unknown moods become calm, every number is clamped and rounded to its range.

      Parameters

      Returns MusicScene

      import { normalizeScene } from '@datamoc/mwg/music';

      console.log(normalizeScene({ id: 'cave', mood: 'tense', tension: 4, voices: 99 })); // tension 1, voices 8