示例#1
0
        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);
            }));
        }