Welcome, Guest. Please login or register. Did you miss your activation email?

Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - trooper

Pages: [1]
1
Audio / .Net Audio Issue on Live Stream
« on: May 05, 2017, 04:40:06 pm »
Hello,

Im really fresh to SFML, so first I want to say thanks for such a great Project.
Actually, Im implementing a Live Voice-Chat over the Internet(with SFML.Net) and already got it working.

When the Voice-Packet is send over the Network, it will be handled by the server which returns it with some more informations. On Client Side I extract these informations and call a Sound-Playing-Function with the voice samples as a byte array(for networking).
Well the packets coming in right here are in a really short intervall (100ms)

this code handles the packets and playing them:
private void PlayAudioData(byte[] data, float[] myposition, float[] mydirection, float[] talkerposition, bool self)
        {
            //set my position
            Listener.Position = new Vector3f(myposition[0], myposition[1],myposition[2]);
            //rotation not implemented in protocol right now
            Listener.Direction = new Vector3f(mydirection[0], mydirection[1], mydirection[2]);
            //if i muted the speaker then dont play
            if (outMuted)
                return;
            //convert audio data back to short
            short[] sdata = new short[(int)Math.Ceiling((double)data.Length / 2)];
            Buffer.BlockCopy(data, 0, sdata, 0, data.Length);
            //load into the buffer
            buffer = new SoundBuffer(sdata, 1, this.SampleRate);
            sound = new Sound(buffer);
           
            //set speakers position
            if(self)
                sound.Position = new Vector3f(talkerposition[0]+1, talkerposition[1]+1, talkerposition[2]+1);
            else
                sound.Position = new Vector3f(talkerposition[0], talkerposition[1], talkerposition[2]);
            sound.RelativeToListener = false;
            sound.MinDistance = 1f;
            //loudness regulation, lower value = louder sound from distance
            sound.Attenuation = 4;
            sound.Play();
        }
the Problem is, that after each Sound.Play, a short clicking sound appears (like abrupt voice-stopping).
With 100ms packets right here, this disturbing sound appears 10 times a second.

Is there a way to solve this problem?

thanks
trooper

Pages: [1]
anything