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

New Post: Extended functionality contribution offer

$
0
0
Hi Mark,

I have two small code classes (written in VB2010) whose functionality I would like to suggest to add to NAudio. These classes were developed to ease the process of creating DAW sampler plugin instruments.

A. SmplChunk

A simple wrapper for Sampler Chunk of a wav file as described in:

http://www.sonicspot.com/guide/wavefiles.html
(refer to the Sampler Chunk - "smpl" section near the bottom of the page).

Of particular interest is the Midi Unity Note as well as the "List of Sample Loops":
  1. The MIDI Unity Note is a nice piece of metadata to have embedded in the file itself as opposed to relying on the filename to specify this info.
  2. If the sample loop points are defined in the wav file itself, files can be moved between DAW sampler formats without having to (externally) specify the loop points in the new sampler format.
Reading these parameters has been implemented; I have not completed the ability to update an existing WAV file with a missing smpl chunk or updated values.

Example usage:
Dim Filename As String = "c:\new_wloop.wav"
Dim myWavFile As New WavFile(Filename)
If myWavFile.SamplerChunk IsNot Nothing Then
    Console.WriteLine(myWavFile.SamplerChunk.MidiUnityNote)
    Console.WriteLine(myWavFile.SamplerChunk.SampleLoopCount)
    Dim I as Integer
    For I = 0 to myWavFile.SamplerChunk.SampleLoopCount - 1
        Console.WriteLine(myWavFile.SamplerChunk.SampleLoop(I).Start)
        Console.WriteLine(myWavFile.SamplerChunk.SampleLoop(I)._End)
    Next 
End If

B. SFZdotNet

A simple wrapper around the sfz Sampler file format as described in:

http://www.cakewalk.com/DevXchange/article.aspx?aid=108

I use this class to programmatically generate sfz instrument files from wav files.
Up to this point I've wrapped up ~25 of the most common Region parameters.

The class does not currently support reading/editing existing files; this is a bit more complicated primarily because the file can be organized in arbitrary order (groups, etc.); plus I didn't require this functionality at the time :)



Simple code example:
Dim mysfz As New SFZdotNET.sfz
mysfz.Comment.Add("This file was generated by a tool.")
mysfz.Comment.Add("Samples courtesy of http://www.freesound.org/people/canucklovingbrit/")
mysfz.Group.Add(New SFZdotNET.Group)
mysfz.Group(0).loop_mode = SFZdotNET.Region.loop_mode_value.one_shot
Dim I As Integer
Dim myFiles() As String
myFiles = IO.Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\Samples")
Dim StartingNoteNumber As Integer = 36
For Each aFile As String In myFiles
    mysfz.Group(0).Region.Add(New SFZdotNET.Region(IO.Path.GetFileName(aFile), I))
    I = I + 1
    Next
mysfz.Save(Environment.GetFolderPath(Environment.SpecialFolder.Desktop) & "\test.sfz")
Output file:

// This file was generated by a tool.
// Samples courtesy of http://www.freesound.org/people/canucklovingbrit/

<group> loop_mode=one_shot
<region> sample=110641__canucklovingbrit__santa-ho-ho-ho-1_001.wav key=36
<region> sample=110641__canucklovingbrit__santa-ho-ho-ho-1_002.wav key=37
<region> sample=110641__canucklovingbrit__santa-ho-ho-ho-1_003.wav key=38
<region> sample=110641__canucklovingbrit__santa-ho-ho-ho-1_004.wav key=39
<region> sample=110641__canucklovingbrit__santa-ho-ho-ho-1_005.wav key=40






If you think either of these classes are a good addition to NAudio, please let me know.

Thanks again for NAudio.

Greg

New Post: Sample Aggregation For WASAPI Loopback

$
0
0
I have been looking into this and it appears that when missed audio occurs, ReadNextPacket is also delayed more than normal (when a standard 50ms 'sleepMilliseconds' value is used), so this isn't an issue with a delay in handling the DataAvailable event, instead it happens much earlier.

During this investigation I logged the Environment.TickCount at key points in the recording chain, as you can see from the below graphs, over a 3.5 minute recording of a song (as a common reference) at various points where the time between calls to ReadNextPacket exceeds 100ms. Beyond this level, noticeable losses can be seen in the written audio at these points, also the 'DataDiscontinuity' flag is raised by AudioCaptureClient.GetBuffer which suggests that the problem lies deeper within the WASAPI loopback capture process.

Image

Any idea what might be holding things up and what might resolve/improve the issue?

Cheers,

Ollie

New Post: Mic input to effectStream Output

$
0
0
Hi, Mark. Please help me. Now I modify EffectStream to simply require an IWaveProvider. But when I call waveOuts.Init(effectStream). It shown clean sound. It sound not process with effect. Please advise me about to get sound to pass effect. Thank you.

New Post: NAudio 1.6 on .Net 4.0 framework

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

New Post: NAudio 1.6 on .Net 4.0 framework

$
0
0
great! I've linked to it on the NAudio homepage. Looks a cool app.

New Post: NAudio 1.6 on .Net 4.0 framework

New Post: Sample Aggregation For WASAPI Loopback

$
0
0
well, Sleep isn't an accurate timer in Windows. Thread.Sleep means sleep for at least 50ms. So if it is taking longer than that to return, it indicates the system is busy doing other stuff. You could reduce the length of the sleep. Alternatively, WASAPI does support an event driven mode. I offer this as an option with WASAPI Out. I can't remember if I made it available for WASAPI in, but that might be a good thing to try.

New Post: Pitch Detection

$
0
0
Is this the correct result?

I editted the code slightly to write out to the console when a value in the console is greater than zero, but the values barely go above 200, which for a constant 500Hz tone I'm not sure is right...

New Post: Mic input to effectStream Output

$
0
0
well what effects have you put into your effect chain?

New Post: Pitch Detection

$
0
0
my autotune code is just looking for the most likely musical note - it is not interested in what octave that note is in, so the range of pitches it outputs may not include the test tones you are using. You need to examine the FFT output directly yourself.

Commented Issue: WaveStillPlaying calling waveUnprepareHeader [16385]

$
0
0
I have written an application that uses nAudio to play wav files when 'events' happen, and records audio from the microphone.

I am occasionally getting a NAudio.MmException "WaveStillPlaying calling waveUnprepareHeader" from NAudio.Wave.WaveInBuffer.Reuse().

I am using nAudio 1.5.4.

Any thoughts on what causes it, and how I can resolve it?
Comments: great, thanks for letting me know

Edited Issue: WaveStillPlaying calling waveUnprepareHeader [16385]

$
0
0
I have written an application that uses nAudio to play wav files when 'events' happen, and records audio from the microphone.

I am occasionally getting a NAudio.MmException "WaveStillPlaying calling waveUnprepareHeader" from NAudio.Wave.WaveInBuffer.Reuse().

I am using nAudio 1.5.4.

Any thoughts on what causes it, and how I can resolve it?

Edited Issue: System.NullReferenceException in NAudio.Wave.WaveOutEvent.PlaybackThread() [16386]

$
0
0
I have written an application that uses nAudio to play wav files when 'events' happen, and records audio from the microphone.

I am occasionally getting a System.NullReferenceException from NAudio.Wave.WaveOutEvent.PlaybackThread()

I am using nAudio 1.5.4.

Any thoughts on what causes it, and how I can resolve it?


Commented Issue: NAudio.MmException - WaveStillPlaying calling waveOutWrite [16387]

$
0
0
I have written an application that uses nAudio to play wav files when 'events' happen, and records audio from the microphone.

I am occasionally getting a NAudio.MmException from NAudio.Wave.WaveOutBuffer.WriteToWaveOut()
I am using nAudio 1.5.4.

Any thoughts on what causes it, and how I can resolve it?


Comments: Yes, 1.6 handles exceptions in the callbacks better

Edited Issue: NAudio.MmException - WaveStillPlaying calling waveOutWrite [16387]

$
0
0
I have written an application that uses nAudio to play wav files when 'events' happen, and records audio from the microphone.

I am occasionally getting a NAudio.MmException from NAudio.Wave.WaveOutBuffer.WriteToWaveOut()
I am using nAudio 1.5.4.

Any thoughts on what causes it, and how I can resolve it?


Commented Issue: Occasional System.InvalidOperationException (Handle is not initialized) in AcmStreamHeader.Dispose [16389]

$
0
0
Occasionally my application crashes....
I have captured the crash using WinDbg, and the Exception trace is:

Exception object: 026c18ac
Exception type: System.InvalidOperationException
Message: Handle is not initialized.
InnerException: <none>
StackTrace (generated):
SP IP Function
00E5FAE8 66D30A4E mscorlib_ni!System.Runtime.InteropServices.GCHandle.Free()+0x93679e
00E5FAFC 075EC9C4 UNKNOWN!NAudio.Wave.Compression.AcmStreamHeader.Dispose(Boolean)+0x24
00E5FB08 075FBCE8 UNKNOWN!NAudio.Wave.Compression.AcmStreamHeader.Finalize()+0x18

Obviously one or more of the GCHandles has already been freed, but I have looked over the code for AcmStreamHeader and cannot see how this can occur - the Dispose() methods appear to handle being called twice, and attempt to prevent this happening. I'm not sure why the GC.SuppressFinalize(this), and Dispose(true); are ordered as they are (in Dispose()) - as this is not the normal recommendation.

My only thought is that the Garbage collector has some kind of parallelism that is allow the Finalizer to run despite the fact that Dispose() is active too?
Comments: strange. You could make a custom build and run it with the ordering differently. Are you sure that you Disposing every single WaveFormatCompressionStream you create?

New Post: Network Chat Multi-Client Program

$
0
0
Can this also work if I have more than one client connected to the server? As long as one client has enough data in their bufferedwaveprovider, I should be able to have waveOut play the audio while still collecting data from other clients. I'm thinking all I would have to do is create a while loop to find a client that has sufficient data and then play the audio. Would that be sufficient or do you think there's more to it than that?

Commented Issue: Assembly with strong name [11429]

$
0
0
Hello,

Could you please release NAudio as an assembly with a strong name so it can be installed in the GAC by running gacutil -i NAudio.dll?

Thanks.
Comments: Bump

Commented Issue: Assembly with strong name [11429]

$
0
0
Hello,

Could you please release NAudio as an assembly with a strong name so it can be installed in the GAC by running gacutil -i NAudio.dll?

Thanks.
Comments: I'm afraid I don't currently have any plans to do this. It seems to cause more problems than it solves (and I don't really want to start publishing two editions of NAudio). My recommendations if your company really really needs signed DLLs for some reason: 1) sign it yourselves 2) hire me to make a special signed version just for you ;)
Viewing all 5831 articles
Browse latest View live


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