Reputation: 6379
My code is pretty simple - but the event never fires!
_msWaveInput = new()
{
DeviceNumber = validDeviceNumber,
WaveFormat = new NAudio.Wave.WaveFormat(rate: 48000, bits: 16, channels: 2),
NumberOfBuffers = 1,
BufferMilliseconds = bufferSizeMs
};
_msWaveInput.DataAvailable += WaveIn_DataAvailable;
_msWaveInput?.StartRecording();
private void WaveIn_DataAvailable(object? sender, WaveInEventArgs e)
{
// never fires!
}
If it's relevant, this is a console app ... :
<PropertyGroup>
<OutputType>Exe</OutputType>
<TargetFramework>net6.0-windows</TargetFramework>
<ImplicitUsings>enable</ImplicitUsings>
<Nullable>enable</Nullable>
<Platforms>AnyCPU;x64</Platforms>
</PropertyGroup>
... with NAudio 2.1:
<PackageReference Include="NAudio" Version="2.1.0" />
The device numbers are made available with another simple piece of NAudio standard code:
for (int i = -1; i < NAudio.Wave.WaveIn.DeviceCount; i++)
{
// i is the device number - I have tried them all!
}
Upvotes: 0
Views: 137