Playing Sounds & Music

by Jon (Updated on 2014-02-20)

Sound is a fundamental aspect of almost any game. This section covers the basics of importing music, playing it back and some interesting tidbits that may not be obvious.


  • Importing Sounds
  • Example: Background Music
  • Accepted Formats
  • Music vs. Sound Effects
  • Playing Sounds
  • Channels
  • MP3 Licensing (Not an Issue!)
  • Known Issues
  • The Future
  • Challenge: Zelda-Style Battle Music
  • Challenge: Smooth Looping


How to: Importing Sounds & Music

1) Import music into the Sound Editor by going to File > Create New > Sound.

2) Give it a name.

3) Click the following box to pick and import.

Tip: Alternatively, you can just drag and drop the sound in. This is quicker for some, and you don’t even need to have the Sound Editor opened to do this.

Example: Looping Background Music

Looping "background" music takes just 1 block to do.

Make a Scene Behavior out of this, or stick this directly into the "Events" for a scene.

Note: There's a flaw in this approach. Think about what happens when you re-enter this scene... That isn't desirable, is it?

Later in this article, we cover all the playback blocks available to you.


Accepted Formats

Starting with Stencyl 3, Stencyl accepts MP3s and OGGs. 

Note: We recommend Audacity for exporting music. It’s free.

For Flash games, the MP3s are used. For mobile and desktop games, OGGs are used. If you're publishing your game to both categories, you'll need to import in both formats.

If possible, import MP3’s in the following format.

  • 44.1 KHz (versus 22 or 11)
  • 16-bit
  • Constant bitrate (versus VBR)
  • No metadata

If your game unexpectedly does not export your game to Flash, it’s likely that sounds are the culprit. Post your issue to the forums and generate logs. (TODO: Take this note out and tell users how to solve it on their own.)

Why can't Stencyl standardize on just one format?

Due to limitations in our underlying technology (OpenFL), we are unable to standardize on one format. Flash playback of OGG music is not available at this time.

Music vs. Sound Effects

You may have noticed the following dropdown inside the Sound Editor. What does it mean?

Music is streamed (like viewing a YouTube video) since it’s too large to fit into memory. This is best for background music. This incurs a small performance penalty on mobile devices.

Sound effects are loaded into memory to reduce latency in playback. This is better for short clips that need to be played immediately but consumes memory, particularly on mobile devices.

How to Play Sounds & Music

All sound-related blocks are conveniently located under the Sound category.

Play = Plays to the end once, then stops
Loop = Plays to the end and then repeats

Volume ranges between 0% and 100%, inclusive.

Note: If you’d like to pause and resume a sound, skip down to the “Channels” section.
A Common Mistake: Looping music does not stop upon switching scenes. A common mistake, however, is to attach a “Background Music” behavior to every scene, causing the music to restart each time you enter a new “room” or "stack up." How would you solve this?

One approach is to create a blank, starting scene prior to the first level which loops the music.



Suppose that you’re playing Zelda. The regular tune plays, but when you approach an enemy, and the music switches over to the battle music. Once you defeat the enemy, the regular tune picks up where it left off.

Channels are a simple way to refer back to a playback instance of sounds, so that you can control their volume and pause/resume them in the future.

Channels are referred to by number, starting at index 0, ending at index 31.

32 channels are available in total.

Note: When you play a sound/music without specifying a channel, Stencyl picks the next available channel starting from 0. If none are available, nothing happens.

MP3 Licensing (Not an Issue)

On occasion, we get questions about MP3 Licensing. In short, there's absolutely nothing to worry about.

For Flash games, licensing is already handled by Adobe (the creator of Flash), and as a game developer, you do not have to worry about licensing for your Flash game.

For desktop and mobile games, we only work with OGG sounds, so you are in the clear.

The Future

We'd like to standardize on a single music format (OGG) and would like to support sequenced formats such as MIDI and tracker music (XM, IT).

On top of that, we’d like to add more control over playback, such as panning, altering pitch, seeking to a certain point in a clip and more.


Known Issues (as of Stencyl 3.0)

  • On the Android target, playing sounds may be delayed by a quarter to half second on a small subset of devices, including the Galaxy S4. This is due to a bug in the underlying technology. We hope that this will be fixed in the future.


  • Music = Streamed, Sound Effects = Loaded into Memory
  • Channels let you control playback. They have little to do with the regular meaning of sound channels.
  • Don’t worry about MP3s - Adobe has you covered. On other platforms, we now use OGGs.


Challenge: Zelda-style Battle Music

“Suppose that you’re playing Zelda. The regular tune plays, but when you approach an enemy, and the music switches over to the battle music. Once you defeat the enemy, the regular tune picks up where it left off.”

How would you build this sound system?


Challenge: Smooth MP3 Looping

MP3's can sometimes have a hard time looping smoothly and seamlessly. Some pieces of software are able to mask this or work it out. One of our users posted up an interesting link talking about a guaranteed-way of creating gapless MP3's.


He put up a shorter guide here.

Your task is simple - run through it and see if it works for you. It's a long article, and if you are able to boil that down to a smaller series of steps, we've love to know about it (in the comments section here!)

Disclaimer: All articles are geared towards Stencyl 3.0 and above. Use comments to provide feedback and point out issues with the article (typo, wrong info, etc.). If you're seeking help for your game, please ask a question on the forums. Thanks!


0 1 year, 1 week ago
I think the link "He put up a shorter guide here." is broke.
0 1 year, 2 weeks ago
Never mind. I figured it out by noticing that you can choose a sound on a channel. :D
0 1 year, 4 months ago
I am having trouble with pausing my background music. I want to be able to pause the music and resume it from where it last left off, which, I think, involve the use of channels. How do I use them?
0 1 year, 4 months ago
OneSaint, why don't you just create a single audio file with many different instances of the original cheer sound effect played over a couple audio beds? That way it only plays one sound, but it can still repeat the sound effect and overlap as many times as needed.
0 1 year, 4 months ago
Invin K
I'm also stuck on sound bugs too.. ahhh... it makes me crazy LOL.
At first, I assigned channel 0 for my some BGMs. and I set-up like this.. 'when BGM on Ch. 0 finish its playback, then Play other BGM.'

Ridiculously, Another BGMs are overlapped with current BGM which is playing now, after other sound effects played.
and, Finally BGMs are Amplified together..! LOL torturing me XD
Of course, I set the BGM as 'music'. not a 'sound effect'. and... Is that sure Music can't be overlapped each other?
I saw that two or more Musics cannot be played at the same time.
but, to me, It is possible. %-S
(I also tried to delete sound resource and remake it. also cleaned Games-generated/my game/music folder. but no works at all)

Is there any problem on 'Channel is done' Event? or... Channel 0 is the problem?

If there is Channel Reservation Command preventing from other sound randomly using that channel, I would maybe solve this...
Maybe if that command will be available later. even though sound effects are exceeded max Channel, we can preserve that channel from playing aborted

0 1 year, 5 months ago
I've been stuck on this sound bug for a month now. I try triggering a cheering sound on a win bolean, and it plays it 60 times on start. I try playing it through channels and it only plays in the next scene. I've tried both turning the Sound into a "music" and "sound effect" track, with no luck.

What am i doing wrong here. How do i get a simple cheering sound to trigger on an event?

0 1 year, 5 months ago
Compared to all other aspects of Stencyl as of this writing, I feel the sound blocks are lacking… like mentioned above in the 'Future' section… please add panning ASAP! Or add/make an extension for FMOD. Thanks for listening.
0 1 year, 5 months ago
Invin K
Sound Pitching Features are urgently needed! I think it is not difficult to be added, technically.

That function is required for game which uses Engine sound and Doppler effect.
oooOOOooh man~ I really need it LOL

0 1 year, 5 months ago
Yeesssss I got it to stop repeating it's self :DD

The way I did it is that I put

When Created - Stop all Sounds - If - Scene transitions - loop *soundtrack* I'm so happy :DD

also are there any tutorials on how to make a platformer AI for a partner character? Kind of like Tails in Sonic 2? I've looked but I can't find one, although it could just be me missing it.

1 1 year, 7 months ago

Sign In to Comment