Example #1
0
        public void AddOpusSamples(IAudioDto audioDto, uint frequency, float distanceRatio)
        {
            if (frequency != this.frequency)        //Lag in the backend means we get the tail end of a transmission if switching frequency in the middle of a transmission
            {
                return;
            }

            CallsignSampleProvider voiceInput = null;

            if (voiceInputs.Any(i => i.Callsign == audioDto.Callsign))
            {
                voiceInput = voiceInputs.First(b => b.Callsign == audioDto.Callsign);
            }
            else if (voiceInputs.Any(b => b.InUse == false))
            {
                voiceInput = voiceInputs.First(b => b.InUse == false);
                voiceInput.Active(audioDto.Callsign, "");
            }

            voiceInput?.AddOpusSamples(audioDto, distanceRatio);
            if (frequency > hfFrequencyUpperLimit || hfSquelchEn)
            {
                doClickWhenAppropriate = true;
            }
        }
Example #2
0
        public void AddSilentSamples(IAudioDto audioDto)
        {
            //Disable all audio effects
            SetEffects(true);

            Array.Clear(decoderByteBuffer, 0, frameCount * 2);
            audioInput.AddSamples(decoderByteBuffer, 0, frameCount * 2);
            lastPacketLatch = audioDto.LastPacket;

            lastSamplesAddedUtc = DateTime.UtcNow;
            if (!timer.Enabled)
            {
                timer.Start();
            }
        }
Example #3
0
        public void AddOpusSamples(IAudioDto audioDto, float distanceRatio)
        {
            if (audioDto.SequenceCounter > sequenceCounter)
            {
                sequenceCounter = audioDto.SequenceCounter;
                DistanceRatio   = distanceRatio;
                DecodeOpus(audioDto.Audio);
                audioInput.AddSamples(decoderByteBuffer, 0, frameCount * 2);
                lastPacketLatch = audioDto.LastPacket;
                if (audioDto.LastPacket && !underflow)
                {
                    CallsignDelayCache.Instance.Success(Callsign);
                }

                lastSamplesAddedUtc = DateTime.UtcNow;
                if (!timer.Enabled)
                {
                    timer.Start();
                }
            }
        }
Example #4
0
        public void AddSilentSamples(IAudioDto audioDto, uint frequency, float distanceRatio)
        {
            if (frequency != this.frequency)
            {
                return;
            }

            CallsignSampleProvider voiceInput = null;

            if (voiceInputs.Any(i => i.Callsign == audioDto.Callsign))
            {
                voiceInput = voiceInputs.First(b => b.Callsign == audioDto.Callsign);
            }
            else if (voiceInputs.Any(b => b.InUse == false))
            {
                voiceInput = voiceInputs.First(b => b.InUse == false);
                voiceInput.ActiveSilent(audioDto.Callsign, "");
            }

            voiceInput?.AddSilentSamples(audioDto);
            //doClickWhenAppropriate = true;
        }
        public void AddOpusSamples(IAudioDto audioDto, List <RxTransceiverDto> rxTransceivers)
        {
            var rxTransceiversFilteredAndSorted = rxTransceivers.Where(y => receiverIDs.Contains(y.ID)).OrderByDescending(x => x.DistanceRatio).ToList();

            // The issue in a nutshell - you can have multiple transmitters so the audio DTO contains multiple transceivers with the same ID or
            // you can have multiple receivers so the audio DTO contains multiple transceivers with different IDs, but you only want to play the audio once in either scenario.

            if (rxTransceiversFilteredAndSorted.Count > 0)
            {
                bool          audioPlayed           = false;
                List <ushort> handledTransceiverIDs = new List <ushort>();
                for (int i = 0; i < rxTransceiversFilteredAndSorted.Count; i++)
                {
                    var rxTransceiver = rxTransceiversFilteredAndSorted[i];
                    if (!handledTransceiverIDs.Contains(rxTransceiver.ID))
                    {
                        handledTransceiverIDs.Add(rxTransceiver.ID);

                        var receiverInput = receiverInputs.First(x => x.ID == rxTransceiver.ID);
                        if (receiverInput.Mute)
                        {
                            continue;
                        }
                        if (!audioPlayed)
                        {
                            receiverInput.AddOpusSamples(audioDto, rxTransceiver.Frequency, rxTransceiver.DistanceRatio);
                            audioPlayed = true;
                        }
                        else
                        {
                            receiverInput.AddSilentSamples(audioDto, rxTransceiver.Frequency, rxTransceiver.DistanceRatio);
                        }
                    }
                }
            }
        }