Quantcast
Channel: naudio Work Item Rss Feed
Viewing all articles
Browse latest Browse all 738

Commented Unassigned: raw file play very fast using NAudio Library [16425]

$
0
0
i m successfully write raw data to serial port with NAudio Library here is my code,

Dim rawStream = File.OpenRead("c:\myfile.raw")
Dim waveFormat = New NAudio.Wave.WaveFormat(8000, 16, 1)

Dim rawSource = New RawSourceWaveStream(rawStream, waveFormat)

Dim buffer As Byte() = New Byte(rawSource.Length) {}

Dim n As Integer = 2
For x As Integer = 0 To buffer.Length - n - 1 Step n
Application.DoEvents()
Dim bytesRead As Integer = rawSource.Read(buffer, 0, x)
If bytesRead > 0 Then

SP1.Write(buffer, 0, bytesRead)

End If

Thread.Sleep(40)

Next
this code works fine only problem i m able to hear raw file to my mobile but play raw file very fast i use thread.sleep and application.DoEvents() but it still play very fast please guide me how to write data with normal speed
Comments: if you are sending raw audio via serial port, then it must match exactly the sample rate, bit depth and channel count whatever on the other end is expecting. Also, NAudio is completely superfluous in this example. Just send your raw stream directly

Viewing all articles
Browse latest Browse all 738

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>