Exemple #1
0
        public ReceiverSampleProvider(WaveFormat waveFormat, ushort id, int voiceInputNumber)
        {
            WaveFormat = waveFormat;
            ID         = id;

            mixer = new MixingSampleProvider(WaveFormat)
            {
                ReadFully = true
            };

            voiceInputs = new List <CallsignSampleProvider>();
            for (int i = 0; i < voiceInputNumber; i++)
            {
                var voiceInput = new CallsignSampleProvider(WaveFormat, this);
                voiceInputs.Add(voiceInput);
                mixer.AddMixerInput(voiceInput);
            }
            ;

            blockTone = new BlockingToneSampleProvider(WaveFormat.SampleRate, 1)
            {
                Gain = 0, Frequency = 180
            };
            mixer.AddMixerInput(blockTone.ToMono());
            volume = new VolumeSampleProvider(mixer);
        }
        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;
            }
        }
Exemple #3
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 ReceiverSampleProvider(WaveFormat waveFormat, ushort id, int voiceInputNumber)
        {
            WaveFormat = waveFormat;
            ID         = id;

            mixer = new MixingSampleProvider(WaveFormat)
            {
                ReadFully = true
            };

            voiceInputs = new List <CallsignSampleProvider>();
            for (int i = 0; i < voiceInputNumber; i++)
            {
                var voiceInput = new CallsignSampleProvider(WaveFormat, this);
                voiceInputs.Add(voiceInput);
                mixer.AddMixerInput(voiceInput);
            }
            ;

            blockTone = new BlockingToneSampleProvider(WaveFormat.SampleRate, 1)
            {
                Frequency = 180, Gain = 0
            };
            hfWhiteNoise = new ResourceSoundSampleProvider(Samples.Instance.HFWhiteNoise)
            {
                Looping = true, Gain = 0
            };

            mixer.AddMixerInput(blockTone.ToMono());
            if (!AudioConfig.Instance.HfSquelch)
            {
                mixer.AddMixerInput(hfWhiteNoise.ToMono());
            }
            volume = new VolumeSampleProvider(mixer);

            hfSquelchEn = AudioConfig.Instance.HfSquelch;
        }