void recorder_MaximumCalculated(object sender, MaxSampleEventArgs e) { SamplePoint newSample = new SamplePoint(); newSample.sampleNum = sampleData.Count; newSample.sampleVal = Math.Max(e.MaxSample, Math.Abs(e.MinSample)); sampleData.Add(newSample); RaisePropertyChanged("SampleData"); RaisePropertyChanged("XRange"); }
void recorder_MaximumCalculated(object sender, MaxSampleEventArgs e) { SamplePoint newSample = new SamplePoint(); newSample.sampleNum = currentTrackSamples.Count; newSample.sampleVal = Math.Max(e.MaxSample, Math.Abs(e.MinSample)); currentTrackSamples.Add(newSample); RaisePropertyChanged("CurrentTrackData"); RaisePropertyChanged("CurrentTrackXRange"); lastPeak = Math.Max(e.MaxSample, Math.Abs(e.MinSample)); RaisePropertyChanged("CurrentInputLevel"); }
private void newTrack() { this.uiDispatcher.Invoke(new Action(delegate() { if (this.audioTracks.Count() > 0) { if (this.currentAudioTrack.State != AudioTrackState.Loaded) { return; } this.currentAudioTrack.Save(); BindableSamplePointCollection newBackgroundSamples = new BindableSamplePointCollection(); for (int i = 0; i < Math.Max(currentTrackSamples.Count, backgroundTrackSamples.Count); ++i) { SamplePoint sample = new SamplePoint(); double backVal = (backgroundTrackSamples.Count > i) ? backgroundTrackSamples[i].sampleVal : 0.0; double curVal = (currentTrackSamples.Count > i) ? currentTrackSamples[i].sampleVal : 0.0; sample.sampleVal = Math.Min(backVal + curVal, 1.0); sample.sampleNum = i; newBackgroundSamples.Add(sample); } backgroundTrackSamples = newBackgroundSamples; RaisePropertyChanged("BackgroundTrackData"); RaisePropertyChanged("BackgroundTrackXRange"); this.currentAudioTrack.SampleAggregator.MaximumCalculated -= new EventHandler <MaxSampleEventArgs>(recorder_MaximumCalculated); } AudioTrack audioTrack = new AudioTrack(micIndex, this.projectDirectory); audioTrack.SampleAggregator.MaximumCalculated += new EventHandler <MaxSampleEventArgs>(recorder_MaximumCalculated); this.audioTracks.Add(audioTrack); })); }