public GtPlayedNotesAnalyserHelper(GtFactory pFactory, IAudioListener pAudioListener)
        {
            if (pAudioListener == null)
            {
                throw new Exception("pAudioListener can't be null!");
            }


            this.Factory       = pFactory;
            this.AudioListener = pAudioListener;

            this.LastQueriedPlayedNotes = new List <MusicalNoteAndTimeStamp>();
            this.SpectrumAnalyzer       = this.Factory.Instantiate <ISpectrumAnalyzer>();
        }
Esempio n. 2
0
        public SpectrumViewModel(RadioViewModel radioViewModel, ISpectrumAnalyzer spectrumAnalyzer)
        {
            _radioViewModel  = radioViewModel;
            SpectrumAnalyzer = spectrumAnalyzer;

            Resolutions = new ObservableCollection <ResolutionBandwidth>();
            for (uint i = 0; i < 8; i++)
            {
                Resolutions.Add(new ResolutionBandwidth()
                {
                    Resolution = Extensions.Pow(2, i)
                });
            }

            if (SpectrumAnalyzer != null)
            {
                SpectrumAnalyzer.BandwidthChanged += (range, value) =>
                {
                    if (_updating)
                    {
                        return;
                    }

                    // var shift = TransformFromChartSamples(value);
                    // var bandwidth = TransformFromChartSamples(range.End) - TransformFromChartSamples(range.Start);

                    var shift     = value;
                    var bandwidth = range.End - range.Start;

                    if ((shift >= long.MinValue && shift <= long.MaxValue) &&
                        (bandwidth >= uint.MinValue && bandwidth <= uint.MaxValue))
                    {
                        Shift     = (long)shift;
                        Bandwidth = (uint)bandwidth;

                        Update();
                    }
                };

                SpectrumAnalyzer.NotchChanged += (range, value) =>
                {
                    var bandwidth = range.End - range.Start;
                };
            }
        }
        private void btnSpeOpen_Click(object sender, RoutedEventArgs e)
        {
            SpectrumAnalyzerType type = (SpectrumAnalyzerType)(this.cmbSpeType.SelectedIndex);
            string addr = this.tbSpeAddr.Text;

            if (!isSpectrumMeterConnected)
            {
                spectrumAnalyzer         = SpectrumAnalyzer.GetInstance(type);
                isSpectrumMeterConnected = spectrumAnalyzer.Connect(addr);
                if (isSpectrumMeterConnected)
                {
                    this.btnSpeOpen.Background = sucessColor;
                }
                else
                {
                    this.btnSpeOpen.Background = normalColor;
                }
            }
            else
            {
                this.btnSpeOpen.Background = sucessColor;
            }
        }
Esempio n. 4
0
        public RadioViewModel(RadioModel model, ISpectrumAnalyzer spectrumAnalyzer, ISweeperAnalyzer sweeperAnalyzer)
        {
            SpectrumAnalyzer = spectrumAnalyzer;
            SweeperAnalyzer  = sweeperAnalyzer;

            SpectrumAnalyzer.BandwidthChanged += (range, value) =>
            {
                var bandwidth = range.End - range.Start;
                //var halfBand = bandwidth/2;
                //var shift = range.Start + halfBand;

                IfBandwidthValue = (uint)bandwidth;
                IfShiftValue     = (int)value;
            };

            SpectrumAnalyzer.NotchChanged += (range, value) =>
            {
                var bandwidth = range.End - range.Start;

                NotchBandwidth = (uint)bandwidth;
                NotchFrequency = (int)value;
            };

            _model = model;
            _model.FftAnalyzer.FftCalculated += FftAnalyzer_FftCalculated;
            MeterView     = new MeterViewModel();
            RecordingView = new RecordingViewModel(_model);
            BlockScanView = new BlockScanViewModel(_model, this);
            SweepView     = new SweeperViewModel(_model, this);
            MemoryView    = new MemoryViewModel(_model, this);

            CommandDefeatSquelch   = new DelegateCommand(() => SquelchValue = G313RadioLimits.SQUELCH_MIN);
            CommandDefeatIfGain    = new DelegateCommand(() => IfGainValue = G313RadioLimits.IFGAIN_MIN);
            CommandDefeatAfSquelch = new DelegateCommand(() => AfSquelchValue = G313RadioLimits.AF_SQUELCH_MIN);
            CommandTuneToPeak      = new DelegateCommand(() => FrequencyValue = (uint)(MeterView.PeakFrequencyValue * 1000000));

            CommandNextStep        = new DelegateCommand(() => FrequencyValue += FrequencyStep);
            CommandNextTenStep     = new DelegateCommand(() => FrequencyValue += (FrequencyStep * 10));
            CommandPreviousStep    = new DelegateCommand(() => FrequencyValue -= FrequencyStep);
            CommandPreviousTenStep = new DelegateCommand(() => FrequencyValue -= (FrequencyStep * 10));

            CommandSpectrumZoomIn  = new DelegateCommand(() => SpectrumAnalyzer.ZoomIn());
            CommandSpectrumZoomOut = new DelegateCommand(() => SpectrumAnalyzer.ZoomOut());
            CommandSweeperZoomIn   = new DelegateCommand(() => SweeperAnalyzer.ZoomIn());
            CommandSweeperZoomOut  = new DelegateCommand(() => SweeperAnalyzer.ZoomOut());

            CommandIfShiftReset = new DelegateCommand(() => IfShiftValue = 0);

            CommandOpenSetup = new DelegateCommand(() =>
            {
                var settings = new SettingsWindow(_model);
                settings.ShowDialog();

                ReInitDataContext();
            });

            NotchBandwidth = _model.Radio.Demodulator().NotchFilter().Bandwidth;
            NotchFrequency = _model.Radio.Demodulator().NotchFilter().Frequency;
            NotchState     = _model.Radio.Demodulator().NotchFilter().Active;

            BlankerThreshold = (uint)_model.Radio.Demodulator().NoiseBlanker().Threshold;
            BlankerState     = _model.Radio.Demodulator().NoiseBlanker().Active;

            SquelchValue = G313RadioLimits.SQUELCH_MIN;

            VideoPoints = 1000;

            FrequencyStep = 500;

            SoftwareAgcState = Agc.Off;

            MuteState = true; //start as muted

            FrequencyValue = _model.Settings.StartFrequency;

            VolumeValue = _model.Radio.Demodulator().Volume();
        }
Esempio n. 5
0
 public IfSpectrumViewModel(RadioViewModel radioViewModel, ISpectrumAnalyzer spectrumAnalyzer)
     : base(radioViewModel, spectrumAnalyzer)
 {
     SelectedResolution = Resolutions.ToArray <ResolutionBandwidth>()[3];
 }