Reputation: 39
When I playback an audio file (Wave), I here stuttering.
I tried changing the order of instantiation of the ISampleProviders I am chaining together.
Public Property FilePath() As String Get Return m_FilePath End Get
Set(ByVal New_FilePath As String)
Try
Dim nCount As Integer = 0
Dim retval As Integer = 0
If New_FilePath.Length = 0 Then
DisposeInputResources()
m_FilePath = ""
ChangeStatus_Controls(False)
Exit Property
End If
PositionTrackBar.Value = 0
m_Position = 0
m_LastPosition = 0
durationLabel.Text = ConvertTime(0)
m_FilePath = New_FilePath
DisposeInputResources()
AudioFileReader1 = New AudioFileReader(FilePath)
playerStatus = PhilipsStatus.stopped
SpeedControl = New VarispeedSampleProvider(AudioFileReader1, 100, New SoundTouchProfile(False, False))
SpeedControl.PlaybackRate = 1
AutomaticGainControl = New SoftLimiter(SpeedControl)
AutomaticGainControl.Boost.CurrentValue = fileAmplificationTrackBar.Value / 2
'AudioFileReader1 = New AudioFileReader(FilePath)
'Equalizer1 = New EqualizerClass(AudioFileReader1, bands)
'SpeedControl = New VarispeedSampleProvider(Equalizer1, 100, New SoundTouchProfile(False, False))
'SpeedControl.PlaybackRate = 1
'VolumeSampleProvider1 = New VolumeSampleProvider(SpeedControl)
audioLengthLabel.Text = ConvertTime(AudioFileReader1.TotalTime.TotalSeconds)
AudioFileReader1.CurrentTime = TimeSpan.Zero
If WaveOut1 IsNot Nothing Then WaveOut1.Stop()
WaveOut1 = New WaveOutEvent()
WaveOut1.Init(AutomaticGainControl)
Thread.Sleep(1000)
nCount = 60
Volume = m_Volume
Speed = m_Speed
Position = 0
PressStopKey()
Dim sWAVFileName As String = Nothing
If Path.GetExtension(New_FilePath).ToUpper() = ".DSS" Then
sWAVFileName = Path.ChangeExtension(New_FilePath, "WAV")
'I assume that ConvertDSSToWAV() has already been called to convert the .DSS to .WAV if necessary
New_FilePath = sWAVFileName
m_FilePath = sWAVFileName
End If
PositionTrackBar.Maximum = AudioFileReader1.TotalTime.TotalSeconds
PositionTrackBar.Minimum = 0
PositionTrackBar.LargeChange = PositionTrackBar.Maximum * 0.1
If PositionTrackBar.LargeChange = 0 Then PositionTrackBar.LargeChange = 1
PositionTrackBar.SmallChange = PositionTrackBar.Maximum * 0.01
If PositionTrackBar.SmallChange = 0 Then PositionTrackBar.SmallChange = 1
PositionTrackBar.TickFrequency = PositionTrackBar.SmallChange
ChangeStatus_Controls(True)
Catch ex As Exception
MessageBox.Show("Property Set FilePath(New_FilePath= " & New_FilePath & ")" & vbCrLf & ex.Message, "FootPedalsControl", MessageBoxButtons.OK, MessageBoxIcon.Error)
End Try
End Set
End Property
in this code, I chain the ISampleProviders and pass them to WaveOut.Init each time i load a new file. I stop the WaveOut first.
Expecting a smooth listen experience (dictation). Actual Results: The playback stutters.
Upvotes: 1
Views: 365
Reputation: 39
This solved my problem: Each time I stop the playback, I destroy the signal chain. When playback is initiated again, I rebuild the signal chain.
Upvotes: 2