While Studio projects are very visual, sound and music form a very important part of immersive 3D experiences and should be considered throughout the development of a project.

Supported Audio Formats

ZapWorks Studio supports audio files in the following formats, imported by dragging the files into the Media Library:

  • .wav - use for short sound effects, such as button taps.
  • .ogg - use for music or longer audio sequences.

The following specifications are recommended for audio files in order to minimize download time and resource use:

  • Use 22.05 kHz sample rate
  • Mono channel
  • 128 kbps

Playing Audio

Once imported into the Media Library, audio files can be dragged into the Hierarchy for use within the scene. It's important to try to minimize the number of initialized audio files as mobile devices have limited resources for mixing and playing sound.

As with other nodes in the Hierarchy, audio nodes have a number of properties that can be changed in the properties view on the left, or modified in a timeline.

Controlling from a Timeline

With a timeline selected, right-click an audio node in the Hierarchy and select Add Timeline Action, then one of the options listed below:

  • start - play the audio from its current position.
  • pause - pause the audio at its current position.
  • restart - return the audio node to the beginning and start playback.

A marker will be added to the timeline at the current timeline's time value to indicate the point that the action will be triggered. As with keyframes, markers can be dragged to change the point along the timeline in which it's triggered.

Markers have a direction - by default the action will only be triggered when the timeline passes it while playing forward. The direction of the marker can be changed from its right-click menu. With a direction of Both, the action will be triggered when a timeline is playing either forwards or backward.

Controlling from a script node

Dragging an audio node into a script allows you to construct a variable that can be used to control the node. The node has a number of methods used to control its playback such as start(), pause() and restart(), as well as functions for controlling volume. See the Z.Audio reference documentation for more information.

Audio files can be looped by calling the restart() function on them when their finish event is fired.

zapcode branded_zapcode i