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

Released: NAudio 1.6 (Oct 26, 2012)


Updated Release: NAudio 1.6 (Oct 26, 2012)

Edited Issue: Format header read for some wav files are incorrect [10105]

$
0
0
The problem is if the header length is not quite correct. fool.wav is a wave file that plays correctly in most players and reads correctly through the mm api, but fails in naudio

The solutions was to hack WaveFormat to set the binary reader to the correct position

/// <summary>
/// Reads a new WaveFormat object from a stream
/// </summary>
/// <param name="br">A binary reader that wraps the stream</param>
public WaveFormat(BinaryReader br)
{
int formatChunkLength = br.ReadInt32();
--> ADDED long chunkStartPosition = br.BaseStream.Position;

if(formatChunkLength < 16)
throw new ApplicationException("Invalid WaveFormat Structure");
this.waveFormatTag = (WaveFormatEncoding) br.ReadUInt16();
this.channels = br.ReadInt16();
this.sampleRate = br.ReadInt32();
this.averageBytesPerSecond = br.ReadInt32();
this.blockAlign = br.ReadInt16();
this.bitsPerSample = br.ReadInt16();
if (formatChunkLength > 16)
{

this.extraSize = br.ReadInt16();
if (this.extraSize > formatChunkLength - 18)
{
Console.WriteLine("Format chunk mismatch");
//RRL GSM exhibits this bug. Don't throw an exception
//throw new ApplicationException("Format chunk length mismatch");

this.extraSize = (short) (formatChunkLength - 18);
}

// read any extra data
// br.ReadBytes(extraSize);

}

ADDED--> br.BaseStream.Position = chunkStartPosition + formatChunkLength;
}

Closed Issue: Format header read for some wav files are incorrect [10105]

$
0
0
The problem is if the header length is not quite correct. fool.wav is a wave file that plays correctly in most players and reads correctly through the mm api, but fails in naudio

The solutions was to hack WaveFormat to set the binary reader to the correct position

/// <summary>
/// Reads a new WaveFormat object from a stream
/// </summary>
/// <param name="br">A binary reader that wraps the stream</param>
public WaveFormat(BinaryReader br)
{
int formatChunkLength = br.ReadInt32();
--> ADDED long chunkStartPosition = br.BaseStream.Position;

if(formatChunkLength < 16)
throw new ApplicationException("Invalid WaveFormat Structure");
this.waveFormatTag = (WaveFormatEncoding) br.ReadUInt16();
this.channels = br.ReadInt16();
this.sampleRate = br.ReadInt32();
this.averageBytesPerSecond = br.ReadInt32();
this.blockAlign = br.ReadInt16();
this.bitsPerSample = br.ReadInt16();
if (formatChunkLength > 16)
{

this.extraSize = br.ReadInt16();
if (this.extraSize > formatChunkLength - 18)
{
Console.WriteLine("Format chunk mismatch");
//RRL GSM exhibits this bug. Don't throw an exception
//throw new ApplicationException("Format chunk length mismatch");

this.extraSize = (short) (formatChunkLength - 18);
}

// read any extra data
// br.ReadBytes(extraSize);

}

ADDED--> br.BaseStream.Position = chunkStartPosition + formatChunkLength;
}
Comments: released in NAudio 1.6

Edited Issue: Error if mp3 frame not at the begining [9071]

$
0
0
If the frame header don't starts imediatly after the the end of the ID3 Tag (or the begining of the file), it is not recognised as an mp3 file, however it is valid, according to http://www.datavoyage.com/mpgscript/mpeghdr.htm. I know, this is not the official source, but for me it worked. I had such a file, ad after changing the sourcecode, it worked fine.

I attach the changed Mp3Frame.cs. But it is not the best/most efficient way. But this is from the 24556 build version.

And sorry for my bad english :)

Closed Issue: Error if mp3 frame not at the begining [9071]

$
0
0
If the frame header don't starts imediatly after the the end of the ID3 Tag (or the begining of the file), it is not recognised as an mp3 file, however it is valid, according to http://www.datavoyage.com/mpgscript/mpeghdr.htm. I know, this is not the official source, but for me it worked. I had such a file, ad after changing the sourcecode, it worked fine.

I attach the changed Mp3Frame.cs. But it is not the best/most efficient way. But this is from the 24556 build version.

And sorry for my bad english :)
Comments: released in NAudio 1.6

Edited Issue: IeeeFloat to ASIOSTFloat32LSB converter [7979]

$
0
0
If you have sound that's already IeeeFloat but you use ASIO, it seems to me it must be deinterleaved as I found of no way to just pass the interleaved floats through it.

So I've added these to NAudio\Wave\Asio\ASIOSampleConvertor.cs:

case ASIOSampleType.ASIOSTFloat32LSB:
switch (waveFormat.BitsPerSample)
{
case 32:
convertor = (SampleConvertor)ConvertorFloatToFloat2Channels;
break;
}
break;

// IeeeFloat to ASIOSTFloat32LSB (deinterleave)
public static void ConvertorFloatToFloat2Channels(IntPtr inputInterleavedBuffer, IntPtr[] asioOutputBuffers, int nbChannels, int nbSamples)
{
unsafe
{
float* inputSamples = (float*)inputInterleavedBuffer;
float* leftSamples = (float*)asioOutputBuffers[0];
float* rightSamples = (float*)asioOutputBuffers[1];

for (int i = 0; i < nbSamples; i++)
{
*leftSamples++ = inputSamples[0];
*rightSamples++ = inputSamples[1];
inputSamples += 2;
}
}
}

Closed Issue: IeeeFloat to ASIOSTFloat32LSB converter [7979]

$
0
0
If you have sound that's already IeeeFloat but you use ASIO, it seems to me it must be deinterleaved as I found of no way to just pass the interleaved floats through it.

So I've added these to NAudio\Wave\Asio\ASIOSampleConvertor.cs:

case ASIOSampleType.ASIOSTFloat32LSB:
switch (waveFormat.BitsPerSample)
{
case 32:
convertor = (SampleConvertor)ConvertorFloatToFloat2Channels;
break;
}
break;

// IeeeFloat to ASIOSTFloat32LSB (deinterleave)
public static void ConvertorFloatToFloat2Channels(IntPtr inputInterleavedBuffer, IntPtr[] asioOutputBuffers, int nbChannels, int nbSamples)
{
unsafe
{
float* inputSamples = (float*)inputInterleavedBuffer;
float* leftSamples = (float*)asioOutputBuffers[0];
float* rightSamples = (float*)asioOutputBuffers[1];

for (int i = 0; i < nbSamples; i++)
{
*leftSamples++ = inputSamples[0];
*rightSamples++ = inputSamples[1];
inputSamples += 2;
}
}
}
Comments: released in NAudio 1.6

Edited Issue: Midi Interop with MIDIHDR is wrong? [2278]

$
0
0
I think your interop with the MIDIHDR struct is wrong. You use a marshal-as attribute and a ref. I think this will not prevent the GC from relocating the (managed) MIDIHDR and when that happens the ref passed to (for instance) midiInAddBuffer is no longer valid. I would use an IntPtr to an unmanaged memory block that contains the MIDIHDR (copied there using Marshal.StructureToPtr).

Closed Issue: Midi Interop with MIDIHDR is wrong? [2278]

$
0
0
I think your interop with the MIDIHDR struct is wrong. You use a marshal-as attribute and a ref. I think this will not prevent the GC from relocating the (managed) MIDIHDR and when that happens the ref passed to (for instance) midiInAddBuffer is no longer valid. I would use an IntPtr to an unmanaged memory block that contains the MIDIHDR (copied there using Marshal.StructureToPtr).
Comments: released in NAudio 1.6

Edited Feature: WMA Reader and WMA Writer Classes [6341]

$
0
0
http://msdn.microsoft.com/en-us/library/bb288688(VS.85).aspx

Closed Feature: WMA Reader and WMA Writer Classes [6341]

$
0
0
http://msdn.microsoft.com/en-us/library/bb288688(VS.85).aspx
Comments: released in NAudio 1.6

Updated Wiki: Home

$
0
0

NAudio Overview

NAudio is an open source .NET audio and MIDI library, containing dozens of useful audio related classes intended to speed development of audio related utilities in .NET. It has been in development since 2002 and has grown to include a wide variety of features. While some parts of the library are relatively new and incomplete, the more mature features have undergone extensive testing and can be quickly used to add audio capabilities to an existing .NET application. NAudio can be quickly added to your .NET application using NuGet.

NAudio demo project showing an MP3 file playing:
naudiodemo.png

NAudio WPF Project showing waveform visualisation and spectrum analyser:
NAudioWPF.png

Latest News

For the latest news and more documentation on NAudio, visit Mark Heath's blog.
  • 26 Oct 2012 NAudio 1.6 Released. Read the release notes
  • 9 Sep 2012 ASIO Recording Support added
  • 19 Dec 2011 NAudio 1.5 Released. Read the release notes
  • 20 Apr 2011 NAudio 1.4 Released. Read the release notes
  • 15 Apr 2011 NAudio demo now shows how to select output devices (for WaveOut, DirectSound, WASAPI and ASIO), and can play 8 bit, 16 bit, 24 bit, and 32 bit float WAV files. Fixed a longstanding ASIO issue.
  • 7 Nov 2010 Major improvements to Mp3FileReader
  • 10 Oct 2009 Version 1.3 Released. Read the release notes
  • 20 Sep 2009 We are getting close to feature complete for 1.3. Last chance to get in any feedback on the API
  • 26 Aug 2009 WPF Waveform drawing demo project including FFT added
  • 28 Feb 2009 Lots of new stuff is being added and planned, so do check out the Source Code tab to have a sneak peak at what's coming in 1.3
  • 26 June 2008 Version 1.2 Released. Read the release notes

NAudio Features

  • Play back audio using a variety of APIs
    • WaveOut
    • DirectSound
    • ASIO
    • WASAPI (Windows Vista and above)
  • Decompress audio from different Wave Formats
    • MP3 decode using ACM or DMO codec
    • AIFF
    • G.711 mu-law and a-law
    • ADPCM
    • G.722
    • Speex (using NSpeex)
    • SF2 files
    • Decode using any ACM codec installed on your computer
  • Record audio using WaveIn, WASAPI or ASIO
  • Read and Write standard .WAV files
  • Mix and manipulate audio streams using a 32 bit floating mixing engine
  • Extensive support for reading and writing MIDI files
  • Full MIDI event model
  • Basic support for Windows Mixer APIs
  • A collection of useful Windows Forms Controls
  • Some basic audio effects, including a compressor

Projects Using NAudio

NAudio currently is used to support a number of audio related utilities, some of which may be moved to be hosted on CodePlex in the future. If you have used NAudio for a project, please get in touch so we can post it here.

More Info

For more information, please visit the NAudio Documentation Wiki

Donate

NAudio is a free open source project that is developed in personal time. You can show your appreciation for NAudio and support future development by donating.
Donate

Created Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Edited Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}


Edited Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: Whoooops, I checked it a second time, WaveOutEvent doesn't has the problem, I think this can be closed!

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: Ok, I'm really sorry, but with the WaveOutEvent class, the exception is now thrown only sometimes

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: what OS and soundcard are you using?

Commented Issue: AccessViolationException when disposing WaveOut in a 64-bit application [16369]

$
0
0
I'm currently migrating my application to 64-bit and whenever I'm trying to dispose the WaveOut class, I'm getting an "AccessVoilationException" with the message "Attempted to read or write protected memory. This is often an indication that other memory is corrupt."

Stacktrace:

at NAudio.Wave.WaveInterop.waveOutClose(IntPtr hWaveOut)
at NAudio.Wave.WaveOut.Dispose(Boolean disposing)
at NAudio.Wave.WaveOut.Dispose()

I've tested this with version 1.5 and 1.6 of NAudio, it only happens when I compile my application for 64-bit, 32-bit works fine.

Small codepiece where it happens:

if (wavePlayer != null)
{
this.wavePlayer.Stop();
this.wavePlayer.Dispose(); //AccessViolationException
}

Initialization of the WaveOut class:
this.wavePlayer = new WaveOut(WaveCallbackInfo.FunctionCallback());

I've also tried it with the new WaveOutEvent class in NAudio, but the problem persists.
Comments: I knew I forgot to mention something... I'm using Windows 7 64-bit, Soundcard is the built in of my Asus N56-VZ (hm, where do I find the specific model?), but the exception occurs on all of my 3 computers (also with Win7 64-bit)
Viewing all 5831 articles
Browse latest View live


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