well I can't see anything wrong with your code. If your WaveFormat is the same as the one that NAudioDemo uses, then it should work. Possibly there is an issue with CreateWaveFile. Try this code and step through it in the debugger and see what you are managing to read. It might be that the buffer size might need to be set to an exact multiple of blockAlign. (e.g. 1024 bytes)
public static void CreateWaveFile(string filename, IWaveProvider sourceProvider)
{
using (WaveFileWriter writer = new WaveFileWriter(filename, sourceProvider.WaveFormat))
{
byte[] buffer = new byte[sourceProvider.WaveFormat.AverageBytesPerSecond * 4];
while (true)
{
int bytesRead = sourceProvider.Read(buffer, 0, buffer.Length);
if (bytesRead == 0)
break;
writer.Write(buffer, 0, bytesRead);
}
}
}