If you check the documentation, AudioClip.SetData expects the audio samples, but when you do File.ReadAllBytes, you take the header and the audio samples. It is potentially why you hear noises. You can use AudioClip.GetData to get the samples from an AudioClip. Be sure to have the correct sample rate and channels count, or else you will still hear noises.
I made a script creating an AudioClip from GetData. Can you make sure this works in your project? If this works then, the issue is probably in the code sending the data.
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class StreamAudioTest : MonoBehaviour
{
public AudioSource receiverSource;
public AudioClip clip;
// Start is called before the first frame update
void Start()
{
int channels = clip.channels;
int frequency = clip.frequency;
float[] samples = new float[clip.samples * clip.channels];
clip.GetData(samples, 0);
CreateAndPlay(samples, channels, frequency);
}
void CreateAndPlay(float[] samples, int channels, int frequency)
{
var clip = AudioClip.Create("ClipName", samples.Length, channels, frequency, false);
clip.SetData(samples, 0);
receiverSource.clip = clip;
receiverSource.Play();
}
}
If not, when you check the array from AudioClip.GetData, does the array has other value than zero? If yes, did you try setting Decompress on load in the importer like the note mentioned?
I thought you had the audio file imported in the sender project, but it is not the case from what I understand. Do you need to play the file while streaming? Is it an issue to download it and play it after? We don’t support importing or streaming an audio file at runtime, but if you are doing this in the Editor only and can wait for the complete file, you can use AssetDatabase.ImportAsset. Even though we don’t support this out of the box, it doesn’t mean you can’t do this yourself. You need to get the PCM data from your file. You can search around for a WAV parser to get the audio samples and feed them to the AudioClip using SetData. If your audio was compressed, you would need to decompress it, but it is not your case. So you can focus on the parser, and you should be fine.