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

New Post: Is it possible to create an app that does what "Sing!" application does using Naudio?

$
0
0
Hey there!

So i was wondering if i can make an application that does what the application called "Sing!" does?

*This Sing! application can be found in both App store and Android(Play) store.

Thanks!

Created Unassigned: Unsupported Wave Format issues [16479]

$
0
0
I'm trying to mix IEEE signals with an app in exclusive mode, but on some devices it doesn't seem to play sound at all.

Some details:
Bitrates of 16 or 24 work equally well with any sample rate.
The app attempts to use 44.1kHz sample rate. If it fails, it switches to 48kHz.
However, the playback is higher pitched when switching to 48kHz.
The app is runs in exclusive mode by default in an attempt to force 44.1kHz.

So on this device:
http://www.officedepot.com/a/products/488121/HP-Pavilion-X2-2-in-1/
exclusive mode can't find 44.1kHz so it switches to 48kHz upon which it immediately fails and does not play sound at all.

The exception I get is similar to the one I receive when attempting to use the NAudio demo:
https://i.imgur.com/xRLvTEo.png

Any insight would be extremely helpful. Thanks!

Commented Unassigned: Unsupported Wave Format issues [16479]

$
0
0
I'm trying to mix IEEE signals with an app in exclusive mode, but on some devices it doesn't seem to play sound at all.

Some details:
Bitrates of 16 or 24 work equally well with any sample rate.
The app attempts to use 44.1kHz sample rate. If it fails, it switches to 48kHz.
However, the playback is higher pitched when switching to 48kHz.
The app is runs in exclusive mode by default in an attempt to force 44.1kHz.

So on this device:
http://www.officedepot.com/a/products/488121/HP-Pavilion-X2-2-in-1/
exclusive mode can't find 44.1kHz so it switches to 48kHz upon which it immediately fails and does not play sound at all.

The exception I get is similar to the one I receive when attempting to use the NAudio demo:
https://i.imgur.com/xRLvTEo.png

Any insight would be extremely helpful. Thanks!

Comments: Yes, you can't assume your soundcard will necessarily support all wave formats in exclusive mode You need to resample your audio to play at 48kHz if it is 44.1kHz audio

New Post: C# 8 BIT WAV (non RIFF) to MP3 conversion makes 0 bit MP3 - HELP!

$
0
0
Probably best to ask this in the NAudio.Lame project.
I tend to either use lame.exe, or if you are on Win 8 or above you can use MediaFoundationEncoder.ConvertToMp3 to use the built in MP3 encoder in Windows (although it offers limited bitrate options)

New Post: Is it possible to create an app that does what "Sing!" application does using Naudio?

$
0
0
I'm not familiar with Sing!, but playing backing tracks, recording audio and applying effects can all be achieved with NAudio. It will be a fair amount of work though. Also, you didn't say what platform you are targetting.

New Post: Facing issue when recording audio over virtual machines "no driver calling waveinprepareheader".

$
0
0
Try a different event model perhaps? What were you using - WaveIn or WaveInEvent? Could also try Wasapi for capturing

New Post: C# 8 BIT WAV (non RIFF) to MP3 conversion makes 0 bit MP3 - HELP!

$
0
0
I am on a WIN2008 server so Win 8 is not an option.
What is the link to post this question to "NAudio.Lame project" ?
Thanks for your suggestion.
Thomas

Commented Unassigned: Unsupported Wave Format issues [16479]

$
0
0
I'm trying to mix IEEE signals with an app in exclusive mode, but on some devices it doesn't seem to play sound at all.

Some details:
Bitrates of 16 or 24 work equally well with any sample rate.
The app attempts to use 44.1kHz sample rate. If it fails, it switches to 48kHz.
However, the playback is higher pitched when switching to 48kHz.
The app is runs in exclusive mode by default in an attempt to force 44.1kHz.

So on this device:
http://www.officedepot.com/a/products/488121/HP-Pavilion-X2-2-in-1/
exclusive mode can't find 44.1kHz so it switches to 48kHz upon which it immediately fails and does not play sound at all.

The exception I get is similar to the one I receive when attempting to use the NAudio demo:
https://i.imgur.com/xRLvTEo.png

Any insight would be extremely helpful. Thanks!

Comments: Makes sense. Thank you for your prompt response!

Commented Unassigned: StereoWaveformPainter winforms control [16478]

$
0
0
Hi,

I made a new winform waveformpainter control, see file attached. Perhaps you want to include it Mark.

Kind regards
Freefall
Comments: thanks, although am avoiding adding any new GUI components (especially WinForms) to NAudio. Probably a better idea would be to put in an extra demo page in the NAudioDemo to show off how to use it.

New Post: WinRT playback recorded microphone audio

$
0
0
Hi!

My problem is (hopefully) not big, but I managed to get stuck with it now for a long time... I'd be very thankful if anybody could help me with it.
So the situation is: I have to record microphone input in my app, then play it back through the audio output.
Actually I am writing a Tox client and I am trying to play back the received audio frames, but you can see that the two things are almost identical. In case of Tox, I just receive the frames from the network, not from my mic. https://github.com/uruk/WinTox/blob/audio/WinTox/ViewModel/CallViewModel.cs

So I made a simplified application to demonstrate my solution for the mic-to-output problem so far:
https://github.com/uruk/NAudioTest/blob/master/NAudioTest/MainPage.xaml.cs

It works (after you give permission to the app to use your mic manually through the settings charm), but the audio played back is nowhere near my normal voice. What am I doing wrong?

Thanks for help in advance,
Peter

New Post: About the Documentation

$
0
0
Hi, I'm having a little trouble understanding the setup for this documentation. I was expecting an MSDN type of thing where each class has it's own uses explained and then demonstrated. Instead it seems like a bunch of links to different end products. I.e. here's how you play a WAV file. Or links to pluralsight... Which is very useful, but doesn't help me understand what everything does. Searching through the documentation seems to further hint at this kind of setup. I searched for: NAudio.Wave.WaveFileReader and got 0 results.

Please tell me I'm wrong about this...

New Post: About the Documentation

$
0
0
hi Forgility,

Unfortunately, there is no MSDN style documentation for NAudio. There are around 70 articles, plus the demo projects which show how to use most of the features of NAudio. And the Pluralsight course will be helpful if you are a subscriber. But yes I agree that NAudio could do with more comprehensive documentation than we currently have. It is something we are always looking to improve and I welcome any contributions to the project in this area.

New Post: About the Documentation

$
0
0
Is there any way at all for me to find out what individual classes/methods do? I just don't understand... with no proper documentation how do you expect people to pick this up with any kind of ease? For example, I'm currently looking into what WaveInCapabilities does - all I'm getting is that it's a struct. And after googling for a bit I can maybe make the guess that it gives you device names etc. Names of classes can often be deceiving, but it's pretty much the only quick and easy way I have to read the code. I mean what use is the sample code you've given us if we have to make assumptions about what its components do based on context, instead of having a dictionary definition on-hand. I really want to use the library, but it's unnecessarily hard at the moment. Still gonna fucking try though... I am grateful that you've provided this tool, it seems super powerful and I'm sure it's really comprehensive once you get used to it. I just think for people who are just getting acquainted with audio programming - it's needlessly difficult.

New Post: About the Documentation

$
0
0
NAudio contains managed wrappers for hundreds of methods, interfaces and structures from the Windows SDK. So the documentation for things like WaveInCapabilities is on MSDN. It wouldn't make sense for me to copy the MSDN documentation for the entirety of WinMM, WASAPI, ACM, MediaFoundation, DMO, DirectSound, WindowsMedia, MIDI etc and even if I wanted to, it would take years to do.

NAudio does attempt to hide some of the complexities of the Windows API methods, but unfortunately it has not all been abstracted away, so there are concepts from the various Windows APIs that you need to understand in order to work effectively. None of this is to deny that the NAudio documentation could be a lot better than it currently is. But you need to understand there are no full time developers on NAudio. It's all volunteer effort in spare time, and a most of the contributions I have received over the years have come with no documentation whatsoever.

New Post: Speed Optimization

$
0
0
Hello All,

I've got working code that receives samples and outputs the audio to speakers but re-sampling is very slow. Do you have suggestions that could immensely speed up the processing? Right now there are gaps in my audio which cause crackling because of the slowness. Most of the code is below for reference.
using (WasapiOut wasapiOut = new WasapiOut(audioClientShareMode_output, 700))
                                {
                                    try
                                    {
                                        wasapiOut.Init(bufferedWaveProvider);
                                        wasapiOut.Volume = 1f;
                                        wasapiOut.Play();

                                        while (true)
                                        {
                                            byte[] arrayByte = m_queue.Dequeue();
                                            if (null == arrayByte) { break; }

                                            bufferedWaveProvider.AddSamples(arrayByte, 0, arrayByte.Length);
                                        }
                                    }
                                    catch (Exception x) { }
                                    wasapiOut.Stop();
                                }
/// <summary>
        /// http://mark-dot-net.blogspot.com/2014/05/how-to-resample-audio-with-naudio.html
        /// </summary>
        /// <param name="waveFormat_input"></param>
        /// <param name="waveFormat_output"></param>
        /// <param name="arrayByte_input"></param>
        /// <returns></returns>
        private byte[] Resample(EnumResamplerType enumResamplerType, WaveFormat waveFormat_input, WaveFormat waveFormat_output, byte[] arrayByte_input)
        {
            List<byte[]> listArrayByte_output = new List<byte[]>();
            int totalBytesRead = 0, bytesRead = -1;

            using (MemoryStream memoryStream_input = new MemoryStream(arrayByte_input))
            {
                using (RawSourceWaveStream rawSourceWaveStream_input =
                    new RawSourceWaveStream(memoryStream_input, waveFormat_input))
                {
                    byte[] arrayByte_sub = null;
                    if (EnumResamplerType.ACM.Equals(enumResamplerType)) // Limited to 16bit sample rate
                    {
                        using (WaveFormatConversionStream waveFormatConversionStream_output =
                          new WaveFormatConversionStream(waveFormat_output, rawSourceWaveStream_input))
                        {
                            byte[] arrayByte = new byte[waveFormatConversionStream_output.WaveFormat.AverageBytesPerSecond];
                            while (0 < (bytesRead = waveFormatConversionStream_output.Read(
                                arrayByte, 0, arrayByte.Length)))
                            {
                                arrayByte_sub = ArraySub(arrayByte, 0, bytesRead);
                                //Filter(waveFormat_output, ref arrayByte_sub);
                                listArrayByte_output.Add(arrayByte_sub);
                                totalBytesRead += bytesRead;
                            }
                        }
                    }
                    else if (EnumResamplerType.MediaFoundation.Equals(enumResamplerType))
                    {
                        using (MediaFoundationResampler mediaFoundationResampler = new MediaFoundationResampler(rawSourceWaveStream_input, waveFormat_output))
                        {
                            mediaFoundationResampler.ResamplerQuality = 60;

                            byte[] arrayByte = new byte[waveFormat_output.AverageBytesPerSecond];
                            while (0 < (bytesRead = mediaFoundationResampler.Read(
                                arrayByte, 0, arrayByte.Length)))
                            {
                                arrayByte_sub = ArraySub(arrayByte, 0, bytesRead);
                                //Filter(waveFormat_output, ref arrayByte_sub);
                                listArrayByte_output.Add(arrayByte_sub);
                                totalBytesRead += bytesRead;
                            }
                        }
                    }
                    else if (EnumResamplerType.WDL.Equals(enumResamplerType))
                    {
                        WdlResamplingSampleProvider wdlResamplingSampleProvider = new WdlResamplingSampleProvider(rawSourceWaveStream_input.ToSampleProvider(), waveFormat_output.SampleRate);

                        float[] arrayFloat = new float[waveFormat_output.AverageBytesPerSecond / 4];
                        while (0 < (bytesRead = wdlResamplingSampleProvider.Read(
                            arrayFloat, 0, arrayFloat.Length)))
                        {
                            arrayByte_sub = ArrayFloatToByte(ArraySub(arrayFloat, 0, bytesRead));
                            //Filter(waveFormat_output, ref arrayByte_sub);
                            listArrayByte_output.Add(arrayByte_sub);
                            totalBytesRead += bytesRead;
                        }
                    }
                }
            }

            byte[] arrayByte_output = new byte[totalBytesRead];
            for (int i = 0; i < listArrayByte_output.Count; i++)
            {
                Buffer.BlockCopy(listArrayByte_output[i], 0, arrayByte_output, bytesRead, listArrayByte_output[i].Length);
                bytesRead += listArrayByte_output[i].Length;
            }

            return arrayByte_output;
        }

/// <summary>
        /// 
        /// </summary>
        public enum EnumResamplerType
        {
            ACM,
            MediaFoundation,
            WDL
        }

Created Unassigned: Stop monitoring? [16480]

$
0
0
Hi! I have a combobox with input devices, and i want to monitor the selected device. I do not understand is how I can stop "BeginMonitoring" to stop monitoring the current device, to monitor the newly selected device. Thx!

New Post: Null error on Stop()

$
0
0
Hi.

I'm trying to just play a file (for learning purposes) but the Stop() command sometimes throws a null error, while sometimes do nothing.

This is a very, very simple class:
class audioEngine

{
    private DirectSoundOut waveOut;
    private AudioFileReader audioCorte;

    public void cortePlay(string corte)
    {


        waveOut = new DirectSoundOut();
        var audioCorte = new AudioFileReader(corte);
        waveOut.Init(audioCorte);
        waveOut.Play();
        waveOut.PlaybackStopped += OnPlaybackStopped;



    }

    private void OnPlaybackStopped(object sender, EventArgs e)
    {
        waveOut.Dispose();

    }

    public void estadoPlayer()
    {
        if (waveOut != null
                && waveOut.PlaybackState != PlaybackState.Stopped)
        {

            waveOut.Stop();

        }

    }

}
What i'm missing there? I just want to play/stop a file...

New Post: WasapiOut High CPU Usage on Windows 10

$
0
0
I've been using WasapiOut in a VB.NET program on Windows 7, 8 and 8.1 without any problems but since Windows 10, as soon as the stream starts playing, CPU usage goes quite high. Usually it's around 15% but i've seen 30% and 100% also.

This is more or less the code i'm using (I created a test program to make sure it wasn't something else in my main program causing the issue)
Imports NAudio.CoreAudioApi
Imports NAudio.Wave

Public Class Form1
    Private Sub Form1_Load(sender As Object, e As EventArgs) Handles MyBase.Load
        Dim WavePlayer As WasapiOut
        Dim DefaultAudioDevice As New MMDeviceEnumerator
        WavePlayer = New WasapiOut(DefaultAudioDevice.GetDefaultAudioEndpoint(DataFlow.Render, Role.Multimedia), AudioClientShareMode.Shared, True, 0)
        WavePlayer.Init(New WaveChannel32(New WaveFileReader("C:\Users\Marc\Documents\Visual Studio 2015\Projects\Wasapi Test\test.wav")))
        WavePlayer.Play()
    End Sub
End Class
Is there a way I can change the implementation of the code, or is there an issue with WasapiOut in Windows 10?

Thanks in advance

Marc

New Post: Changing frequency/pitchshifting

$
0
0
Hi there. Newcomer to NAudio, and a big fan so far, but I have one simple question which is really a dealbreaker for my project if the answer is "no" :/

I'm looking to use NAudio to get at DirectSound from vb.net, and I need the ability to play back wav files at a different pitch - easily achieved in vanilla DirectX with DirectSoundBuffer.SetFrequency.

I can't see this method, or any equivalent, exposed though. Am I missing something?

Many thanks!

New Post: WasapiOut High CPU Usage on Windows 10

$
0
0
I noticed that in Win 10, get stream latency returns 0, which means that the waits for events will instantly return. Try running it without event based sync, and seeing if that improves performance.
Viewing all 5831 articles
Browse latest View live


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