tjscience / audion.cscore

An audio visualization and processing framework for WPF
MIT License
33 stars 7 forks source link

Slowed down Waveform loading #2

Closed filoe closed 7 years ago

filoe commented 7 years ago

Why do you slow down the loading process of the waveform by adding Thread.Sleep? https://github.com/tjscience/audion/blob/master/Audion/Source.cs#L209

tjscience commented 7 years ago

I added the sleep, which only gets figured in at higher resolutions so that, the drawing of the waveform was not choppy. If you remove the sleep and crank up the Resolution to 4096, you will not see it progressively drawn. Instead it takes several seconds and then the whole waveform is drawn at once. I am open to other suggestions but this was a quick way to get the desired result that I was after.

Mitra-M commented 7 years ago

@tjscience , for draw progressively , remove Thread.Sleepfrom source.csand change _source_SourcePropertyChangedEvent(in waveform.cs) like this:

  ` private void _source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
    {
        if (e.Property == Source.Property.WaveformData)
        {
          //  Dispatcher.BeginInvoke((Action)delegate
          //  {
          //      UpdateWaveform();
          //  });
            Dispatcher.Invoke((Action)delegate { UpdateWaveform(); }, System.Windows.Threading.DispatcherPriority.ApplicationIdle, null);
        }
    }`

With these changes, it will be much more speed and will also progressively waveform is drawn.

(sorry for my bad English)

tjscience commented 7 years ago

Thanks for the suggestions! I will try them out. I am currently going through and refactoring a ton so these changes will be welcome.