public ControlPanelViewModel(IWaveFormRenderer waveFormRenderer, SpectrumAnalyser analyzer) { this.waveFormRenderer = waveFormRenderer; this.analyzer = analyzer; this.context = new InstanceContext(new SpectrumCallback()); this.client = new AnalyzerProxyDetails.DetalisClient(context); SpectrumCallbackFftHandler callbackFftHandler = new SpectrumCallbackFftHandler(fftCalculated); SpectrumCallbackMaxSampleHandler callbackMaxSampleHandler = new SpectrumCallbackMaxSampleHandler(onMaxSampleCalculated); Mp3RequestHandler callbackMp3Handler = new Mp3RequestHandler(onMp3Sample); PcmRequestHandler callbackPcmHandler = new PcmRequestHandler(onPcmBuffer); CatcherCallBackFftEvent += callbackFftHandler; CatcherCallBackMaxSampleEvent += callbackMaxSampleHandler; CatcherCallBackMp3RequestEvent += callbackMp3Handler; CatcherCallBackPcmRequestEvent += callbackPcmHandler; this.captureSeconds = 5; this.client.Open(); CaptureCommand = new RelayCommand( () => this.Capture(), () => true); StopCommand = new RelayCommand( () => this.Stop(), () => true); PlayFileCommand = new RelayCommand( () => this.Play(), () => true); }
// Awake Method void Awake() { #region SINGLETON_PATTERN // Check if there are any other instances conflicting if (Instance != null && Instance != this) { // if tha tis the case, we destroy other instances Destroy(gameObject); } // Save singleton instance Instance = this; // Don't destroy this intance between scenes DontDestroyOnLoad(gameObject); #endregion }
private void Button_Click(object sender, RoutedEventArgs e) { if (testRecorder != null) { testRecorder.StopRecording(); } SpectrumAnalyser analyser = new SpectrumAnalyser(11); analyser.OpenFile(@"./wav/test.wav"); analyser.AnalyseFile(); var spectrogram = analyser.Spectrogram; var bitmap = spectrogram.DrawSpectogram(); this.image.Source = bitmap; spectrogram.SaveToTxtFile(@"./txt/spectrogram.txt"); }