Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Data Compression RPCS?

Discussion in 'NetCode for ECS' started by l33t_P4j33t, Oct 31, 2021.

  1. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    i made a voice system
    it needs to send 16,000 floats a second. 64k per talking person
    this is done through rpcs

    does the data get compressed automatically?
    tried doing a custom rpc serializer that uses writer.writepackedfloat().
    i don't know if this helps, but the method function doesn't seem to at all use the model argument.
    is it being compressed?

     

    Attached Files:

  2. CMarastoni

    CMarastoni

    Unity Technologies

    Joined:
    Mar 18, 2020
    Posts:
    774
    The compression model is only used for integers (where it actually make sense). The WritePackedFloatDelta always send 1 bit if the value equals the baseline, otherwise the full float 32 bits as uint. And because of the floating point format, compressing the 32bit value with the model (that is based on Huffman) will return the same amount (if not more).

    If you want to use compression you need to quantise your float first fo integers (up to some precision). But I would say, compressing voice this way is not the best. There is no guarantee of preserving some of the speech characteristic. You need to use a voice compression codec like Speed, Lyra, Opus etc etc that generate very low bandwidth quantised signal and send this as a packet.

    Using RPC also is a highly discouraged. They are reliable and that is really not for voice transmission or to be sent at high frequency (every frame in practice). You should use an unreliable channel for that purpose and use the NetworkDriver to send the voice packets.

    On top of that you need also to adjust and compensate for latency and packet losses, by caching the received packets and dispatching them at regular intervals (otherwise you will start hearing cracks in the speech)

    I would suggest to just use a P2P connection for voice and/or a relay service and use transport directly for the best performance and customisability.
     
    l33t_P4j33t likes this.
  3. l33t_P4j33t

    l33t_P4j33t

    Joined:
    Jul 29, 2019
    Posts:
    232
    thank you for pointing me in the right direction