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

New Post: mp3 starting point

$
0
0
Hi,

I'm new to naudio and i look for some method for programmatically playing a piece of mp3 file. I mean from time t1 to time t2.

Does anybody knows wich method of naudio can do this?

New Post: Volume constantly increases

$
0
0
I have a bizarre situation.
I've implemented a player using NAudio, and ask that player to play a certain audio file (MP3, but that shouldn't matter) at a low volume. The original file I pass through a volume/panning provider, where I pan the channels and multiply by a volume multiplier (around 0.004).

I've tried that feature on three difference computers, on two of which everything is fine. The thing is, that on one particular laptop (HP EliteBook 8570w) the audio been played begins at a low volume, and then the volume gradually increases. I figured out, that if in my volume/panning provider, in the Read, I insert the following lines, the volume does not increase.
    ' Keep volume down
    For idx = 0 To 3999
        buffer(offset + idx) = 0
    Next
So it looks like there is something that checks the samples on the output and if it believes the level is too low, it increases it by itself. Note, that this does not happen if I use standard .NET MediaPlayer component.

The question is: what is this entity, and how do I switch it off?

New Post: Volume constantly increases

$
0
0
I found the issue (it helps formulating the question :-)
In HP there is an "Enhance audio" setting in the Control Panel, which, when switched off, keeps the audio volume as specified. Interesting, though, is the fact that Media Player seems to be able to circumvent this setting.

New Post: Record from 2 microphones

$
0
0
it looks like you're trying to open the same device number for recording twice. Put some breakpoints on StartRecording, and see what DeviceNumber is,.

New Comment on "Documentation"

$
0
0
Hi, is there any reference page? Something similar as this http://www.cplusplus.com/reference/ for Cpp?

New Post: If signal is already stereo, how do I pan left/right?

$
0
0
why do you need the output to be a WaveStream? Best approach is just to convert to SampleProvider (and back to 16 bit WaveProvider if necessary later).

New Post: WaveStillPlaying calling WaveOutWrite

$
0
0
you can safely ignore these. They should really be removed if playback is paused

New Post: Any Naudio issues known for Windows 10?

$
0
0
Hi Mark,
With Windows 10 set to auto-convert windows 7/8 users to the new OS, I'm wondering if there are any known incompatibilities with Naudio libraries on that OS? And if yes, any plan/schedule for Naudio releases to address the issues?

Also is there a Release Notes doc for NA 1.7.3 to see what's new in that release?

New Post: How to dispose the memory that BufferedWaveProvider uses?

$
0
0
Hi,
I use BufferedWaveProvider to play a PCM audio without common wav file header.
The file is approximately 400MB.
My program offers a function that allows users to decide which point to start and how long to play. But if I use BufferedWaveProvider bwp=new BufferedWaveProvider(new WaveFormat()) every time when clicking the Play button, the memory that my program uses will add another more 400MB. So how to dispose it after using it ?
I tried to call bwp.ClearBuffer() but it seems nothing happens.
And if I only initialize bwp on the Form Load event, then the memory usage is no longer a problem. However, this will cause NAudio.dll throw a Buffer Full exception if I aborted a longer play and then play a shorter one.

My code is as follows:
BufferedWaveProvider bwp=new BufferedWaveProvider(new WaveFormat());
WaveOut wo=new WaveOut();
FileStream fs = new FileStream(FilePath, FileMode.Open);
        BinaryReader br = new BinaryReader(fs);
        byte[] b = new byte[44100];
        br.BaseStream.Position = POS;
        bwp.BufferLength = LEN;
        int bytesread, i = 0;
        while (i < bwp.BufferLength)
        {
            bytesread = br.Read(b, 0, b.Length);
            if (bytesread != 0 && br.BaseStream.Position <POS+ LEN)
            {
                i += bytesread;
                bwp.AddSamples(b, 0, bytesread);
            }
            else
            {
                i = bwp.BufferLength;
            }
        }
        wo.Init(bwp);
        wo.Play();
        br.Dispose();
        fs.Dispose();
Thanks ahead,
Joy,Sun

New Post: How to dispose the memory that BufferedWaveProvider uses?

$
0
0
RawSourceStream is what you want here, rather than BufferedWaveProvider, which is for playing real-time streamed data.

New Post: mp3 to sample array

$
0
0
How can I use NAudio library to get sample float array from mp3 file?

Here is my code:
        float[] buffer = new float[2000];

        AudioFileReader reader = new AudioFileReader(filePath);
        reader.Read(buffer, 0, 2000);
After that buffer is always empty (only zeros inside).

New Post: VB.NET - Buffer full TCP-Server

$
0
0
Hey, i have a problem with TCP-Server.
I can send the input from microphone with a TCP-Client but the TCP-Server cannot play, because fast cames the error: "buffer full".
I have searched but i didn't found a solution and i have asked in two forums, one user said to ask here.

Code:

TCP-Server:
Private Sub MainServer()
    TCP_Server.Start()  
    Dim bytes(1024) As Byte
    Dim Received_Message As String = Nothing
    While True
        Dim client As TcpClient = TCP_Server.AcceptTcpClient()
        Dim MicrosoftADPCM_Codec As INetworkChatCodec = New MicrosoftADPCM()
        Dim stream As NetworkStream = client.GetStream

        waveOut = New WaveOut()
        waveProvider = New BufferedWaveProvider(MicrosoftADPCM_Codec.RecordFormat)
        waveOut.Init(waveProvider)
        waveOut.Play()

        Dim i As Int32 = stream.Read(bytes, 0, bytes.Length)
        While (i <> 0)

            Dim decoded As Byte() = MicrosoftADPCM_Codec.Decode(bytes, 0, i)
            waveProvider.AddSamples(decoded, 0, decoded.Length)

        End While
    End While
    TCP_Server.Stop()
End Sub
TCP-Client:
    Dim TCP_Client As New TcpClient("IP", "PORT")
    Dim stream As Stream = TCP_Client.GetStream

    Call_Stream = stream
    Dim MicrosoftADPCM_Codec As INetworkChatCodec = New MicrosoftADPCM()
    selectedCodec = MicrosoftADPCM_Codec
    waveIn = New WaveIn()
    waveIn.BufferMilliseconds = 50
    waveIn.DeviceNumber = comboBoxInputDevices.SelectedIndex
    waveIn.WaveFormat = MicrosoftADPCM_Codec.RecordFormat

    AddHandler waveIn.DataAvailable, AddressOf waveIn_DataAvailable
    waveIn.StartRecording()
waveIn_DataAvailable:
Private Sub waveIn_DataAvailable(sender As Object, e As WaveInEventArgs)
    Dim encoded As Byte() = selectedCodec.Encode(e.Buffer, 0, e.BytesRecorded)
    Call_Stream.Write(encoded, 0, encoded.Length)
End Sub
Thank you for any replies.

New Post: VB.NET - Buffer full TCP-Server

$
0
0
are you playing from the BufferedWaveprovider? If not it will just fill up and you'll get an exception as you are seeing here

New Post: Any Naudio issues known for Windows 10?

$
0
0
As far as I am aware, Windows 10 should work just fine with NAudio. I'll of course do some testing as soon as the final version becomes available.

There is no official release notes for 1.7.3 as it was just a roll-up of some minor bugfixes.

New Post: System.IndexOutOfRangeException using WaveFileWriter

$
0
0
my main suggestion would be to be sure that the number of bytes you are reading is an exact multiple of the BlockAlign. I'd probably also need to see the full signal chain and how you are using those OffsetSampleProviders to be sure.

New Post: mp3 to sample array

$
0
0
Hi,

you read only the first 2000 samples of your mp3 file, which are all zeros when some silence is in there at start.

Besides that, it is a obviously very dangerous approach to assume it owns a fixed number of samples.
I recommend writing a While Loop and exit after you got 2000 samples if that is what you want. If you want the whole file as float array, run the While Loop completely through and better use a List of Float to store the samples dynamically.

Cheers.

New Post: Any Naudio issues known for Windows 10?

New Post: how to play gsm and dss files using NAudio

$
0
0
NAudio does not have any built-in support for these file formats. However, it does allow you access to any codecs on your machine, which should include a GSM one, so you may still be able to play the audio if you can extract the payload from the file

New Post: VB.NET - Buffer full TCP-Server

$
0
0
Hmm, that is all.
I think that:
waveOut.Play()
refresh the bytes and playing.

What should I do? How i play right?

New Post: VB.NET - Buffer full TCP-Server

$
0
0
you can still over-fill the buffer if you are receiving data too fast, or maybe if you have got your recording formats wrong. To see a working example of what you are trying to do, take a look at the code for the network chat demo in the NAudio demo application
Viewing all 5831 articles
Browse latest View live


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