InworldAudioModule | Inherits from: MonoBehaviour
Abstract base class for all audio processing modules in the Inworld framework. Provides common functionality for audio modules including coroutine management and audio manager access. All audio modules should inherit from this class to integrate with the audio processing pipeline.
Properties
Methods
Audio Processing Pipeline
The InworldAudioModule interfaces are called in a specific order during audio processing:- Pre-Processing:
OnPreProcessAudio()is called first - Collection:
OnCollectAudio()gathers audio data from the input buffer - Post-Processing:
OnPostProcessAudio()processes the collected data - Voice Detection: Voice detection runs continuously when enabled
- Audio Sending: Audio data is sent when the player is speaking
Constants
The base class defines several audio processing constants:k_InputSampleRate(16000) - Standard sample rate for audio inputk_InputChannels(1) - Number of audio channels (mono)k_InputBufferSecond(1) - Buffer duration in secondsk_SizeofInt16(2) - Size of 16-bit integer in bytes
Interfaces
The InworldAudioModule system uses several interfaces that define different aspects of audio processing. These interfaces are implemented by child classes and called by the InworldAudioManager at specific times:IMicrophoneHandler
Handles microphone recording functionality. Methods:ListMicDevices()- Lists available microphone devicesStartMicrophone()- Called by InworldAudioManager.StartMicrophone()StopMicrophone()- Called by InworldAudioManager.StopMicrophone()ChangeInputDevice(string deviceName)- Changes the input deviceIsMicRecording(property) - Accessed by InworldAudioManager.IsMicRecording
ICollectAudioHandler
Handles audio data collection from the input buffer. Methods:OnCollectAudio()- Called by InworldAudioManager.CollectAudio() during the audio coroutineResetPointer()- Called by InworldAudioManager.ResetPointer()
IPlayerAudioEventHandler
Handles voice detection and player audio events. Methods:OnPlayerUpdate()- Coroutine for continuous player audio updatesStartVoiceDetecting()- Called by InworldAudioManager.StartVoiceDetecting()StopVoiceDetecting()- Called by InworldAudioManager.StopVoiceDetecting()
ICalibrateAudioHandler
Handles audio calibration functionality. Methods:OnStartCalibration()- Called by InworldAudioManager.StartCalibrate()OnStopCalibration()- Called by InworldAudioManager.StopCalibrate()OnCalibrate()- Performs the actual calibration process
IProcessAudioHandler
Handles audio pre-processing and post-processing. Methods:OnPreProcessAudio()- Called by InworldAudioManager.PreProcess() during the audio coroutineOnPostProcessAudio()- Called by InworldAudioManager.PostProcess() during the audio coroutineProcessedBuffer(property) - Buffer containing processed audio data
ISendAudioHandler
Handles sending audio data to external services. Methods:OnStartSendAudio()- Called when InworldAudioManager.IsPlayerSpeaking is set to trueOnStopSendAudio()- Called when InworldAudioManager.IsPlayerSpeaking is set to falseSamples(property) - Accessed by InworldAudioManager.OnSendAudio() and InworldAudioManager.PushAudio()
Reference
Priority
Gets or sets the execution priority of this audio module. Lower values indicate higher priority and will be processed first.Returns
Type:int
Audio
Gets the InworldAudioManager instance that coordinates audio processing. Automatically finds and caches the audio manager in the scene if not already set.Returns
Type:InworldAudioManager
StartModule
Starts the module’s processing coroutine. Only one coroutine can be active per module at a time.Parameters
| Parameter | Type | Description |
|---|---|---|
| moduleCycle | IEnumerator | The coroutine to start for this module’s processing cycle. |
Returns
Type:void
StopModule
Stops the currently running module coroutine and cleans up resources. Safe to call even if no coroutine is currently running.Returns
Type:void