当我播放音频文件(波形)时,我口吃了。
我尝试更改要链接在一起的ISampleProviders的实例化顺序。
公共属性FilePath()作为字符串 得到 返回m_FilePath 结束获取
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
在此代码中,我链接ISampleProviders并将它们传递给WaveOut.Init,每次加载新文件时。我先停止WaveOut。
期望流畅的聆听体验(听写)。 实际结果:播放断断续续。
答案 0 :(得分:1)
这解决了我的问题:每次停止播放时,都会破坏信号链。再次开始播放时,我会重建信号链。