Replies: 2 comments
-
Mark, Am I not using NAudio correctly, or are the above issues bugs? |
Beta Was this translation helpful? Give feedback.
-
Just in case anyone else is wondering, the G722 issue was with the factors: the buffer size has to be divided by 4, and the short buffer size by 2. Then it works. 16000/16/1 compresses 4x times, and by using the appropriate flag it is possible to use 8000/16/1 input. The end result is the same, in both cases, so the former probably provides better sound quality. As to changing the output device, the player has to be disposed and re-created. Then it plays to the new device ID. |
Beta Was this translation helpful? Give feedback.
-
I used NAudio to implement a simplistic building intercom, and it works fabulously, as long as I send and receive captured audio frames as-is. I also contemplated compression but faced a problem of sound becoming unintelligible.
In any combination of settings, the voice becomes low-volume, and it is overlain with either loud rapid chirping or clicks.
In the best case scenario, it is loud clicks in the foreground and quiet voice in the background. In the worst case, it is nothing but rapid chirping.
For the best case, I have to set G722 codec to
64kbps Packed
and recorder to 16kHz 16bit. Compression ends up being 2x.I achieve the same compressed size of every buffer as with 8kHz, so it does not make sense to compress even if it produced perfect sound. Is there any way to compress 8kHz source to a clear sound, with NAudio's G722 codec?
Also, I can switch microphone input without issues, using this code:
But if I try to do the same to the speaker output it does nothing at all:
I can see, in the debugger, that the value is assigned correctly and successfully, but the playback continues through the initial device which is system default. What am I doing wrong with the player?
Here is my G722 compression MWE. It saves 2x files: a raw file that can be imported into Audacity and played back, and a .722 file that VLC can play. It also plays exactly the same through NAudio's player class. In the .722 file, my voice is delayed, quiet, and breaking at times.
```
using Microsoft.VisualStudio.TestTools.UnitTesting;
using NAudio.Codecs;
using NAudio.Wave;
using System;
using System.Diagnostics;
using System.IO;
using System.Threading;
namespace Test
{
[TestClass]
public class UnitTestRecording
{
WaveIn recorder;
}
Beta Was this translation helpful? Give feedback.
All reactions