Everything you need to know to create an interactive augmented reality experience.
In this tutorial you'll learn to add sound, and to make the sound play in response to an interaction from the person using your effect.
We’ll look at:
When you’ve got to grips with the basics of audio, take a look at the audio effect patches included in Spark AR Studio. They can be added to your project to distort audio clips or input from a device’s microphone.
Start by creating an audio playback controller. You can do this in the Assets Panel:
It'll be listed in the Assets Panel as audioPlaybackController0.
When an audio playback controller is selected in the Assets Panel, you'll see its properties in the Inspector.
Add the audio file next to the option labeled Audio. To do this:
For sound to actually render in a scene, the audio playback controller has to be connected to an object called a speaker.
To add a speaker:
It’ll be listed in the Scene Panel as speaker0:
Next apply the playback controller to the speaker:
You can also edit the speaker’s properties to adjust the volume of sound in the scene, using the slider next to Volume.
To add a looping sound, adjust the properties of the playback controller:
You’ll now have a continuous looping sound in the scene!
Let's make this sound stop in response to a tap on the device screen.
In the Inspector panel, there are circles with arrows on in next to Play, Loop and Stop. Clicking these circles will create patches, representing that property.
Click the circle next to Stop to create a patch, and open the Patch Editor:
Next create a Screen Tap patch. This is one of many interaction patches included in Spark AR Studio, that will detect when someone touches to screen of their device when they're using the effect.
To add this patch to your project:
You’ve now got 2 patches in the Patch Editor:
Connect the output of the Screen Tap patch to the Stop input port in the audio playback controller patch:
Now the sound will stop when someone taps the screen of the device.
We can test this in the Simulator. Click the gear and select Simulate Touch, then click anywhere in the Simulator.
Find out more about playing sounds in response to interactivity.
In this tutorial, you've learned how to use the speaker and audio playback controller to add a continuous sound to your effect.
You've also learned to add some simple interactivity, making the sound stop when someone touches the device screen.
Find inspiration, see examples, get support, and share your work with a network of creators.Join Community