PYBLOCKS / DOCS

Sound and music

Import sound effects and music into your project and play them with the Audio blocks.

Supported formats and importing

PyBlocks plays WAV, MP3 and OGG files. Short effects (jumps, coins, hits) work best as WAV or OGG; longer music tracks as OGG or MP3.

  1. Open the Project panel (in the Scene workspace, or with Window → Panels → Project & Console).
  2. Right-click the folder where the files should go, for example assets/audio, and choose Import Files.
  3. Select one or more audio files. They are copied into the project; your originals stay where they were.

Any .wav, .mp3 or .ogg file inside the project folder is available to the audio blocks, whatever subfolder it is in.

Sound effects

Play Sound plays a file once. Pick it in the Sound list, which shows every audio file of the project by its path (for example assets/audio/coin.wav), and set At Volume from 0 to 1.

  • The same sound can play several times at once, so fast repeated effects overlap naturally.
  • Stop Sound stops every copy of one sound that is playing; Stop All Sounds stops all sound effects.

A typical use: an On Collision Enter script on a coin that plays coin.wav and then destroys the coin.

Music

Play Music starts a background track that loops until you stop it. Only one music track plays at a time: playing another one replaces the current track.

A good place for Play Music is a When Scene Starts script on an object of each scene, so every level can have its own track.

Volume

  • Every Play Sound and Play Music has its own At Volume, from 0 (silent) to 1 (full).
  • Set Volume sets the master volume, also from 0 to 1. The volume you hear is the block's At Volume multiplied by the master volume, so Set Volume 0.5 makes everything half as loud.
  • Set AudioClip Volume changes the volume of copies of one sound effect that are already playing.

Good to know

  • All sounds and music stop when you press Stop, and when a scene is loaded while the game runs.
  • If a file cannot be found or loaded, the block does nothing and the game keeps running. Check the file name in the block's list after moving or renaming files.
  • Every example project includes its own sound effects in assets/audio, which you can reuse. See Examples.

The full list of audio blocks is in the Audio block reference.