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

New Post: Sending and playing MP3 frames

$
0
0

There is an example of this in the NAudioDemo project, which uses a BufferedWaveProvider to queue audio for playback. Get the latest code and look at the NAudioDemo MP3 streaming example.


New Post: Sending and playing MP3 frames

$
0
0

This is what I have so far, but I can't figure out why the buffer in Read() is getting full..

http://pastebin.com/QedH4yVZ

(Couldn't get the code tags to work :s)

New Post: ASIO input

$
0
0
Hfuy wrote:

Hi,

Is there some reason ASIO input isn't supported?

I've hacked input capability into ASIODriverExt.cs - it's only half a dozen changes and appears to work fine, but I worry that there's  some reason this wasn't done in the first place.

HF

Hi Hfuy,

 

Could you describe exactly which hacks you made to ASIODriverExt.cs to get ASIO input working? I would love to see this feature added to NAudio in the future but for now if I would be happy with a work-around.

Thanks!

New Post: NAudio Recording Performance

$
0
0

Thanks for your reply Mark. Some follow-up questions:

- When you say "optimise your playback code": I'm not actually playing the audio back, just recording it. The popping I hear is right in the WAV files that I'm producing, as heard in any audio program.

- How does one increase the buffer size for NAudio recording?

- "Some of the NAudio playback models do create background threads": Again, this is a recording issue. Not sure if that changes your answer at all.

New Post: NAudio Recording Performance

$
0
0

OK, that is very strange. I wouldn't expect there to be any pops if you are writing the recorded buffers directly to disk unless your computer is struggling so much it can't keep up at all. Do you write directly to WAV file or are you processing in any way? You can increase the size and number of record buffers that might take a bit of the strain off your machine.

You can set the BufferMilliseconds property to 200 or 300 on WaveIn (or WaveInEvent which does use a background thread). Could also try increasing NumberOfBuffers from 2 to 3.

Mark

New Post: Decompress (convert) mp3 to byte array for manipulation of audio...

$
0
0

Hi!

I would like to decompress (convert) a mp3 file to byte array, so I can manipulate it and apply some of my own audio filters. How would I do that with naudio? Code would be very much appreciated :)

Thanks! 

New Post: Using NAudio playback as time source

$
0
0

I'm there, its all working and the timing is close enough. I used the WPFSoundVisualizationLib to show progress along the soundtrack. The only thing to solve is a problem with the sound after a pause. Seems like its playing 2 versions simultaneously. I'm using the NAudio sample from the visualization lib. After the restart of the audio, its garbled like its being played twice slightly out of phase. Any advice on pausing and resuming audio play?

 

Thanks,

 

Neil

New Post: NAudio - Peak Meter in C#

$
0
0

Hello,

I have create my own application and i have to add volume meter in my application when an audio is playing, i used ur code but it was not working... Can u please help me where are u getting value for the amplitude????

Thanks in advance...


Created Issue: Save on file system with costant format [16349]

$
0
0
Hello,
what is the most efficient way to persist the audio captured from the microphone guaranteeing the constant wave format (PCM, 1 channel, 16bit and 16000Hz) regardeless of the microphone configuration?

Thanks,
Pedro

New Post: The Id3v2Tag.Create()

$
0
0

Does this not exist anymore? It is in one of your tutorials but i cant seem to find it in the source. I tried instead to use ReadTag(System.IO.Stream stream) but i cant figure out what to pass it because it breaks when i pass what i think i should be passing.

 

Please help. All im trying to do is retrieve the data in  an mp3. For example the title, artist, album etc..

 

Thanks,

New Post: The Id3v2Tag.Create()

$
0
0

Ok so i can get the RawData but now i dont know what is actually useful to me. So frustrating.

New Comment on "MP3"

$
0
0
So what do we need the volumestream for? Manipulating the volume?

New Post: Decompress (convert) mp3 to byte array for manipulation of audio...

$
0
0

So I can be more clear:  I need a sample data from a mp3 file, so I can manipulate the data and then play the newly manipulated data.


I have searched on google for a long time and did not get any info, that would come handy :S

 

I hope you can help me.

Commented Issue: Destination array was not long anough when reading mp3 file whit NAudio [16345]

$
0
0
I've got this code

static void Main(string[] args)
{
try
{
Mp3FileReader reader = new Mp3FileReader(@"C:\testAudio.mp3");
long count = reader.Length;
if (count <= int.MaxValue)
{
byte[] info = new byte[count];
reader.Read(info, 0, (int)count);
Console.WriteLine("Succesfull read");
}
else
Console.WriteLine("Could not read");
}
catch(Exception ex)
{
Console.WriteLine(ex);
}
}

that prints out the following exception message

System.ArgumentException: Destination array was not long enough. Check destIndex and length, and the array's lower bounds.
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length, Boolean reliable)
at System.Array.Copy(Array sourceArray, Int32 sourceIndex, Array destinationArray, Int32 destinationIndex, Int32 length)
at NAudio.Wave.AcmMp3FrameDecompressor.DecompressFrame(Mp3Frame frame, Byte[] dest, Int32 destOffset) in C:\NAudio-Source\NAudio\FileFormats\Mp3\Mp3FrameDecompressor.cs:line 50
at NAudio.Wave.Mp3FileReader.Read(Byte[] sampleBuffer, Int32 offset, Int32 numBytes) in C:\NAudio-Source\NAudio\Wave\WaveStreams\Mp3FileReader.cs:line 338
at Tester.Program.Main(String[] args) in C:\Tester\Program.cs:line 30

I've dowloaded NAudio code and I've been debugging it but I can't find the cause of the error, although, as you can see on the stack trace is in *NAudio-Source\NAudio\FileFormats\Mp3\Mp3FrameDecompressor.cs:line 50*

¿Am I doing something wrong? By the way, it only happens with a few mp3 files, others are read just fine. I'm attaching one of the files that can't be read

Thanx
Comments: I have exactly the same problem with a different mp3 file. In my case the decompressed length is 32256, which does not fit in the decompressBuffer (of length 9216). Maybe the cause does not lie within NAudio, but it would be nice if NAudio handles this exceptional case gracefully.

New Post: MemoryAllocationError calling waveInOpen

$
0
0

I have an app that uses WaveIn to record audio. It records it in chunks... to do this, it calls:

waveIn.StartRecording()

... and then after a few seconds, it calls:

waveIn.StopRecording()

Right after it calls waveIn.StopRecording(), it allocates a new WaveIn object and calls StartRecording() on it to start recording the next chunk of audio.

Is this a reasonable approach?

What I'm finding is that occassionally, this happens when calling StartRecording():

Error while starting recording: MemoryAllocationError calling waveInOpen

at NAudio.MmException.Try(MmResult result, String function)

at NAudio.Wave.WaveIn.OpenWaveInDevice()

at NAudio.Wave.WaveIn.StartRecording()

Any thoughts on how to avoid this?


New Post: MemoryAllocationError calling waveInOpen

$
0
0

You need to properly dispose of the old WaveIn to avoid memory leaks. Also, it would be better to use just one instance of WaveIn, calling Start and Stop. An alternative is to just call StartRecording once and ignore the DataAvailable events when you don't want data.

New Post: Alternative mp3 to wav method?

$
0
0

Hi!

I'm currently working on a small project that operates on mp3 files at frame level, so i'm using Naudio, and i'm very happy with the results so far.

Since I'm working with a List<Mp3Frame> for direct access over individual frames, I'm wondering if it is possible to create some Mp3 reader to read directly from memory so the method definition would be:

public static void Mp3ToWav(List<Mp3Frame> array, string outputFile)

and instead of: using (Mp3FileReader reader = new Mp3FileReader(mp3File))

,I would be using:  using (Mp3Reader reader = new Mp3Reader(array))

 If this is not possible, is there any workaround i could use?

Thanks in advance,

Created Issue: NAudio resampler exception when deployed to Azure [16350]

$
0
0
I'm resampling wav file for my web app using ResamplerDmoStream. This works fine running locally, but I'm getting a registration error when deployed to Azure:

Exception thrown = System.Runtime.InteropServices.COMException (0x80040154): Retrieving the COM class factory for component with CLSID {F447B69E-1884-4A7E-8055-346F74D6EDB3} failed due to the following error: 80040154 Class not registered (Exception from HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).
at NAudio.Dmo.Resampler..ctor()
at NAudio.Wave.ResamplerDmoStream..ctor(IWaveProvider inputProvider, WaveFormat outputFormat)

I'm using version 1.5.4 of NAudio.dll. Thanks!

New Post: Decompress (convert) mp3 to byte array for manipulation of audio...

$
0
0

Create a new class that interherits from IWaveProvider.

Now create as example a ctor and give set as parameter a IWaveProvider. Store this in a field. Now in your Readmethod you first read from the stored IWaveProvider and manipulate the read bytes.

New Post: How to play an a-law-encoded network stream

$
0
0

Hi there,

I'm new to NAudio and have problems while trying to play an a-law encoded network stream. My approach goes like this:

RawSourceWaveStream myALawStream = new RawSourceWaveStream(networkStream, WaveFormat.CreateALawFormat(8000, 1));
WaveStream pcmStream = WaveFormatConversionStream.CreatePcmStream(myALawStream);
WaveOut myWaveOut = new WaveOut();
myWaveOut.Init(pcmStream);
myWaveOut.Play();


The WaveOut should play while data is available and be silent when not. But how is the networkStream to be created? I want to fill it with A-law encoded bytes as they come in from the network. Do I have to implement a new class that derives from WaveStream or am I missing something.

 

Thanks,

Norbert

Viewing all 5831 articles
Browse latest View live


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