JoP
JoP

Reputation: 1

Play 32 bit audio with NAudio and ASIO

I try to play a 32 bit byte array via naudio and ASIO. But i can not get it running. The output signal is distorted. The same converting method works fine with 32 bit for naudio and WASAPI.

Sample convert:

var newAmp = (int)Math.Round(amp * (Math.Pow(2, 32) / 2));
var buffer = BitConverter.GetBytes(newAmp);   

The Play and record via naudio and ASIO:

var waveToneClass = new WaveTone(48000, 32, playBuffer, true, 1);
var stream = new BlockAlignReductionStream(waveToneClass);

asio_outin = new AsioOut(nameOfDriver);
asio_outin.ChannelOffset = 0;               
asio_outin.InputChannelOffset = 0;
asio_outin.InitRecordAndPlayback(stream, 1, 48000);

asio_outin.AudioAvailable += ASIO_dataAvailable;
asio_outin.Play();

with:

private AsioOut asio_outin = null;

With 16 bit and the same method i get a clean Signal. But for very low output levels and a high gain i get artefacts and that´s the reason for 32bit.

NAudio v1.7.3.0 / Windows 7 / .Net 4.0

What is my failure?

Upvotes: 0

Views: 533

Answers (1)

Mark Heath
Mark Heath

Reputation: 49522

There are a number of different ASIO "sample types" available when using 32 bit audio, because often it is just 24 or 20 bit audio placed somewhere in a 32 bit integer. So I suspect that maybe the wrong sample type is being used. Or could it be that you are actually producing IEEE floating point samples which are also 32 bit (and is what WASAPI likes to use).

Upvotes: 0

Related Questions