Skip to content

Commit

Permalink
do straightforward settings/getting
Browse files Browse the repository at this point in the history
  • Loading branch information
float3 committed Jul 29, 2024
1 parent cb1ca3d commit 27b651a
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 37 deletions.
21 changes: 7 additions & 14 deletions Packages/com.llealloo.audiolink/Runtime/Scripts/AudioLink.cs
Original file line number Diff line number Diff line change
Expand Up @@ -830,21 +830,14 @@ public void SendAudioOutputData()

#if UNITY_WEBGL && !UNITY_EDITOR

if (audioSource.isPlaying)
{
audioLinkWebPeer.SyncLeft((leftSamples) =>
{
FetchAnalyzerLeft(WebALID, leftSamples, 4096);
});

audioLinkWebPeer.SyncRight((rightSamples) =>
{
FetchAnalyzerRight(WebALID, rightSamples, 4096);
});
}
if (audioSource.isPlaying)
{
FetchAnalyzerLeft(WebALID, audioLinkWebPeer.WaveformSamplesLeft, 4096);
FetchAnalyzerRight(WebALID, audioLinkWebPeer.WaveformSamplesRight, 4096);
}

_audioFramesL = audioLinkWebPeer.GetWaveformLeft();
_audioFramesR = audioLinkWebPeer.GetWaveformRight();
_audioFramesL = audioLinkWebPeer.WaveformSamplesLeft;
_audioFramesR = audioLinkWebPeer.WaveformSamplesRight;

#else

Expand Down
27 changes: 4 additions & 23 deletions Packages/com.llealloo.audiolink/Runtime/Scripts/WebALPeer.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,32 +9,13 @@ namespace AudioLink
public class WebALPeer : MonoBehaviour
{
const int SAMPLES_COUNT = 4096;
private float[] _waveformSamplesLeft, _waveformSamplesRight;
[HideInInspector][NonSerialized]
public float[] WaveformSamplesLeft, WaveformSamplesRight;

public WebALPeer()
{
_waveformSamplesLeft = new float[SAMPLES_COUNT];
_waveformSamplesRight = new float[SAMPLES_COUNT];
}

public float[] GetWaveformLeft()
{
return _waveformSamplesLeft;
}

public float[] GetWaveformRight()
{
return _waveformSamplesRight;
}

public void SyncLeft(Action<float[]> FetchSamplesLeft)
{
FetchSamplesLeft(_waveformSamplesLeft);
}

public void SyncRight(Action<float[]> FetchSamplesRight)
{
FetchSamplesRight(_waveformSamplesRight);
WaveformSamplesLeft = new float[SAMPLES_COUNT];
WaveformSamplesRight = new float[SAMPLES_COUNT];
}

}
Expand Down

0 comments on commit 27b651a

Please sign in to comment.