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

Created Issue: Buffer not dispose [16391]

$
0
0
I'm Trying NAudio in my project.
It seem that in Mp3FileReader buffer dispose function not work.
I use this scenario:
mp3_1 = New Mp3FileReader("FileAudio.MP3")
DSO1.Init(mp3_1)
DSO1.Play()
Then stop and dispose WaweOut and restart a new file with same routine.
After any stop and play, memory is loss.

Is this routine correct?

Rehards
Alex

Commented Issue: Buffer not dispose [16391]

$
0
0
I'm Trying NAudio in my project.
It seem that in Mp3FileReader buffer dispose function not work.
I use this scenario:
mp3_1 = New Mp3FileReader("FileAudio.MP3")
DSO1.Init(mp3_1)
DSO1.Play()
Then stop and dispose WaweOut and restart a new file with same routine.
After any stop and play, memory is loss.

Is this routine correct?

Rehards
Alex
Comments: You should Dispose your Mp3FileReader as well when you are finished playing it.

Commented Issue: Buffer not dispose [16391]

$
0
0
I'm Trying NAudio in my project.
It seem that in Mp3FileReader buffer dispose function not work.
I use this scenario:
mp3_1 = New Mp3FileReader("FileAudio.MP3")
DSO1.Init(mp3_1)
DSO1.Play()
Then stop and dispose WaweOut and restart a new file with same routine.
After any stop and play, memory is loss.

Is this routine correct?

Rehards
Alex
Comments: I have try: mp3_1.close mp3_1.dispose But the memory used increases each time use new Mp3FileReader. It seem that the dispose function not releases all file stream. Cam you tell me the proper method? Regards Alex

Commented Issue: Buffer not dispose [16391]

$
0
0
I'm Trying NAudio in my project.
It seem that in Mp3FileReader buffer dispose function not work.
I use this scenario:
mp3_1 = New Mp3FileReader("FileAudio.MP3")
DSO1.Init(mp3_1)
DSO1.Play()
Then stop and dispose WaweOut and restart a new file with same routine.
After any stop and play, memory is loss.

Is this routine correct?

Rehards
Alex
Comments: then you have disposed it. memory usage does not go down in .net when you dispose something. that only happens when the garbage collector runs.

New Post: Convert Mpeg1 layer 2 to wave

$
0
0
Hi!
I have mp3(mpeg1 layer2) data. How to convert to wave?
I using Naudio, but return one file with no data return.
Thank!

New Post: 10 band Equalizer

$
0
0
I'm trying to create a 10 band EQ (frequency based; beginning at 32hz, ending at 16khz). I found BiQuadFilter.PeakingEQ, but I cannot figure out what the "q" parameter is supposed to be.

Is it the peak width? If so, what is the best way to implement? Overlapping peaks?

Is PeakingEQ what I should be using or is there a better option?

New Post: Insert silence to beginning of audio file and save as new file

$
0
0
Hi,

I'm trying to insert silence into the beginning of an audio file, then save that file as a new audio file. I'm using the Mp3FileReader to read the input file, but can't figure out how to insert silence at the beginning of the file and save it. I've seen some references to using WaveOffsetStream or OffsetSampleProvider, but can't figure out how to use them. Any pointers/sample code would be greatly appreciated.

Thanks,
Alan

New Post: Insert silence to beginning of audio file and save as new file

$
0
0
you have to convert to PCM first, and then re-encode as MP3 if you need MP3. So write zeroes into a WaveFileWriter until you have the desired amount of silence (use AverageBytesPerSecond from the Mp3FileReader's WaveFormat to know how many to write), and then read everything out of your Mp3FileReader into the WaveFileWriter after that. Once you've done that, you'll have a WAV file that you can re-encode as MP3.

New Post: Insert silence to beginning of audio file and save as new file

$
0
0
Another option if you are just adding silence to the beginning of a MP3 file (and nothing more): Add empty frames to the "beginning" of the MP3 file. There are some caveats to it, though:

1) Adding a frame to a MPEG1 Layer III file will add 1152 samples (regardless how many channels; don't divide by channel count).
2) The new frames have to come after the ID3v2 tag and the RIFF header (if it exists; if it does, you'll also have to update the chunk sizes).
3) If there is a VBR tag (either form): Put your frames after the VBR tag. You can use minimum-bitrate frames here. Make sure to update the VBR tag.
4) Otherwise, put your frames at the beginning of the audio data. Your "empty" frame header should be almost identical to the first "real" audio frame's header.

Any frames you add should consist of a 32-bit frame header and no less than 20 bytes of 0's. Pad to the frame size (there are plenty of references for MP3 frame header parsing & frame length calculation...).

Commented Issue: Buffer not dispose [16391]

$
0
0
I'm Trying NAudio in my project.
It seem that in Mp3FileReader buffer dispose function not work.
I use this scenario:
mp3_1 = New Mp3FileReader("FileAudio.MP3")
DSO1.Init(mp3_1)
DSO1.Play()
Then stop and dispose WaweOut and restart a new file with same routine.
After any stop and play, memory is loss.

Is this routine correct?

Rehards
Alex
Comments: Can I know the device audio list name? Regards Alex

New Post: NoDriver calling acmFormatSuggest

$
0
0
I can't seem to get NAudio to read an MP3 file. It works fine on my local machine, but fails with "NoDriver calling acmFormatSuggest" in production. The line it fails on in creating the NAudio.Wave.Mp3FileReader.

I've created a small app that replicates the error (below) on a Win 2008 R2, 64bit machines. I've verified that the code is running in 32bit (same as IIS - which is what needs to work).
using System;

namespace NAudioTest
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                using (var rdr = new NAudio.Wave.Mp3FileReader("Test.mp3"))
                {
                    Console.WriteLine("Duration: {0}", rdr.TotalTime);
                }
            }
            finally
            {
                Console.ReadKey();
            }
        }
    }
}
We also have LAME.exe running on this machine and it works just fine, so the machine should have the appropriate codecs. I started the audio service just in case that would help, but it didn't.

Any ideas?

New Post: NoDriver calling acmFormatSuggest

$
0
0
I was able to find a work-around, but I wouldn't mind figuring out why this is a problem in case I need to do more than just get duration with NAudio in the future.

Here's the work-around (adapted from http://stackoverflow.com/a/13269914/320)...
public static TimeSpan GetMediaDuration(string srcPath)
{
    var duration = 0.0;
    using (var fs = System.IO.File.OpenRead(srcPath))
    {
        var frame = Mp3Frame.LoadFromStream(fs);
        while (frame != null)
        {
            duration += (double)frame.SampleCount / (double)frame.SampleRate;
            frame = Mp3Frame.LoadFromStream(fs);
        }
    }
    return TimeSpan.FromSeconds(duration);
}

Created Issue: PlaybackStopped [16392]

$
0
0
in last version I see problem with PlaybackStopped when .mp3 is end.
How I can know when mp3 file is play end?



Regards
Alex

New Post: Setting Sample rate on ASIO device

$
0
0
Hi All,

How i can set the different sample rate on the ASIO device from the code.

Thanks in advance.

New Post: Insert silence to beginning of audio file and save as new file

$
0
0
Thanks for the quick replies. Mark, love NAudio, great library!

For reference, here's basically what I ended up doing, thanks for the pointers. If you see any problems, please comment.

-Alan
            int silence = 5000;  // silence to add in ms
            string mp3Url = "http://freedownloads.last.fm/download/494669779/Calgary.mp3";
            string outfile = "newfile.wav";
            WaveStream waveStream = new Mp3FileReader(mp3Url);
            using (WaveFileWriter waveFileWriter = new WaveFileWriter(outfile, waveStream.WaveFormat))
            {

                int avgBytesPerMillisecond = waveStream.WaveFormat.AverageBytesPerSecond / 1000;
                var silenceArraySize = avgBytesPerMillisecond * silence;
                byte[] silenceArray = new byte[silenceArraySize];
                waveFileWriter.Write(silenceArray, 0, silenceArray.Length);
                byte[] songArray = new byte[waveStream.Length];
                int numSamples = waveStream.Read(songArray, 0, songArray.Length);
                waveFileWriter.Write(songArray, 0, numSamples);
            }

New Post: 10 band Equalizer

$
0
0
I figured out what "Q" is: http://www.homemadehitshow.com/EQTips.htm.

The BiQuadFilter class is private and seems to be... unused and forgotten. I decided to just create my own class to handle the peaking EQ. If anyone is interested (and I remember), I will post the code here.

If I remember to do it...

Commented Issue: PlaybackStopped [16392]

$
0
0
in last version I see problem with PlaybackStopped when .mp3 is end.
How I can know when mp3 file is play end?



Regards
Alex
Comments: Solved Regards Alex

Closed Issue: PlaybackStopped [16392]

$
0
0
in last version I see problem with PlaybackStopped when .mp3 is end.
How I can know when mp3 file is play end?



Regards
Alex

New Post: Setting Sample rate on ASIO device

$
0
0
NAudio will try to open the ASIO device using the sample rate of the stream to playback you passed into the Init method

New Post: Best strategy to resample IEEE 32 bit streams in Windows XP?

$
0
0
Good question. I'm not sure what the answer is. I suspect that the DMO resampler doesn't work in XP either. I have tried a couple of times in the past to make a fully managed resampler, but my current implementation isn't quite ready to release yet. I'd probably use something like sox for now.
Viewing all 5831 articles
Browse latest View live


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