void SetSamples( System.Int16[] samples, float duration, string sound )

robot_2Generated
code_blocksInput

Description

The SetSamples method is used to configure the audio samples for a sound that will be played by the SoundPlayer in the editor. This method allows you to specify the raw audio data, the duration of the sound, and the name of the sound.

Usage

To use the SetSamples method, you need to provide an array of audio samples, the duration of the sound in seconds, and a string identifier for the sound. This method is typically used when you want to dynamically set or change the audio data for a sound that is to be played in the editor environment.

Example

// Create an instance of SoundPlayer
Editor.SoundPlayer soundPlayer = new Editor.SoundPlayer();

// Define audio samples
short[] audioSamples = new short[] { 0, 32767, -32768, 0 };

// Set the duration of the sound
float duration = 1.5f; // 1.5 seconds

// Define the sound name
string soundName = "MyCustomSound";

// Set the samples for the sound
soundPlayer.SetSamples(audioSamples, duration, soundName);

// Optionally, play the sound
soundPlayer.Play();