Experimental Audio Connection Example
This example is similar to the basic “hello-world” example. The main difference is that, instead of the usual Connect
method, the Experimental_ConnectAudio
is called to initiate an audio stream (or ConnectAudio
from the Experimental::AudioStreamConfiguration
component).
In playmode, the device will automatically connect to the configured audio device, and update the connection status. Additionally, two buttons are displayed in the middle of the screen, pressing one of them triggers a predefined haptic effect on the vest on the front (or back) of the haptic device.
The scene is composed of a canvas with two buttons and a text and an empty gameobject SkineticBasicUIExample containing two gameobjects: one to handle the SkineticDevice
component and one to handle the HapticEffect
components.
Automatic connection
The connection is automatically performed by the SkiEx_Exp_AutoAudioConnect script on the SkineticDevice
component using the audio setting set on the Experimental::AudioStreamConfiguration
component. This script has a reference set in the inspector to the SkineticDevice
and Experimental::AudioStreamConfiguration
components and a Text on the canvas.
AudioSettings configuration
Experimental::AudioStreamConfiguration
component can be edited in the inspector to set the audio settings. Pressing Edit allows to configure all the settings fields (see Experimental::AudioStreamConfiguration
).
On the OnEnable event
A connection callback is set:
m_device.SetConnectionCallback(ConnectionCallback);
This callback will be called whenever the connection to the device is made or broken, and update the state string
m_connectString
.A connection to he configured audio device is requested by passing the targeted
SkineticDevice
component to theConnectAudio
of theExperimental::AudioStreamConfiguration
component.Start a coroutine to update the connection status in the text field as the callback being called from another thread cannot update the UI itself.
During the OnDisable event
The disconnection routine is initiated and the function returns once the disconnection is completed.