Extended functionality contribution offer

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

Of particular interest is the Midi Unity Note as well as the "List of Sample Loops":

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.

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

One application for this class is to programmatically generate sfz instrument files from a folder a wav files. At present, 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 :)

hi Greg, thanks for this. NAudio is in C#, so they would need to be converted. The sampChunk would be particularly nice if it could integrate with NAudio's existing WAV chunk support (convert from RiffChunk).

NAudio did include a sfz parser but I took it out because it wasn't fully featured. I'd probably just go with a demo app for sfz for now, and only move it into NAudio when both a reader and a writer are available.