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

New Post: WinRT capture audio

$
0
0
Hi

I am trying to convert my previous project that was using NAudio to run on winRT

for WaveOut I simply converted output to use NAudio.Win8.Wave.WaveOutputs.WasapiOutRT and the rest of it was almost the same.

But I cant see replacement for WaveIn.

What I am missing ?

I am trying to capture Audio from microphone in PCM format and convert it to byte array.

Thanks

New Post: Capturing byte[] from mic, sending it to network and playing in client site

$
0
0
Hi,

I am not very much experienced in audio programming but very much attracted with NAudio,Basically what i wanted to do is, capture the data (byte[]) from the microphone, then transport it over the network and play on client end. Just as voice call in chat application.
I tried saving the byte array in to the queue and send it to the service in certain interval.

long count = 0;
    bool bufferfull = false;
    private WaveIn waveIn = null;
    private BufferedWaveProvider waveProvider = null;
    private WaveOut waveOut = null;
    private Queue<byte[]> datas = new Queue<byte[]>();
private void button1_Click(object sender, EventArgs e)
    {
        if (waveIn != null)
            return;
        waveIn = new WaveIn(this.Handle);
        waveIn.BufferMilliseconds = 25;
        waveIn.RecordingStopped += waveIn_RecordingStopped;
        waveIn.DataAvailable += waveIn_DataAvailable;

        waveProvider = new BufferedWaveProvider(waveIn.WaveFormat);

        waveOut = new WaveOut();
        waveOut.DesiredLatency = 100;
        waveOut.Init(waveProvider);
        waveOut.PlaybackStopped += wavePlayer_PlaybackStopped;


        waveIn.StartRecording();
        waveOut.Play();
    }
void waveIn_DataAvailable(object sender, WaveInEventArgs e)
    {
        // add received data to waveProvider buffer
        if (count <= 200)
        {
            if (waveProvider != null)
                waveProvider.AddSamples(e.Buffer, 0, e.BytesRecorded);
        }
        if (count >= 200)
        {
            //send the byte array (Queue) as stream in to the network.
        }
        if (!bufferfull)
            datas.Enqueue(e.Buffer);
        count++;
    }
and in the client side

datas = getTheQueueFromTheService();
while (datas.Count > 0)
        {
            var playingData = datas.Dequeue();
            waveProvider.AddSamples(playingData, 0,playingData.Length);
            Thread.Sleep(30);
            waveOut.Play();
            waveProvider.ClearBuffer();// because i got the exception Buffer full
        }
but i found no luck. I googled for more the 3days, tried various methods still i was not able to figure out how to do it.

With the great hope for the assistance and help i have posted it here.I would be very greatful if some one could get me a piece of code.
and can i use NAudio to develop app as voice call provided by chat application.Is it appropriate.

Thank in advance.

New Post: Producing poor quality sound

$
0
0
No one is here to help me out ? I tried different formats and different waveformat but none of them worked for me. :(

Thanks in advance.

New Post: Capturing byte[] from mic, sending it to network and playing in client site

$
0
0
Hello,

above code seems to be correct at a first view, but this
    if (waveIn != null)
     return;
could be the problem perhaps? Perhaps you could upload full project sample somewhere, so that ppl can test it for improvements.
I´d try to help you more, but I´m really busy atm with my job.

Kind regards

Freefall

Edit:

This could also be a error source as it does nothing when your buffer is full:
  if (count >= 200)
   {
       //send the byte array (Queue) as stream in to the network.
   }

New Post: How about adding *.flac support?

$
0
0
Freefall,

Next steps: Cancel your (blank) pull request, code up the integration, submit the changes, then re-submit the pull request. Once that is done, Mark will tell you the next steps (maybe none if your implementation is solid and fits with NAudio's overall design). That said, you'll need to track CsCore's changes for us so our implementation is as good as theirs. A (very) quick review of the code tells me it's a "new, from scratch" implementation, so there will be bugs to address.

I'll let Mark address the idea of merging projects, but the short version is that it ain't gonna happen and either project will do the majority of what people need. :)

New Post: How about adding *.flac support?

$
0
0
What do you mean by
blank pull request
I´ve written there where I´ve stored the plugin and project files, so I don´t get your point.
code up the integration
Already did, in form of a plugin. As you can see at my example above and on google code.
submit the changes
Sorry, I´m new to forks and this pull request stuff and so on, how can I submit a full project source as change?
Maybe none if your implementation is solid and fits with NAudio's overall design
Yes, it seems that the architecture is very similar and should therefore fit into NAudio design. That´s why I could
implement it in 2 hours. I also share Mark´s opinion, to integrate it as an plugin to don´t bloat NAudio´s source up.
you'll need to track CsCore's changes for us so our implementation is as good as theirs
I agree, since I´ve already encountered a bug. I´ll do my best to fix them and ensure it´s up to date as far as I can.
but the short version is that it ain't gonna happen and either project will do the majority of what people need
Well, I don´t want to argue with you, but I have a different opinion on that. You could reach so much if you let all misunderstandings behind.

Kind regards

Freefall

New Post: How about adding *.flac support?

$
0
0
hey Freefall.

Thanks for contacting thefiloe. I had many conversations with him a few years back, and was hopeful that he could contribute some of his ideas to NAudio, but he has decided to do his own thing. I certainly would be up for collaboration in the future if that is possible. He has put some good ideas into cscore, and has the advantage of having a fresh start with the API rather than having to maintain backwards compatilbility. One idea I've had in mind for a while is possibly giving NAudio a bit of a fresh start for version 2.0, making more breaking changes, and maybe moving to GitHub at the same time.

And if he is the original creator and has given his permission, that is great, and there should be no problem incorporating it into NAudio. Because NAudio is used in a lot of large commercial applications, it is important that there are no question marks over the origin of the code it contains.

You should be able to add extra commits to your existing pull request. I do code review all pull requests to NAudio, and hopefully over the next week or so I'll get round to this. NAudio is just a spare time hobby project for me, and the amount of emails I get about it has got to the point that I can't keep up any more. I have 90 still waiting for a response at the moment. But I do try to prioritise things like this, and I'll be looking at your pull request over the next few weeks.

One thing I do ask contributors if possible is to also write some documentation about how to use the classes they add to NAudio. You may have already done this, but if not, please consider doing this.

Mark

New Post: Producing poor quality sound

$
0
0
What is resampleStream? And what is this code actually trying to achieve? It isn't obvious to me what exactly you are trying to do here.

New Post: Simple Pitch Shifting (non-realtime)

$
0
0
ISampleProvider is designed for this type of situation, where you are performing your algorithms with floating point samples.

New Post: AcmNotPossible calling acmStreamOpen

$
0
0
Not every conversion is possible. You can only do what the codecs allow. The ACM resampler codec won't allow you to go from 32 bit floating point to 16 bit AND resample in one go. You'd need to do it in two steps. The MediaFoundationResampler is actually more flexible and may be a better choice here.

New Post: Windows Store Validation Issue

$
0
0
I've published a new NAudio (1.7.2) to NuGet with an updated Win 8 store DLL. Hopefully this will pass WACK now. Let me know how you get on with it.

New Post: Distortion in sound writing to serial port

$
0
0
You can't convert from 44.1kHz 16 bit stereo to 8kHz 8bit stereo in one hit. You need to resample first, then go 16 bit to 8 bit. Also, you are recording in mono, so why is the resampler operating in stereo?

New Post: Left channel and Right channel graph not working

$
0
0
Have you looked at the code sample in the NAudio demo? It shows a left and a right level meter using a Metering Sample Provider

New Post: How to concatenate two Wave files in memory to play

$
0
0
Hi all,

I want to know how to concatenate two Wave files in memory to play. I don't want to save a result wave file. I just only one to reproduce the two files as one.

Is it possible?

Thank you very much in advance,
Fran

New Post: How to concatenate two Wave files in memory to play

$
0
0
I'd make my own IWaveProvider (or WaveStream if you need to reposition within the concatenated file) that took the two WaveFileReaders as inputs. In the Read method, read out of the first one, and if you get less than count, start reading out of the second one. Both files must have the same waveformat.

New Post: Left channel and Right channel graph not working

$
0
0
Hi Mark,

In previous code we can implement left and right channel graph but now we change the logic(please see the code) and we are unable to implement channel indicator.Please see my above code and suggest me.

New Post: Distortion in sound writing to serial port

$
0
0
Thanks for the reply Mark. I thought that 44.1kHz 16 bit stereo is produced by Microphone so i was using here. But as per your direction i changed it to


var resampleStream = new AcmStream(new WaveFormat(8000, 16, 1), WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm , 8000, 1,8000 * 1, 1, 8));
and set
wi.BufferMilliseconds =20;

There is improvement in sound quality but i cant hear clearly on the other side of phone. I tried everything, and i dont know what i have to change to hear the clear voice.

Please provide me solution, because i have tried everything, and according to me i have no solution for this problem.

Thanks in advance

New Post: Producing poor quality sound

$
0
0
Thanks for the reply mark.In first I was trying to write byte array to serial port instead of

bufferedWaveProvider.AddSamples(decoded133, 0, decoded133.Length);

line in above code. But i was not hearing clear voice on other side of the phone line so i first tried to listen this on my computer so used mentioned line in my code.
But it is playing same distorted sounds as playing on other side of the line while i write the byte array to serial port.

resampleStream is
var resampleStream = new AcmStream(new WaveFormat(8000, 16, 1),  WaveFormat.CreateCustomFormat(WaveFormatEncoding.Pcm   , 8000, 1,8000 * 1, 1, 8));
Thanks in advance.

New Post: Producing poor quality sound

$
0
0
But what wave format is the device at the other end of the serial port actually expecting. Is it really 8 bit linear PCM? Or could it be mu or a -law?

To troubleshoot issues like this I recommend taking a divide and conquer approach. First, instead of sending your audio to the serial port, write it to a WAV file. Listen to the WAV file in Windows Media Player. Does it sound distorted or OK?

Then create a simple voice recording at the format you plan to send to the serial port. Play that through the serial port by sending it's data a few hundred milliseconds at a time. Does that sound OK?

By answering these questions you will discover which part of the overall system isn't working correctly.

New Post: Distortion in sound writing to serial port

$
0
0
Make sure that your recording format is definitely set to 8kHz 16 bit mono. What is WaveFormat of WaveInEvent?
Viewing all 5831 articles
Browse latest View live


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