Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[BUG]: How get spectrum data from receiving audio stream track? #1033

Open
VadimFokin20 opened this issue May 21, 2024 · 0 comments
Open

[BUG]: How get spectrum data from receiving audio stream track? #1033

VadimFokin20 opened this issue May 21, 2024 · 0 comments
Assignees
Labels
bug Something isn't working

Comments

@VadimFokin20
Copy link

Package version

3.0.0-pre.7

Environment

* OS: Windows 11
* Unity version: 2023.2

Steps To Reproduce

void ReceivingAudio() {
  var receivedAudioSource = GetComponent<AudioSource>();
  var receiveStream = new MediaStream();
  receiveStream.OnAddTrack = e => {
    if(e.Track is AudioStreamTrack track)
    {
        receivedAudioSource.SetTrack(track);
        receivedAudioSource.loop = true;
        receivedAudioSource.Play();        
    }
  }
}

void FixedUpdate() {
  if(receivedAudioSource != null) {
    float[] data = new float[256]
    receivedAudioSource.GetSpectrumData(data, 0, FFTWindow.Rectangular)
    // do something
  }
}

After sending peer has connected to receiving peer data array is empty, cause receivedAudioSource.clip is null, but receiver has sound from sender

Current Behavior

I have implemented audio streaming channel on LAN with own signalling server. Everything works good.
After receiving the audio stream track on remote PC I need get a output data or spectrum data from the Audio Source. But the receiving Audio Source doesn't contains a audio clip and i get the empty float array from the necessary methods (AudioSource.GetSpectrumData() or AudioSource.GetOutPutData())
I tried the Audio Sample. The Same thing there.

Expected Behavior

Maybe there are other ways to get a data from audio clip?

Anything else?

No response

@VadimFokin20 VadimFokin20 added the bug Something isn't working label May 21, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants