Example #1
0
 private void _source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
 {
     if (e.Property == Audion.SourceProperty.Position)
     {
         Dispatcher.BeginInvoke((Action) delegate
         {
             UpdateWaveform();
         });
     }
     else if (e.Property == Audion.SourceProperty.PlaybackState)
     {
         if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Stopped)
         {
             wavelengthDataSnapshot = null;
             cachedSeconds          = 0;
             cachedPosition         = 0;
             byteToResolutionRatio  = 0;
         }
     }
     else if (e.Property == Audion.SourceProperty.RecordingState)
     {
         if ((RecordingState)e.Value == RecordingState.Stopped)
         {
             wavelengthDataSnapshot = null;
             cachedSeconds          = 0;
             cachedPosition         = 0;
             byteToResolutionRatio  = 0;
         }
     }
 }
Example #2
0
        private void Output_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
        {
            switch (e.Property)
            {
            case ESourceProperty.PlaybackState:
                if (output != null && output.Position == output.Length && (PlaybackState)e.Value == PlaybackState.Stopped)
                {
                    output.Stop();
                    Application.Current.Dispatcher.Invoke(delegate
                    {
                        PlayPauseImg.Source = new BitmapImage(new Uri("pack://application:,,,/Resources/play.png"));
                    });

                    var selected = ListBoxVm.soundFiles.Where(x => x.FullPath.Equals(output.FileName)).FirstOrDefault();
                    if (selected is ListBoxViewModel2 s)
                    {
                        int index = ListBoxVm.soundFiles.IndexOf(s);
                        if (index < ListBoxVm.soundFiles.Count - 1)
                        {
                            Application.Current.Dispatcher.Invoke(delegate
                            {
                                Sound_LstBox.SelectedIndex = index + 1;
                                OnPlayPauseClick(sender, null);
                            });
                        }
                    }
                }
                break;
            }
        }
Example #3
0
 private void _source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
 {
     if (e.Property == Audion.SourceProperty.WaveformData)
     {
         Dispatcher.Invoke((Action) delegate
         {
             UpdateWaveform();
         }, System.Windows.Threading.DispatcherPriority.ApplicationIdle, null);
     }
 }
Example #4
0
 private void _source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
 {
     if (e.Property == Audion.SourceProperty.FftData)
     {
         UpdateSpectrum(_spectrumResolution, _source.FftData);
     }
     else if (e.Property == Audion.SourceProperty.PlaybackState && (PlaybackState)e.Value == PlaybackState.Playing)
     {
         CreateBars();
     }
     else if (e.Property == Audion.SourceProperty.RecordingState && (RecordingState)e.Value == RecordingState.Recording)
     {
         CreateBars();
     }
     else if (e.Property == Audion.SourceProperty.PlaybackState && (PlaybackState)e.Value != PlaybackState.Playing)
     {
         SilenceBars();
     }
     else if (e.Property == Audion.SourceProperty.RecordingState && (RecordingState)e.Value == RecordingState.Stopped)
     {
         SilenceBars();
     }
 }
Example #5
0
        private void _source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
        {
            if (e.Property == Audion.SourceProperty.Position)
            {
                TimeSpan position = (TimeSpan)e.Value;
                Dispatcher.BeginInvoke((Action) delegate
                {
                    Position = position;

                    if (lengthGrid != null && progressLine != null)
                    {
                        var x = 0d;

                        if (_source.Length.TotalMilliseconds != 0)
                        {
                            double progressPercent = position.TotalMilliseconds / _source.Length.TotalMilliseconds;
                            x = progressPercent * lengthGrid.RenderSize.Width;
                        }

                        progressLine.Width = x;
                    }
                });
            }
        }
Example #6
0
        private void _source_SourcePropertyChangedEvent(object sender, SourcePropertyChangedEventArgs e)
        {
            if (timeText != null)
            {
                if (e.Property == SourceProperty.PlaybackState)
                {
                    _activeSource = sender as ISource;

                    /*if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Playing)
                     * {
                     *  _activeSource = sender as ISource;
                     * }
                     * else if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Paused)
                     * {
                     *  _activeSource = sender as ISource;
                     * }
                     * else if ((CSCore.SoundOut.PlaybackState)e.Value == CSCore.SoundOut.PlaybackState.Stopped)
                     * {
                     *  _activeSource = null;
                     * }*/

                    // Calculate the time elapsed and remaining time of the queue.
                    var index = SourceCollection.IndexOf(_activeSource);

                    _elapsedTotal   = TimeSpan.Zero;
                    _remainingTotal = TimeSpan.Zero;

                    if (index == -1)
                    {
                        // There is no active source, so the elapsed time will be 0 and the remaining
                        // will be the length of the entire queue.
                        _remainingTotal = TimeSpan.FromTicks(SourceCollection.Sum(x => x.Length.Ticks));
                    }
                    else
                    {
                        // There is an active source, so we need to sum all of the sources before
                        // and after the active source to get the elapsed and remaining times.
                        for (var i = 0; i < SourceCollection.Count; i++)
                        {
                            var source = SourceCollection[i];

                            if (i < index)
                            {
                                // add to elapsed time.
                                _elapsedTotal += source.Length;
                            }
                            else if (i > index)
                            {
                                // add to remaining time.
                                _remainingTotal += source.Length;
                            }
                        }
                    }
                }

                if (e.Property == Audion.SourceProperty.Position)
                {
                    CalculateTime();
                }
            }
        }