Show / Hide Table of Contents

How to: Compose your first song

Create a song

  1. Open the music composer window. Go to "Window > RetroKit > Music Composer".
  2. Click "New" beside the song selection box.
  3. Create/edit as many patterns as you need.
  4. Create/edit as many tracks as you need.
  5. Click "Play Song" to hear the result.
  6. Repeat steps 3-5 until you're happy with the result.

Create a pattern

Whenever you create a new song, the first pattern is created automatically, so for the first pattern you can skip step 1.

  1. Click "New" beside the pattern selection box.
  2. Add the notes you want inside the pattern composer.
    • Left-click in the pattern composer to add note to your pattern.
    • Right-click on a note in the pattern composer to delete it.
  3. Click "Play Pattern" to hear what the pattern sounds like.
  4. Repeat steps 2-4 until you're happy with the result.

Create a track

Whenever you create a new song, the first track is created automatically, so for the first track you can skip step 1.

  1. Click "New Track".
  2. Select the pattern you want to add to the track.
  3. Add the pattern as many times as you want to the track.
    • Left-click in the track composer to add the active pattern to the track.
    • Right-click on a pattern block in the track composer to remove it from the track.
    • Pattern blocks cannot overlap in a single track. If you try to add a pattern to the track but it doesn't appear, that's likely because it would overlap with another pattern block.
  4. Click "Play" beside the track composer to hear the result for that track.
  5. Repeat steps 2-4 until you're happy with the result.

Using the song in a scene

RetroKit generates sample set assets for both music and sound effects. By default, these music sample sets are stored in Assets/RetroKit/Resources/Music.

You can use these sample sets in a number 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 and 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 usual.

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 music or sound 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 "Happy_Song" like this:

AudioPlayer.PlayMusic("Happy_Song");

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.PlayMusic(Songs.HappySong);

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.

In order to stop playing a song or all songs, you can use the following code.

AudioPlayer.StopMusic("Happy_Song");

AudioPlayer.StopMusic(Songs.HappySong);

AudioPlayer.StopAllMusic();

See also: Sample sets
See also: Music Composer

Back to top Generated by DocFX