Skip to main content
Skip table of contents

RapportAudioClipInput

Description

The RapportAudioClipInput class is an implementation of the IRapportAudioInput interface that allows you to use a Unity AudioClip as the audio source for the Rapport system. This is useful for playing pre-recorded audio files through your Rapport character.

Namespace: SpeechGraphics.Rapport.Audio

Properties

Name

Type

Description

Frequency

int

The sample rate of the audio input, in Hertz (Hz). This value is set in the constructor and cannot be changed after instantiation.

SystemMute

bool

A property that gets or sets the system-level mute state, as required by the IRapportAudioInput interface.

IsMuted

bool

A read-only property that returns true if SystemMute is true, effectively checking if the audio stream is currently silenced by the system.

Methods

Name

Type

Description

OnAudioRead(int sampleOffset, float[] buffer)

void

This method is called internally from the audio thread to get samples from the currently playing AudioClip and populate the provided buffer. If no clip is currently playing, it fills the buffer with silence (zeros). It handles the end of the clip by resetting its internal state.

Parameters:

  • sampleOffset (int): The offset in samples since the last call.

  • buffer (float[]): The buffer array to be populated with audio samples.

Update()

void

This method is required by the IRapportAudioInput interface but has no implementation in this class, as AudioClip playback is handled by the OnAudioRead method.

PlayClip(AudioClip clip)

void

Loads a new AudioClip for playback. This method handles all necessary pre-processing, including getting the raw sample data from the clip, converting it to mono (if stereo), and resampling it to the specified Frequency of this class. The playback will start automatically on the next OnAudioRead call.

Parameters:

  • clip (AudioClip): The Unity AudioClip to be played.

JavaScript errors detected

Please note, these errors can depend on your browser setup.

If this problem persists, please contact our support.