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.
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":
Example usage:
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:
// 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
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":
-
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.
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