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

Commented Unassigned: 32bit PCM into 16bit PCM [16397]

$
0
0
How can i convert 32 bit PCM wave into 16 bit PCM??

I was making software to record system volume using LoopBackCapture. Its capturing data of 32 bit PCM ( 32 bit PCM: 48kHz 2 channels wBitsPerSample:32 dwChannelMask:3 subFormat:00000003-0000-0010-8000-00aa00389b71 extraSize:22 )

I want to convert it into a 16 bit stereo data....I am not able to get it...

Its my code to convert the data from 32 bit PCM into 16 bit PCM. I am getting some noises and some real song data. Need help...

```
Private Function FX32TO16(ByVal input As Byte(), ByVal len As Integer) As Byte()
Dim output As Byte() = New Byte(len / 2 - 1) {}
Dim outputIndex As Integer = 0
For n As Integer = 0 To len - 1 Step 4
output(outputIndex) = input(n + 2)
output(outputIndex + 1) = input(n + 3)
outputIndex += 2
Next
Return output
End Function
```
Comments: you need to understand audio bit depths if you want to write the conversion code yourself. You can't just throw away two out of every four bytes and expect it to work. Please read my article here for more information: http://www.codeproject.com/Articles/501521/How-to-convert-between-most-audio-formats-in-NET Alternatively, just use WaveFloatTo16Provider

Viewing all articles
Browse latest Browse all 738

Trending Articles



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