Clear
Back

Triggering Audio in Response to Interactions

These are some examples of how you can use the Patch Editor to trigger audio in your effects.

Triggering audio in response to interaction

This graph makes a sound to play once when the screen is tapped, and stop when the screen is tapped again.

The Screen Tap patch creates a boolean signal when someone taps on the device screen. Passed through the Switch pass, this causes the sound to either play or stop.

You could use a different interaction patch if you wanted.

Using the same audio clip in different ways

In this effect, we're using the Multi-Clip Controller and Single-Clip Controller patches to play the same audio clip in different ways, based on different interactions.

Because we've connected the Screen Tap patch and the Single-Clip Controller, the clip will play once when the screen is tapped. If the screen was tapped again while the sound was still playing, the clip would start from the beginning.

The Object Tap patch is connected to a Multi-Clip Controller. Every time the object is tapped, the clip will play. Unlike with the Single-Clip controller, if the sound was still playing when the object was tapped, the it won't stop and start from the beginning - a new clip will play over the top of the previous one.

Because we're using the Multi-Clip Controller and Single-Clip Controller, we don't have a playback controller patch in this graph. Our audio clip - which is represented by an orange asset patch - is connected to the Audio Player patch instead. It has still been assigned to the speaker.

Playing 2 different audio clips

In this effect we have 2 different audio clips - represented by the 2 orange asset patches. Both asset patches are connected to Audio Player patches, which are then both connected to consumer patches representing the Audio property of 2 speakers.

The Controller output port of a Single-Clip Controller is connected to the Controller input port of both Audio Player patches, so that when the screen is tapped, both audio clips play.

Join the Spark AR Creator's community

Find inspiration, see examples, get support, and share your work with a network of creators.

Join Community

Join the Spark AR Creator's community

Find inspiration, see examples, get support, and share your work with a network of creators.

Join Community

Frequently asked questions

Have a specific question? Maybe it's been answered.


Read FAQs
Was this document helpful?