尝试将各种音频文件混合到一个
我已经这样写了
lstOfReaderOBJs.Add(Reader1(0))
lstOfReaderOBJs.Add(Reader1(1))
lstOfReaderOBJs.Add(Reader1(2))
但是我想将其放在for next循环中,以使数量可变,因此NumberOfAudioFiles
Private Sub Button7_Click(sender As Object, e As EventArgs) Handles Button7.Click
Dim NumberOfAudioFiles As Integer = 2
Dim Reader1(NumberOfAudioFiles) As AudioFileReader
Reader1(0) = New AudioFileReader("C:\Users\Server\Desktop\Singing Stuff\Piano Tones\Wav\0-3.wav")
Reader1(1) = New AudioFileReader("C:\Users\Server\Desktop\Singing Stuff\Piano Tones\Wav\4-3.wav")
Reader1(2) = New AudioFileReader("C:\Users\Server\Desktop\Singing Stuff\Piano Tones\Wav\7-3.wav")
Dim lstOfReaderOBJs As New List(Of AudioFileReader)
For I = 0 To NumberOfAudioFiles
lstOfReaderOBJs.Add(Reader1(NumberOfAudioFiles))
'lstOfReaderOBJs.Add(Reader1(NumberOfAudioFiles))
'lstOfReaderOBJs.Add(Reader1(NumberOfAudioFiles))
Next
Dim mixer = New MixingWaveProvider32(lstOfReaderOBJs)
WaveFileWriter.CreateWaveFile("C:\Users\Server\Desktop\Singing Stuff\Piano Tones\Wav\mixed.wav", mixer)
End Sub
当我将lstOfReaderOBJs.Add(Reader1(NumberOfAudioFiles))与for next循环一起放入时,列表中仅获得一个ReaderObject,并且是最后一个而不是全部三个ReaderObject。
答案 0 :(得分:1)
只需像这样使用循环变量I
:
For I = 0 To NumberOfAudioFiles
lstOfReaderOBJs.Add(Reader1(I))
Next