Naudio WaveFileReader.Read()没有填充byte []缓冲区

时间:2017-06-06 14:30:46

标签: c# naudio

class Question
  belongs_to :author, class_name: 'User'
end

class User
  has_many :questions, inverse_of: :author
end

以上代码输出

Console.WriteLine("Audio file path : " + audioFilePath);
NAudio.Wave.WaveFileReader reader = new NAudio.Wave.WaveFileReader(audioFilePath);
Console.WriteLine("Reading file of length : " + reader.Length);
byte[] buffer = new byte[reader.Length];
Console.WriteLine("created buffer of size : " + buffer.Length);
reader.Read(buffer, 0, buffer.Length);
Console.WriteLine("data read to buffer : " + readBuffer(buffer));

如果我改变了行

Audio file path : C:\Users\Me\Desktop\testAudio.wav
Reading file of length : 12349440
created buffer of size : 12349440

Console.WriteLine("data read to buffer : " + readBuffer(buffer));

输出变为

Console.WriteLine("data read to buffer");

readBuffer()只是

Audio file path : C:\Users\Me\Desktop\testAudio.wav
Reading file of length : 12349440
created buffer of size : 12349440
data read to buffer

如果我删除缓冲区的控制台打印,执行会挂起使用缓冲区的任何一行,在这种情况下,下一行是public static string readBuffer(byte[] buffer) { string stringResult = ""; for (int i = 0; i < buffer.Length; i++) { stringResult += buffer[i]; } return stringResult; }

有什么想法吗?

0 个答案:

没有答案