Placeholder-Software / Dissonance

Unity Voice Chat Asset
71 stars 5 forks source link

[bug] Call to AudioClip.Create() in VoicePlayback should use 'false' for parameter 'stream' #246

Closed koschke closed 2 years ago

koschke commented 2 years ago

Context

I am creating a multi-player game with remote players communicating via Dissonance. The remote players are represented as UMA avatars. I am using SALSA's lip syncing to animate the face of a speaking player. The network connection is via Unity's NetCode. I am connecting the audio source of the Dissonance player representations (the game object which are children of DissonanceSetup) with the audio source slot in the Salsa component of the avatar programmatically at run-time.

I get the exception as described in detail in section "Actual behaviour" below.

Expected behaviour

This exception should not occur and my avatar's lips should be synced with the voice of a remote player.

Actual behaviour

The error is as follows (retrieved from the Unity console):

Cannot get data from streamed samples for audio clip "Flatline". If the audio clip was created via AudioClip.Create and no PCM read callback was provided, the 'stream' argument must be false. For a disk-based AudioClip changing the load type to DecompressOnLoad on the AudioClip will allow modification of the data.

UnityEngine.AudioClip:GetData (single[],int)
CrazyMinnow.SALSA.Salsa:SalsaLssGetAudioClipData (single[],int)
CrazyMinnow.SALSA.SalsaAdvancedDynamicsSilenceAnalyzer:ProcessAudioStream ()
CrazyMinnow.SALSA.SalsaAdvancedDynamicsSilenceAnalyzer:LateUpdate ()

Fix

Changing the parameter stream in the call to AudioClip.Create() from true to false fixes my problem. More precisely, line 179 in VoicePlayback.cs is currently:

AudioSource.clip = AudioClip.Create("Flatline", 4096, 1, AudioSettings.outputSampleRate, true, buf =>

and should rather be:

AudioSource.clip = AudioClip.Create("Flatline", 4096, 1, AudioSettings.outputSampleRate, false, buf =>

Steps to Reproduce

The section "Context" already describes the basic steps. If you need more detail, let me know. But since I have provided a fix already, that might not be necessary.

Your Environment

martindevans commented 2 years ago

Thanks for the very detailed bug report - I'll investigate whether we can change that parameter from true to false.

Just so you know there is an integration package available for SALSA+Dissonance here (SalsaDissonanceLink), see the docs here: https://crazyminnowstudio.com/docs/salsa-lip-sync/addons/using-with-dissonance

koschke commented 2 years ago

Thanks. I am actually using SalsaDissonanceLink, but I still need to connect the audio sources in order to get it working. Or have I overlooked something and am doing something wrong?

martindevans commented 2 years ago

It's a long time since I worked with SALSA on this, but as I understand it rather than linking the AudioSource in to SALSA the SalsaDissonanceLink component should read amplitude data from Dissonance and directly drive SALSA with that.

martindevans commented 2 years ago

This parameter was changed to false in the previous release (8.0.4)