Quantcast
Channel: NAudio
Viewing all 5831 articles
Browse latest View live

New Post: Need help saving .wav file from RTP G711

$
0
0
I'm having a problem with NAudio 1.8 when creating a .wav file from a G711 RTP stream. Can anyone help?

The wav files created by NAudio have loud machine-gun noise that obscures the voice audio. Intelligible audio is present, but it's masked by the pulsating, clicking noise. Wireshark plays audio from the pcap files without a problem. Wireshark shows the sample rate is 8K ulaw.

Here's my code:

if (wavOutput == null)
{
string today = DateTime.Now.ToString("yyyy-MM-dd");
wavOutput = new WaveFileWriter("D:\Calls\" + today + "\" + CallID + ".wav", new WaveFormat(8000, 16, 1));
}

for (int index = 0; index < udpPacket.PayloadData.Length; index++)
{
short pcm = MuLawDecoder.MuLawToLinearSample(udpPacket.PayloadData[index]);
wavOutput.WriteByte((byte)(pcm & 0xFF));
wavOutput.WriteByte((byte)(pcm >> 8));

}


New Post: playing a .wav file stored as an embedded resource and controlling playback volume

$
0
0
Use the extension WaveFileReader".ToSampleProvider", which will convert it in a sample based stream. Then pass this to a new VolumeSampleProvider, where you can set the volume of the stream internally, and finally play this stream witch an IWavePlayer.

=> Signal chain:

WaveFileReader -> .ToSampleProvider -> VolumeSampleProvider -> IWavePlayer.

New Post: ACC or MP4 to MP3

$
0
0
NAudio doesnt include an MP3 Encoder directly.

Your only option could be the "MediaFoundationEncoder" oder respectively ACM class, which use the mp3 codecs of your os for encoding when available.

New Post: Need help saving .wav file from RTP G711

$
0
0
The error is in these lines I assume:
wavOutput.WriteByte((byte)(pcm & 0xFF));
wavOutput.WriteByte((byte)(pcm >> 8));
Rest seems correct to me. I recommend to use "bitconverter.getbytes()" instead.

New Post: Help on using BufferedWaveProvider

$
0
0
If you dont know the waveformat, you cant process the data ... lol

New Post: Need help saving .wav file from RTP G711

$
0
0
Freefall, thanks for the idea. Unfortunately, I get the same result when using bitconverter.getbytes(). Also, I confirmed I am calling wavOutput.Dispose(). Other ideas?

New Post: Help on using BufferedWaveProvider

$
0
0
Gotcha... thanks after a day of messing around I found out what I need to do. Now on to other things. Karin

New Post: Need help saving .wav file from RTP G711

$
0
0
Noise may be also caused by the g711 compression, anyway, if wireshark plays it better there might be a bug in the NAudio mulaw decoder...

New Post: playing a .wav file stored as an embedded resource and controlling playback volume

$
0
0
wow! That looks great, will give that a try. Thanks!

New Post: EQ Bandwidth

$
0
0
Q is the parameter for the width of the frequency filter. The higher, the more frequencies around are affected, the lower less frequencies or even just the selected frequency are affected.

This video explains that quite well without the maths: https://www.youtube.com/watch?v=hNVdvsOEF7w

New Post: Need help saving .wav file from RTP G711

$
0
0
I am having the exact same issue. It does not matter if I convert my file using nAudio, Sox, Switch, Audacity, whatever, it comes out with the exact same sound as described by Daryl. The only way the audio comes out clean is when I play it or convert it in Wireshark.

I really want to make nAudio work as it is a simple clean solution I can put into my app.

Wireshark shows this:
Payload type: ITU-T G.711 PCMU (0)
Sample Rate (Hz): 8000

I am using the following nAudio code from my app:
        Stream tmpMemStream = new FileStream(inFileName, FileMode.Open, FileAccess.Read);
        var waveFormat = WaveFormat.CreateMuLawFormat(8000, 1);
        var reader = new RawSourceWaveStream(tmpMemStream, waveFormat);
        using (WaveStream convertedStream = WaveFormatConversionStream.CreatePcmStream(reader))
        {
            WaveFileWriter.CreateWaveFile(outFileName, convertedStream);
        }
        tmpMemStream.Close();
Still I get that ratcheting noise over my phone call audio which is barely audible in the background.

To assist I have posted the wav file here so you can give it a listen:
https://services.streamwrite.com/images/output.wav

Any help would be greatly appreciated!
-Marco.

New Post: Need help saving .wav file from RTP G711

$
0
0
Hmm, looks like a recurring noise in each paket. You could try to send a silent stream, extract the noise and then subtract it from your voice stream.

New Post: Need help saving .wav file from RTP G711

$
0
0
Some other options: use the managed speex port (NSpeex), the managed vorbis port (NVorbis) or write your own encoder/decoder...

New Post: DirectSoundOut seems to be wrong

$
0
0
Mark includes pull requests on github, codeplex remains just for discussions.

New Post: Record to mp3?

$
0
0
Hello

I'm new to naudio and I want to use it for recording audio as mp3 but so far I found only examples with wav files.

So far I have:
m_WaveSource = new WaveIn();
            m_WaveSource.WaveFormat = new WaveFormat(44100, 1);

            m_WaveSource.DataAvailable += new EventHandler<WaveInEventArgs>(DataAvailable);
            m_WaveSource.RecordingStopped += new EventHandler<StoppedEventArgs>(RecordingStopped);

            m_WaveFile = new WaveFileWriter(strFile, m_WaveSource.WaveFormat);

            m_WaveSource.StartRecording();
 void DataAvailable(object sender, WaveInEventArgs e)
        {
            if (m_WaveFile != null)
            {
                m_WaveFile.Write(e.Buffer, 0, e.BytesRecorded);
                m_WaveFile.Flush();
            }
        }
What do I have to change for getting a mp3 file?

New Post: Record to mp3?

$
0
0
Dude, how about asking google before posting?? As answered 1000 ppl before NAudio does NOT include an MP3 encoder.

You can try the NAudio MediafoundationEncoder class, which depends on your OS, or Lame.

New Post: Transefer function

$
0
0
Hi guys,
I've got a little problem with apllying transfer fuction. I need to take data from .wav file and make convolution with transfer function and play this sound in real time. Thank you for advices. I'm new to NAudio.

New Post: Transefer function

$
0
0
Hi, this is not a trivial task. For realtime processing you can´t process the data in the time domain, which would be simple coding (using the class "ImpulseResponseConvolution"). The only approach is complex and demands a lot of knowledge: you need to transform the data in the frequency domain, process it and transform it back. For transformation the "FastFourierTransform" (FFT) or "ShortTermFourierTransform" (STFT) is commonly used. Unfortunately, there is no implementation available in NAudio, but good luck (and pls provide if you can deploy it).

New Post: Transefer function

$
0
0
Thanks,I thought, I could just fit my input data from wav file to transfer function...

New Post: how to use SimpleCompressorStream?

$
0
0
Hello

I record from the mic and I need to compress & normalize the wav file that I record. I would like to use SimpleCompressorStream for compressing but I can't find any example how to do that. I also wonder how to normalize the file too

At the moment my record method looks like that:
public void Record(String strFile)
    {            
        m_WaveSource = new WaveIn();
        m_WaveSource.WaveFormat = new WaveFormat(44100, 1);

        m_WaveSource.DataAvailable += new EventHandler<WaveInEventArgs>(DataAvailable);
        m_WaveSource.RecordingStopped += new EventHandler<StoppedEventArgs>(RecordingStopped);

        m_WaveFile = new WaveFileWriter(strFile, _WaveSource.WaveFormat);

        m_WaveSource.StartRecording();
    }
       void DataAvailable(object sender, WaveInEventArgs e)
        {
            if (m_WaveFile != null)
            {
                m_WaveFile.Write(e.Buffer, 0, e.BytesRecorded);
                
                double sum = 0;
                for (var i = 0; i < e.BytesRecorded; i = i + 2)
                {
                    double sample = BitConverter.ToInt16(e.Buffer, i) / 32768.0;
                    sum += (sample * sample);
                }
                double rms = Math.Sqrt(sum / (e.BytesRecorded / 2));
                var decibel = 20 * Math.Log10(rms);
                
              
                VolumeMeter.Value = decibel;
                m_WaveFile.Flush();
            }
        }
Viewing all 5831 articles
Browse latest View live


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