Programmer Instrument with createSound and network URL

Hi all,

I’m attempting to use createSound to load in a mp3 file over the network to play from a programmer instrumnet callback.

I saw in the docs that the name parameter can take a URL but I’m unable to get it working with programmer instruments.

System::createSound(
  string name,
  MODE mode,
  out Sound sound
);

name: Name of the file or URL to open

The setup works if the file is predownloaded into the Streaming Assets folder, but I’m curious how to correctly use createSound with a url and programmer instrument callback. I’m attaching my niave attempt at modifying the programmer instrument example script.

thanks for any suggestions,

FmodNetCreate.cs.txt (4.7 KB)

1 Like

Hi,

What version of the FMOD integration are you using?

We have an example for setting up a sound to use a URL in our API Examples: "C:\Program Files (x86)\FMOD SoundSystem\FMOD Studio API Windows\api\core\examples\vs2019\examples.sln" net_stream.cpp.

The main thing to change is the FMOD.MODE which needs to be: FMOD.MODE soundMode = FMOD.MODE.CREATESTREAM | FMOD.MODE.NONBLOCKING;

When using the URL in our example, it worked, so it may also be an issue with your URL. Could you try http://live-radio01.mediahubaustralia.com/2TJW/mp3/ and let me know if that works?

Hope this helps!

Hi Connor,

thanks for your reply, I’m using 2.02 in Unity (I attached my C# code in my message above as a text file).

I can confirm using your setup (soundMode to CREATESTREAM) with that stream URL works.

Its a little different to my situation where I have static (non-streaming) small (~50k mp3s) and I was attempting to use CREATECOMPRESSEDSAMPLE as the soundMode.

I think I’ve misinterpreted what the URL in the docs is refering to!

Can you confirm these URLs (used with createSound) need to be streaming urls rather than static ones?

thanks again, in the mean time I will look into a solution to precache the files locally before passing them into the programmer instrument.

Hi,

No, they do not have to be streaming. However, it will depend on how the files are being hosted and any security the site may have in place.

I can play small audio files when I host them myself using Simple Web Server for example. It may be worth trying a different hosting method to allow you to play the audio files.