How to: Create your first sound effect
Creating a sound effect
A sound effect is made up of a series of tones. A tone consists of a pitch, volume and a duration.
Open the "Sound Effect Editor" window. ("Window > RetroKit > Sound Effect Editor")
Click "New".
Set the pitches and volumes for the tones you want.
In the Sound Composer (black part of the window) you can see a small gray bar, that represents each tone. By Left-clicking above or on the bar adjusts the pitch of that tone.
Right-click to adjust the volume for that tone.
Pick the sample provider you want, to change the "instrument" of the sound effect. By default "Pulse" is selected.
(Optional) Add or remove tones by changing the "Number of tones".
(Optional) Change the "Tone duration (ms)" to speed up or slow down the sound.
Press play to hear a preview of the sound effect you created.
Use sound effects in a scene
RetroKit generates sample set assets for both sound effects and music. By default, the sample sets for sound effects are stored in Assets/RetroKit/Resources/Sound Effects.
You can use these sample sets in a couple of ways.
1. Use the Sample Set Audio Source component
The easiest way to use this component is to simply select the sample set you want in your project window and then drag it onto the hierarchy window.
This will either create a new game object and add the Audio Source and Sample Set Audio Source components to it or add those components to an existing game object.
You can then use the Audio Source component as normal.
2. Use RetroKit's Audio Player
To use the Audio Player, first you need to add it to the scene. Right-click in the hierarchy window and select "RetroKit > Audio Player".
This method is useful to assign playing of sound or music to a UnityEvent. (When a button is clicked, for example.)
You could pass the Audio Player to a custom script to use it there, but in that case it's probably easier to use the 3rd method.
3. Use a script
You can play audio from a script by calling the AudioPlayer class. For example, you could play a sound effect called "Plok" like this:
AudioPlayer.PlaySfx("Plok");
However, RetroKit provides a safer way to do this however, by generating constants for all sound effects. Here's the same call, but using the constant:
AudioPlayer.PlaySfx(SoundEffects.Plok);
The main advantage of using the constant is that your code will fail at compile time instead of during runtime, if you either deleted, renamed or simply misspelled the sound effect.
See also: Sample sets
See also: Sound Effect Editor