.DAT File from DDP Fileset

Nov 10, 2012 at 12:40 AM

Hi Mark,

I was wondering if NAudio would playback a .DAT File from a DDP fileset?

The format for the DAT file from DDP is always 44.1 Stereo 16bit.

Thanks, Wyatt

Coordinator
Nov 10, 2012 at 7:46 AM

Is it PCM, and is the byte ordering little endian? If so you could just use a RawSourceAudioStream, passing in a new WaveFormat(44100,16,2) and a FileStream to the .DAT file.

Mark

Nov 10, 2012 at 7:45 PM
Edited Nov 11, 2012 at 5:26 PM

Would it be possible to do this from the source, like was metioned in this thread?

http://naudio.codeplex.com/discussions/254145

Edit: Or could I get some kind of example from this post?

http://naudio.codeplex.com/discussions/85827

or how could I use it in this code?

    Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
        If Label1.Text = Nothing Then
            Dim wavFile As String
            OpenWavFile.InitialDirectory = ""
            wavFile = OpenWavFile.ShowDialog()
            wavFile = OpenWavFile.FileName
            Label1.Text = wavFile
        Else
            wave = New NAudio.Wave.WaveFileReader(Label1.Text)
            output = New AsioOut(comboBoxAsioDriver.Text)
            output.Init(New NAudio.Wave.WaveChannel32(wave))
            output.Play()
            btnPlay.Enabled = False
        End If
    End Sub

Nov 12, 2012 at 5:06 AM

I've tried to figure this out. Does this look correct?

    Private Sub btnPlay_Click(sender As Object, e As EventArgs) Handles btnPlay.Click
        If Label1.Text = Nothing Then
            Dim wavFile As String
            OpenWavFile.InitialDirectory = ""
            wavFile = OpenWavFile.ShowDialog()
            wavFile = OpenWavFile.FileName
            Label1.Text = wavFile
        Else
            Dim file As New FileStream(Label1.Text, FileMode.Open, FileAccess.Read)
            Dim format As New WaveFormat(44100, 16, 2)
            Dim rawStream As New RawSourceWaveStream(file, format)

            output = New AsioOut(comboBoxAsioDriver.Text)
            output.Init(New NAudio.Wave.WaveChannel32(rawStream))
            output.Play()
            btnPlay.Enabled = False
        End If
    End Sub

Coordinator
Nov 12, 2012 at 7:10 AM

yes this is fine, although the WaveChannel32 is redundant in this case. Also, only use ASIO if you have a particular need for very low latency.