Repository navigation
Unity Quick Start
From an empty scene to a sound you trigger yourself, in about five minutes. You make one asset, add one component and write one short script. No device is needed.
flowchart LR
P["Step 1: a preset<br/>(the sound, as an asset)"] --> C["Step 2: an SFX Player<br/>(the component that plays it)"]
C --> S["Step 3: a script<br/>calls Play()"]
S --> H["You hear it"]
Before you start: the package is installed (Unity Install), and you are on Windows x64.
- In the Project window, right-click a folder: Create > SFX Forge > Preset (the same as Assets > Create > SFX Forge > Preset in the menu bar).
- An asset named
New SFXappears. Rename itLaser. A new preset holdsSfxPatch.Default, which is a laser. - Select it. The Inspector shows the sound the way the device's display does:

The Inspector of a preset. This one is the showcase's Jump on page OSC; yours says the name of your asset and SCI-FI FM. The picture is rendered by the package's tests, not photographed in the editor.
- Press the soft key PLAY (6 in the picture). You hear the laser through the editor's speakers.
- Drag a value tile (3) up or down, for example FREQ. The key HEAR CHANGES is lit at first, so the sound plays again a moment after each change (outside Play mode).
- Press MUTATE a few times for variations. UNDO or Ctrl+Z takes a change back.
- Not after a laser? Under TOOLS (8), on the tab NEW, click a kind: CHIME for a pickup, THUD or CLICK for a footstep. Every click gives another sound of that kind; UNDO takes it back (Unity Sound Design Tools).
A tile shows one value; a key is one of the buttons under the picture. Both words are in the Glossary.
Unity Presets And Patches explains every page and value.
-
GameObject > Create Empty. Name it
Sound. - With it selected, click Add Component and choose SFX Forge > SFX Player. Unity adds an Audio Source beside it, because the player needs one. Leave the Audio Source's AudioClip empty: the player keeps that source running itself.
- Drag your
Laserasset onto the player's Preset field. - Check that the scene has an Audio Listener. The default Main Camera has one.
To hear it without any code: tick Play On Enable on the SFX Player and press Play. The laser plays once when the scene starts. Untick it again before the next step.
- Create a C# script named
FirstSound.cswith this content:
using CatSplat.SfxForge;
using UnityEngine;
[RequireComponent(typeof(SfxPlayer))]
public class FirstSound : MonoBehaviour
{
SfxPlayer player;
void Start()
{
player = GetComponent<SfxPlayer>();
}
void OnGUI()
{
if (GUI.Button(new Rect(20, 20, 160, 40), "Laser")) player.Play();
if (GUI.Button(new Rect(20, 70, 160, 40), "Higher")) player.Play(1f, 7f);
if (GUI.Button(new Rect(20, 120, 160, 40), "Soft")) player.Play(0.4f);
}
}- Drag the script onto the
Soundobject. - Press Play. Three buttons appear in the Game view.
- Click Laser: the preset plays. Higher: the same sound, 7 semitones up. Soft: at velocity 0.4, so quieter.
Play(velocity, semitones, midiNote) takes all three as optional arguments:
| Argument | What it is |
|---|---|
velocity |
how hard the note is played, 0 to 1. Softer is quieter |
semitones |
moves the pitch up or down; 12 are an octave |
midiNote |
above 0, the sound plays as that note (69 is the A at 440 Hz) instead of at its own FREQ |
The Glossary has these words.
A sound is also just a value in code. SfxPatch.Create takes an engine and up to 25 numbers, each 0 to 127; the
ones you leave out come from a plain patch. The first ten, as the Inspector names them: FREQ, PITCH ENV, ENV TIME,
A, B, NOISE, CUTOFF, RESO, DECAY, CRUSH. Unity Presets And Patches
has the whole order.
// in: SfxPlayer player
// a fragment: put it where `player` is known, for example in OnGUI of the script above
SfxPatch coin = SfxPatch.Create(SfxEngine.UiBlip, 86, 64, 0, 26, 60, 0, 127, 0, 62, 0);
player.Play(coin); // no preset needed
player.Play(SfxPatch.Default); // the laserWhile the game is in Play mode, select the Laser asset and turn a value. A sound of that preset that is ringing
on the player takes the new values, and the next Play() uses them. That is how you tune a sound in place.
| Check | Why |
|---|---|
| Is there a warning "the native library (sfxforge) is not available"? | you are not on Windows x64. Nothing is synthesized there |
| Does the SFX Player have a preset? |
Play() without a preset does nothing |
Did the patch start from new SfxPatch()? |
all its values are 0, also level. Use SfxPatch.Create or SfxPatch.Default
|
Is Play called from another object's Awake? |
a player ignores Play until its own OnEnable has run, and while it is disabled. Call from Start or later |
| Is there an Audio Listener, and is the Game view not muted? | the player goes through Unity's audio like everything else |
The full list is in Unity Troubleshooting.
- Unity Concepts: what the preset, the patch and the player are
- Unity Choosing A Route: baked clip, live voice, held sound or music?
- Unity Presets And Patches: shape the sound
- Unity Music First Song: the same five minutes for music
SFX FORGE, firmware 1.7.2 · Home · Glossary · What Is Tested · the pages are kept in the repository's wiki/ folder: Editing This Wiki
Start
Device
- Quick Start
- Controls And Pages
- Make A Sound
- The Five Engines
- Make A Beat
- Recording
- Finer Grids
- Time Signatures
- Perform
- Song And Arrangement
- Layers And Intensity
- Automation
- Mixer And Effects
- The Stage
- Saving And Reset
- Cheat Sheet
Unity: first steps
- Install
- Quick Start
- Concepts
- Choosing A Route
- One Shots
- Live Voices
- Held Sounds
- Variations
- Presets And Patches
Unity: music
Unity: link and tools
Unity: in practice
- Recipes
- Recipes: Music
- Recipes: Link
- Showcase Walkthrough
- Copy The Showcase Pattern
- Troubleshooting
- Testing Your Audio
Unity: reference and extending
Internals
- Architecture Overview
- Repository Map
- Sound Engine
- Patch Format
- Song Format
- Link Protocol
- Firmware Internals
- Add A Page Or Key
- Add An Engine
- Add A Setting
- Building From Source
- Running The Tests
- Release Checklist
About this wiki