Photon voice - Linking audio signals to speakers

m241
m241
edited September 6 in Photon Voice
Hi, I'm looking into how Photon routes the audio data around.

There's a few things I'd want clarification on:
1. Why does the Photon Voice Network requires a speaker prefab? Specifically, will a prefab (with Photon Voice View) attached works if it's not the one injected in the Photon Voice Network? If that's the case, would that implies that I need to make a specific prefab that's just the speaker, and attach it dynamically if I want a player to be able to use multiple different classes, for example?
2. Related to 1, what about photon voice views that isn't in a prefab?
3. Can I route the same audio data to multiple speakers using just Photon API, or do I need to relay it manually?
4. Can multiple audio sources from multiple different players be routed to the same speakers, or do I have to make one for each player individually?

Comments

  • m241
    m241
    edited September 6
    I found out the forum allows editing, but apparently not deleting, ignore this.
  • Hi @m241,

    Thank you for choosing Photon!

    1. It's optional not required. Speaker prefab will be used if the PhotonVoiceView does can not fine a Speaker to setup and requires one.
    2. I think 1 answers this already. You can see PhotonVoiceView.SetupSpeaker methods.
    3. No this is not possible out of the box but you can try it out. Why do you need it though? I don't think it makes sense to play the same sound in multiple components at the same time?
    4. No it's not possible to play (mix) multiple incoming audio streams using the same Speaker.
  • m241
    m241
    edited September 8
    I see, thanks for the clarification.

    For 3 and 4, I'm mainly exploring what Photon (and Unity) offers in terms of audio setup. Specifically in my use case, indeed that only one component would be playing the audio at a time, but not necessarily the same component. It would be more straightforward to disable/enable the speaker depending on context, rather than moving it around and changing the config dynamically. Other use cases includes in-game broadcasting system/stations.

    What would happen if I create multiple pre-fab instances with Photon Voice View then, or if I have multiple Photon Voice View instances with their own speaker component? Would only one of them work at a time?
  • Hi @m241,

    You can have multiple Recorder (locally, outgoing streams) that will result in multiple Speaker components (remote, for incoming streams)...
    In PUN integration this means you can have multiple PhotonView/PhotonVoiceView with a Recorder assigned to each yes.
    To make sure enabling/disabling voice components work as expected make sure to tick:
    Speaker.PlaybackOnlyWhenEnabled and Recorder.RecordOnlyWhenEnabled.
  • I see. What about speakers connected via "Use default recorder" method? Should only one of them exists/be active at a time, and would Photon automatically handle the routing if I make sure that is the case?

    Thanks.
  • The Primary Recorder is like the default recorder yes.
    It is automatically found and used if you choose this behaviour.
    It's mainly there because we have the assumptions that in most use cases, you only need one Recorder to transmit a single outgoing voice stream.
    But Photon Voice can have up to 255 voice streams per player in theory.