Understanding sound types in Stencyl

Although the available sound-control instruction blocks will play any sound that we have imported, it's important to understand that as far as Stencyl is concerned, there are two distinct types of audio that we can use in our game:

  • Sound effects
  • Music (soundtracks)

Although both of these types of audio start off life as files on our hard drive, once they are imported into Stencyl, they are treated differently for technical reasons. The sound effect type of audio is designed to be used for short, snappy sounds, such as the jumping and fruit-pickup sound effects that we have already implemented, whereas the music (soundtrack) type of audio is intended for playing back longer sound files. Sound effects are loaded into and stored in the computer's memory in order to reduce latency— delays that can occur when playing the effect. It would not be a good experience for players of our game if a sound effect was played shortly after it was required; we need it to be played instantly! In contrast, music audio is streamed , that is, the audio is loaded into memory in smaller parts as required.

Audio file requirements

Stencyl currently supports two different types of audio files:

  • MP3
  • OGG

The MP3 file format is required when creating games for Flash, HTML5, Android, and iOS. Stencyl manages any format conversions that are required for these target platforms, but we do need to ensure that the MP3 file is encoded, or configured correctly, before we import it into Stencyl. While most MP3 files will work in Stencyl without us having to modify them, not all MP3 files are encoded in the same way, which can cause problems when compiling our game. If unexpected errors are displayed when a game is being compiled by Stencyl, or if sounds simply fail to play as expected in a game, ensure that the MP3 files used in the game conform to the following requirements:

  • Frequency of 44.1 kHz
  • 16-bit constant bitrate (as opposed to VBR, which is a variable bitrate)
  • No metadata

OGG is an alternative audio file format that Stencyl requires when targeting desktop platforms (MS Windows, Mac OS X, and Linux). There are many utilities available for converting MP3 and other audio formats to OGG files, including free ones.

While this is a lot of technical information to consider, the good news is that many MP3 files work just fine in Stencyl! For further information about audio requirements, refer to the Stencyl help pages relating to sounds at www.stencyl.com/help.

Note

Refer to the section entitled, Third-party tools, in Appendix, Planning, Resources & Legal Issues, for additional resources relating to working with audio in Stencyl.

Looping music

It's useful to note that looping music, such as the soundtrack in our game, will continue to loop and play even when a different scene is loaded. This means that we do not have to tell each scene to play our soundtrack; it will continuously loop and play automatically. If we want to stop the music when a scene is over, we must implement those instructions ourselves; perhaps we would fade the soundtrack out in that scenario.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.144.250.153