Photon Voice v2.53

Public Types | Public Member Functions | Static Public Attributes | Protected Member Functions | Properties | List of all members
Recorder Class Reference

Component representing outgoing audio stream in scene. More...

Inherits VoiceComponent.

Public Types

enum  InputSourceType
 
enum  MicType
 

Public Member Functions

bool RestartRecording ()
 Restarts recording if Recorder.RecordingEnabled is true More...
 
void VoiceDetectorCalibrate (int durationMs, Action< float > detectionEndedCallback=null)
 Trigger voice detector calibration process. While calibrating, keep silence. Voice detector sets threshold basing on measured background noise level. More...
 
bool SetIosAudioSessionParameters (IOS.AudioSessionParameters asp)
 Sets the AudioSessionParameters for iOS audio initialization when Photon MicrophoneType is used. More...
 
bool SetIosAudioSessionParameters (IOS.AudioSessionCategory category, IOS.AudioSessionMode mode, IOS.AudioSessionCategoryOption[] options)
 Sets the AudioSessionParameters for iOS audio initialization when Photon MicrophoneType is used. More...
 
bool SetAndroidNativeMicrophoneSettings (bool aec=false, bool agc=false, bool ns=false)
 Sets the native Android audio input settings when the Photon microphone type is used. More...
 
bool ResetLocalAudio ()
 Resets audio session and parameters locally to fix broken recording due to system configuration modifications or audio interruptions or audio routing changes. More...
 

Static Public Attributes

const int MIN_OPUS_BITRATE = 6000
 
const int MAX_OPUS_BITRATE = 510000
 

Protected Member Functions

virtual void SendPhotonVoiceCreatedMessage ()
 
void Update ()
 
- Protected Member Functions inherited from VoiceComponent
virtual void Awake ()
 

Properties

bool TransmitEnabled [get, set]
 If true, audio transmission is enabled. More...
 
bool Encrypt [get, set]
 If true, voice stream is sent encrypted. More...
 
bool DebugEchoMode [get, set]
 If true, outgoing stream routed back to client via server same way as for remote client's streams. More...
 
bool ReliableMode [get, set]
 If true, stream data sent in reliable mode. More...
 
bool VoiceDetection [get, set]
 If true, voice detection enabled. More...
 
float VoiceDetectionThreshold [get, set]
 Voice detection threshold (0..1, where 1 is full amplitude). More...
 
int VoiceDetectionDelayMs [get, set]
 Keep detected state during this time after signal level dropped below threshold. Default is 500ms More...
 
object UserData [get, set]
 Custom user object to be sent in the voice stream info event. More...
 
Func< IAudioDescInputFactory [get, set]
 Set the method returning new Voice.IAudioDesc instance to be assigned to a new voice created with Source set to Factory More...
 
AudioUtil.IVoiceDetectorVoiceDetector [get]
 Returns voice activity detector for recorder's audio stream. More...
 
byte InterestGroup [get, set]
 Target interest group that will receive transmitted audio. More...
 
int[] TargetPlayers [get, set]
 Target players which will receive transmitted audio. More...
 
bool IsCurrentlyTransmitting [get]
 Returns true if audio stream broadcasts. More...
 
AudioUtil.ILevelMeterLevelMeter [get]
 Level meter utility. More...
 
bool VoiceDetectorCalibrating [get]
 If true, voice detector calibration is in progress. More...
 
ILocalVoiceAudio voiceAudio [get]
 
InputSourceType SourceType [get, set]
 Audio data source. More...
 
MicType MicrophoneType [get, set]
 Which microphone API to use when the Source is set to Microphone. More...
 
AudioClip AudioClip [get, set]
 Source audio clip. More...
 
bool LoopAudioClip [get, set]
 Loop playback for audio clip sources. More...
 
SamplingRate SamplingRate [get, set]
 Outgoing audio stream sampling rate. More...
 
OpusCodec.FrameDuration FrameDuration [get, set]
 Outgoing audio stream encoder delay. More...
 
int Bitrate [get, set]
 Outgoing audio stream bitrate. More...
 
bool RecordingEnabled [get, set]
 Gets or sets whether this Recorder is recording audio to be transmitted. More...
 
bool StopRecordingWhenPaused [get, set]
 If true, stop recording when paused resume/restart when un-paused. More...
 
bool UseOnAudioFilterRead [get, set]
 If true, recording will make use of Unity's OnAudioFitlerRead callback from a muted local AudioSource. More...
 
bool UseMicrophoneTypeFallback [get, set]
 If true, if recording fails to start with Unity microphone type, Photon microphone type is used -if available- as a fallback and vice versa. More...
 
bool RecordWhenJoined [get, set]
 If true, recording starts when joining the room and stops when leaving the room. More...
 
DeviceInfo MicrophoneDevice [get, set]
 
bool AndroidMicrophoneAGC [get]
 
bool AndroidMicrophoneAEC [get]
 
bool AndroidMicrophoneNS [get]
 
- Properties inherited from VoiceComponent
string Name [set]
 

Additional Inherited Members

- Public Attributes inherited from VoiceComponent
VoiceLogger VoiceLogger => impl.VoiceLogger
 
- Protected Attributes inherited from VoiceComponent
Voice.ILogger Logger => impl.Logger
 

Detailed Description

Component representing outgoing audio stream in scene.

Member Function Documentation

◆ ResetLocalAudio()

bool ResetLocalAudio ( )

Resets audio session and parameters locally to fix broken recording due to system configuration modifications or audio interruptions or audio routing changes.

Returns
If reset is done.

◆ RestartRecording()

bool RestartRecording ( )

Restarts recording if Recorder.RecordingEnabled is true

◆ SetAndroidNativeMicrophoneSettings()

bool SetAndroidNativeMicrophoneSettings ( bool  aec = false,
bool  agc = false,
bool  ns = false 
)

Sets the native Android audio input settings when the Photon microphone type is used.

Parameters
aecAcoustic Echo Cancellation
agcAutomatic Gain Control
nsNoise Suppression
Returns
If a change has been made.

◆ SetIosAudioSessionParameters() [1/2]

bool SetIosAudioSessionParameters ( IOS.AudioSessionCategory  category,
IOS.AudioSessionMode  mode,
IOS.AudioSessionCategoryOption[]  options 
)

Sets the AudioSessionParameters for iOS audio initialization when Photon MicrophoneType is used.

Parameters
categoryAudio session category to be used.
modeAudio session mode to be used.
optionsAudio session category options to be used
Returns
If a change has been made.

◆ SetIosAudioSessionParameters() [2/2]

bool SetIosAudioSessionParameters ( IOS.AudioSessionParameters  asp)

Sets the AudioSessionParameters for iOS audio initialization when Photon MicrophoneType is used.

Parameters
aspYou can use custom value or one from presets, IOS.AudioSessionParametersPresets
Returns
If a change has been made.

◆ VoiceDetectorCalibrate()

void VoiceDetectorCalibrate ( int  durationMs,
Action< float >  detectionEndedCallback = null 
)

Trigger voice detector calibration process. While calibrating, keep silence. Voice detector sets threshold basing on measured background noise level.

Parameters
durationMsDuration of calibration in milliseconds.
detectionEndedCallbackCallback when VAD calibration ends.

Property Documentation

◆ AudioClip

AudioClip AudioClip
getset

Source audio clip.

◆ Bitrate

int Bitrate
getset

Outgoing audio stream bitrate.

◆ DebugEchoMode

bool DebugEchoMode
getset

If true, outgoing stream routed back to client via server same way as for remote client's streams.

Initialized with serialized field and can be updated by Editor at runtime.

◆ Encrypt

bool Encrypt
getset

If true, voice stream is sent encrypted.

Initialized with serialized field and can be updated by Editor at runtime.

◆ FrameDuration

OpusCodec.FrameDuration FrameDuration
getset

Outgoing audio stream encoder delay.

◆ InputFactory

Func<IAudioDesc> InputFactory
getset

Set the method returning new Voice.IAudioDesc instance to be assigned to a new voice created with Source set to Factory

◆ InterestGroup

byte InterestGroup
getset

Target interest group that will receive transmitted audio.

If InterestGroup != 0, recorder's audio data is sent only to clients listening to this group. Initialized with serialized field and can be updated by Editor at runtime.

◆ IsCurrentlyTransmitting

bool IsCurrentlyTransmitting
get

Returns true if audio stream broadcasts.

◆ LevelMeter

AudioUtil.ILevelMeter? LevelMeter
get

Level meter utility.

◆ LoopAudioClip

bool LoopAudioClip
getset

Loop playback for audio clip sources.

◆ MicrophoneType

MicType MicrophoneType
getset

Which microphone API to use when the Source is set to Microphone.

◆ RecordingEnabled

bool RecordingEnabled
getset

Gets or sets whether this Recorder is recording audio to be transmitted.

◆ RecordWhenJoined

bool RecordWhenJoined
getset

If true, recording starts when joining the room and stops when leaving the room.

◆ ReliableMode

bool ReliableMode
getset

If true, stream data sent in reliable mode.

Initialized with serialized field and can be updated by Editor at runtime.

◆ SamplingRate

SamplingRate SamplingRate
getset

Outgoing audio stream sampling rate.

◆ SourceType

InputSourceType SourceType
getset

Audio data source.

◆ StopRecordingWhenPaused

bool StopRecordingWhenPaused
getset

If true, stop recording when paused resume/restart when un-paused.

◆ TargetPlayers

int [] TargetPlayers
getset

Target players which will receive transmitted audio.

Initialized with serialized field and can be updated by Editor at runtime

◆ TransmitEnabled

bool TransmitEnabled
getset

If true, audio transmission is enabled.

◆ UseMicrophoneTypeFallback

bool UseMicrophoneTypeFallback
getset

If true, if recording fails to start with Unity microphone type, Photon microphone type is used -if available- as a fallback and vice versa.

◆ UseOnAudioFilterRead

bool UseOnAudioFilterRead
getset

If true, recording will make use of Unity's OnAudioFitlerRead callback from a muted local AudioSource.

If enabled, 3D sounds and voice positioning can be lost.

◆ UserData

object UserData
getset

Custom user object to be sent in the voice stream info event.

◆ VoiceDetection

bool VoiceDetection
getset

If true, voice detection enabled.

◆ VoiceDetectionDelayMs

int VoiceDetectionDelayMs
getset

Keep detected state during this time after signal level dropped below threshold. Default is 500ms

◆ VoiceDetectionThreshold

float VoiceDetectionThreshold
getset

Voice detection threshold (0..1, where 1 is full amplitude).

◆ VoiceDetector

AudioUtil.IVoiceDetector? VoiceDetector
get

Returns voice activity detector for recorder's audio stream.

◆ VoiceDetectorCalibrating

bool VoiceDetectorCalibrating
get

If true, voice detector calibration is in progress.