Skip to content

gingerbeardman/good-old-game-sound-generator

 
 

Repository files navigation

good-old-game-sound-generator (DEMO)

Generate sound effects and background music for good old-fashioned mini-games. Powered by magenta.js and jsfxr.

How to generate background music

  1. Open the DEMO page.

  2. (Optional) Input the base music for the generation in MML (Music Macro Language) at the bottom of the screen.

  3. Click the 'Generate' button.

How to use the generated music in your game

Known issue: Cannot play sound on some iOS devices.

  1. On the Demo page, click the 'Copy to clipboard' button to copy the MML JSON data to your clipboard.

  2. Load dist/ggg.umd.js. See a template html file for details.

  3. Call the ggg.playMml function with the JSON in the clipboard as the first argument.

Sample game

Sample code

T LASER source code

Functions

// Play music described in MML JSON data
function playMml(mmlData: MmlData, volume?: number): void;
// Stop music
function stopMml(): void;
// Play the sound effect
function playSoundEffect(
  type:
    | "coin"
    | "laser"
    | "explosion"
    | "powerUp"
    | "hit"
    | "jump"
    | "select"
    | "synth"
    | "tone"
    | "click"
    | "random",
  seed?: number,
  count?: number,
  volume?: number,
  freq?: number
): void;
// The update function needs to be called every
// certain amount of time (typically 60 times per second)
function update(): void;
// Initialize the library (baseRandomSeed represents
// the seed of the random number used to generate the sound effect)
function init(baseRandomSeed?: number, audioContext?: AudioContext): void;
// The startAudio function needs to be called from within
// the user operation event handler to enable audio playback in the browser.
function startAudio(): void;
// Set the tempo of the music
function setTempo(tempo?: number): void;
// Set the quantize timing of sound effects by the length of the note
function setQuantize(noteLength?: number): void;

About

Generate sound effects and background music for good old-fashioned mini-games

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • TypeScript 62.8%
  • JavaScript 34.7%
  • HTML 2.5%