Jump to content


Photo

Sf2Xrni


  • Please log in to reply
29 replies to this topic

#1 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 10 March 2010 - 04:26

Hello,

I have created a simple soundfont-to-xrni conversion utility. While the new VST Grabber would fill lots of such SoundFont need, I guess this converter would be still useful for some uses.

The converter is rather a hack, far from well designed and perfect (I'm very new to both soundfont and renoise land, haven't written any songs yet). I tried only a few sf2 files, but it looks working in general.

If any of you are interested, please give it a try. sf2xrni is at:

http://github.com/atsushieno/sf2xrni

It is based on NAudio and NRenoiseTools (binaries are included in the project files). You'll need .NET Framework 3.5 or Mono to run it.

Your feedback is appreciated :)

#2 hotelsinus

hotelsinus

    Big Daddy Member

  • Normal Members
  • PipPipPipPipPipPipPip
  • 412 posts
  • Gender:Male
  • Location:Hungary
  • Interests:Sound Design music Sound Creatin and how they born.

Posted 25 May 2010 - 09:33

Interesting idea, indeed.
But i dont want to convert tonz of my SF2's ot XRNI.

The good way is we can load SF2 or REX files to Renoise. Just like EnergyXT2 latest update can do this!

#3 Djeroek

Djeroek

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 6639 posts
  • Gender:Male
  • Location:Borneo

Posted 25 May 2010 - 16:01

The good way is we can load SF2 or REX files to Renoise. Just like EnergyXT2 latest update can do this!


rex file support would mean multiple markers in the sample editor = very probable beatslicer implementation as well :drummer: +1

Never have used sountfonts, what is the benefit over normal .wavs?

#4 Conner_Bw

Conner_Bw

    Probably More God or Borg Than Human Member

  • Normal Members
  • PipPipPipPipPipPipPipPipPipPipPipPipPipPipPip
  • 7043 posts
  • Gender:Male
  • Location:Montreal, Quebec, Canada

Posted 25 May 2010 - 16:25

Not the feature request forum?

cpu Lenovo X220, Intel i7-2640M @ 2.80GHz ×4 os Windows 10 / Ubuntu 16.04 LTS
My Homepage » : My Renoise Tools » : Normalize Your Sig » : One million clicks! »


#5 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 25 May 2010 - 20:23

Thanks guys, nice to know that it attracted some interests :)
Yeah, sf2xrni wouldn't help if you have a lot of sf2 files with not too many storage space.

As for my own purpose for sf2xrni: I wanted to try out several soundfonts with renoise's own tone selector UI, not through VST plugin (which was not very efficient as far as I tried; I have to open a program/bank selector UI, close, and then test its sound, instead of a few clicks). Converting them into .xrni was easier.

SF2 and XRNI are different in data structures. Basically sf2 has a set of instruments (unlike xrni for an instrument) and many (I'd say, too many) features than whatever Renoise supports. So, supporting SF2 in Renoise itself would require not a few works (functionality-wise and UI-wise), and I'm not sure if it is a good idea to put it to the stack of the requested features. (I also think there was the same feature idea earlier in this forum, and not many people were for that.)

#6 Khades

Khades

    Member

  • Normal Members
  • PipPip
  • 69 posts

Posted 07 March 2011 - 19:32

i'd try to use that tool for my soundfont library, but if it would work i would be happy

thanks for tools anyway

#7 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 14 June 2011 - 19:50

Hello,

I have created a simple soundfont-to-xrni conversion utility. While the new VST Grabber would fill lots of such SoundFont need, I guess this converter would be still useful for some uses.

The converter is rather a hack, far from well designed and perfect (I'm very new to both soundfont and renoise land, haven't written any songs yet). I tried only a few sf2 files, but it looks working in general.

If any of you are interested, please give it a try. sf2xrni is at:

http://github.com/atsushieno/sf2xrni

It is based on NAudio and NRenoiseTools (binaries are included in the project files). You'll need .NET Framework 3.5 or Mono to run it.

Your feedback is appreciated :)


Is there a pre-compiled version of this tool available? I've tried to follow the installation instructions, but am unsure how to get it to work.
  • esaruoho likes this

#8 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 14 June 2011 - 21:23

Is there a pre-compiled version of this tool available? I've tried to follow the installation instructions, but am unsure how to get it to work.


Yes, there is a link to "Download" dialog. The latest archive contains both .exe and README.

#9 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 15 June 2011 - 02:33

Thanks atsushieno. However, when I run the program from the command line, I get the following output:
E:\Samples\sf2xrni "12.5mg GM Bank"

Unhandled Exception: System.BadImageFormatException: Could not load file or asse
mbly 'NAudio, Version=1.3.9.0, Culture=neutral, PublicKeyToken=null' or one of i
ts dependencies. An attempt was made to load a program with an incorrect format.

File name: 'NAudio, Version=1.3.9.0, Culture=neutral, PublicKeyToken=null'
   at Commons.Music.Sf2Xrni.Sf2Xrni.Import(String file, String filter)
   at Commons.Music.Sf2Xrni.Driver.Main(String[] args)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].

What am I missing? I have all of the files included in the zip file, plus the soundfont is in the same directory, which I hoped would have made things easier on the program.

Thanks for your help!

#10 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 15 June 2011 - 06:03

Thanks atsushieno. However, when I run the program from the command line, I get the following output:

E:\Samples\sf2xrni "12.5mg GM Bank"

Unhandled Exception: System.BadImageFormatException: Could not load file or asse
mbly 'NAudio, Version=1.3.9.0, Culture=neutral, PublicKeyToken=null' or one of i
ts dependencies. An attempt was made to load a program with an incorrect format.

File name: 'NAudio, Version=1.3.9.0, Culture=neutral, PublicKeyToken=null'
   at Commons.Music.Sf2Xrni.Sf2Xrni.Import(String file, String filter)
   at Commons.Music.Sf2Xrni.Driver.Main(String[] args)

WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\M
icrosoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure lo
gging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fus
ion!EnableLog].

What am I missing? I have all of the files included in the zip file, plus the soundfont is in the same directory, which I hoped would have made things easier on the program.

Thanks for your help!


Oh, indeed. Thanks for the details. I got the same exception when running on .NET. I always ran it with mono (as I am an insider ;) , so I didn't notice that.

I could get sf2xrni working by recompiling the sources with .NET 3.5. I pushed the latest build on the download page, so please retry with the latest one.

This tool was written in .NET 2.x runtime era and when I had x86 machine, so I wasn't even aware of 64bit-ness issue. NRenoiseTools has also been updated to deprecate my sources :/ so I will have to make them up to date too.

#11 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 15 June 2011 - 14:44

Thanks for taking the time to fix this! I'm looking forward to trying it out, but unfortunately GitHub won't let me download the new version you've compiled (it complains about an Access Denied error).

I didn't expect really to have any issues on the machine I'm using as it's Windows 7 32-bit, but then if they've been updating the libraries on you that's bound to break something! :)

#12 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 16 June 2011 - 05:38

Thanks for taking the time to fix this! I'm looking forward to trying it out, but unfortunately GitHub won't let me download the new version you've compiled (it complains about an Access Denied error).

I didn't expect really to have any issues on the machine I'm using as it's Windows 7 32-bit, but then if they've been updating the libraries on you that's bound to break something! :)


Hmm, I was also getting Access Denied. I've deleted and uploaded the archive again and confirmed the new download works. So, please retry. Sorry for inconvenience.

#13 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 16 June 2011 - 15:03

Thanks atsushieno! I've been trying the program out with a number of different soundfonts, and for the most part things seem to be going well - it's certainly a lot quicker than converting the soundfonts manually!

I've come across a couple of instances where some errors have popped up. The first one is:
Unhandled Exception: System.ArgumentOutOfRangeException: startIndex cannot be la
rger than length of string.
Parameter name: startIndex
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length,
Boolean fAlwaysCopy)
   at NRenoiseTools.Instrument.Save(Stream xrniOutputStream)
   at Commons.Music.Sf2Xrni.Sf2XrniStreamingConverter.OnXrniCreated(Instrument x
rni)
   at Commons.Music.Sf2Xrni.Sf2Xrni.Import(String file, String filter)
   at Commons.Music.Sf2Xrni.Driver.Main(String[] args)

and the second is:
Unhandled Exception: System.IO.EndOfStreamException: Unable to read beyond the e
nd of the stream.
   at System.IO.__Error.EndOfFile()
   at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
   at System.IO.BinaryReader.ReadUInt32()
   at NAudio.SoundFont.SampleHeaderBuilder.Read(BinaryReader br)
   at NAudio.SoundFont.RiffChunk.GetDataAsStructureArray(StructureBuilder s)
   at NAudio.SoundFont.PresetsChunk..ctor(RiffChunk chunk)
   at NAudio.SoundFont.SoundFont..ctor(String fileName)
   at Commons.Music.Sf2Xrni.Sf2Xrni.Import(String file, String filter)
   at Commons.Music.Sf2Xrni.Driver.Main(String[] args)

There is a third one I've experienced where sf2xrni will close whilst processing a soundfont, and that's where illegal characters are used in the instrument/patch name (e.g. </\|>) that can't be translated into a filename. Could you add an exception handler in the program to replace those with an acceptable character such as an underscore ( _ )?

I hope that helps!

#14 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 17 June 2011 - 00:55

Thanks for the feedback!

I've come across a couple of instances where some errors have popped up. The first one is:

Unhandled Exception: System.ArgumentOutOfRangeException: startIndex cannot be la
rger than length of string.
Parameter name: startIndex
   at System.String.InternalSubStringWithChecks(Int32 startIndex, Int32 length,
Boolean fAlwaysCopy)
   at NRenoiseTools.Instrument.Save(Stream xrniOutputStream)
   at Commons.Music.Sf2Xrni.Sf2XrniStreamingConverter.OnXrniCreated(Instrument x
rni)
   at Commons.Music.Sf2Xrni.Sf2Xrni.Import(String file, String filter)
   at Commons.Music.Sf2Xrni.Driver.Main(String[] args)

and the second is:
Unhandled Exception: System.IO.EndOfStreamException: Unable to read beyond the e
nd of the stream.
   at System.IO.__Error.EndOfFile()
   at System.IO.BinaryReader.FillBuffer(Int32 numBytes)
   at System.IO.BinaryReader.ReadUInt32()
   at NAudio.SoundFont.SampleHeaderBuilder.Read(BinaryReader br)
   at NAudio.SoundFont.RiffChunk.GetDataAsStructureArray(StructureBuilder s)
   at NAudio.SoundFont.PresetsChunk..ctor(RiffChunk chunk)
   at NAudio.SoundFont.SoundFont..ctor(String fileName)
   at Commons.Music.Sf2Xrni.Sf2Xrni.Import(String file, String filter)
   at Commons.Music.Sf2Xrni.Driver.Main(String[] args)


For those files, can you give me more infos, namely which soundfont did you try? Either posting here or emailing atsushieno@veritas-vos-liberabit.com would be great. They may be either bugs in sf2xrni tool, NRenoiseTool library (sf2xrni dependency) or NAudio library (this too).

There is a third one I've experienced where sf2xrni will close whilst processing a soundfont, and that's where illegal characters are used in the instrument/patch name (e.g. </\|>) that can't be translated into a filename. Could you add an exception handler in the program to replace those with an acceptable character such as an underscore ( _ )?


Ah, didn't notice that possibility. I've fixed this issue and pushed new download on github.

#15 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 19 June 2011 - 02:21

Ok, so for those of you who've been watching this thread, atsushieno has resolved a lot of the issues I was having problems with :-)

Now the program runs, the next problem is getting Renoise to load in the XRNI files that sf2xrni has converted. At the moment I get an error in Renoise, saying:

Posted Image

I guess that sf2xrni will need to call a sample convertor (e.g. ffmpeg) to put the samples into the correct format. I haven't searched, but is there a quick way to extract the samples from an XRNI file to see what format they've been saved in?

#16 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 21 June 2011 - 07:39

Ok, so for those of you who've been watching this thread, atsushieno has resolved a lot of the issues I was having problems with :-)

Now the program runs, the next problem is getting Renoise to load in the XRNI files that sf2xrni has converted. At the moment I get an error in Renoise, saying:

Posted Image

I guess that sf2xrni will need to call a sample convertor (e.g. ffmpeg) to put the samples into the correct format. I haven't searched, but is there a quick way to extract the samples from an XRNI file to see what format they've been saved in?


Oops, I found that it was bad to have blindly updated NRenoiseTools.dll without any changes. I had to fix one thing to get converter working fine.

Please download 0.1.6 package. I verified the resulting samples sound fine on renoise 2.7.

Thanks for the report :)

#17 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 21 June 2011 - 15:01

Oops, I found that it was bad to have blindly updated NRenoiseTools.dll without any changes. I had to fix one thing to get converter working fine.

Please download 0.1.6 package. I verified the resulting samples sound fine on renoise 2.7.

Thanks for the report :)


No worries - thanks for the update! I can confirm that the samples work in Renoise too.

One question that I thought of is that with the new Renoise Instrument format allowing for instruments with multiple layers per key, does this tool take that into account? For example, the jRhodes soundfont that I referred to earlier should have multiple velocity layers (I downloaded the 5 layered, unlooped version from http://learjeff.net/sf/sf.html), but so far the instrument loads into Renoise like this:

Posted Image

I hope that helps - we're getting close to having this tool fully functional!

#18 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 23 June 2011 - 17:24

No worries - thanks for the update! I can confirm that the samples work in Renoise too.

One question that I thought of is that with the new Renoise Instrument format allowing for instruments with multiple layers per key, does this tool take that into account? For example, the jRhodes soundfont that I referred to earlier should have multiple velocity layers (I downloaded the 5 layered, unlooped version from http://learjeff.net/sf/sf.html), but so far the instrument loads into Renoise like this:

Posted Image

I hope that helps - we're getting close to having this tool fully functional!


Oh, indeed. Actually I wanted this kind of usecase when I was hacking this tool for the first time, and this time I filled the missing parts that supports it. I have uploaded a new archive that contains this fix. Thanks again for the reproducible test :)

#19 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 24 June 2011 - 02:42

Oh, indeed. Actually I wanted this kind of usecase when I was hacking this tool for the first time, and this time I filled the missing parts that supports it. I have uploaded a new archive that contains this fix. Thanks again for the reproducible test :)


No worries, and thanks for the update! :)

So here is what I get so far - using the jRhodes3 soundfont again as our test case, loading the soundfont into the sfzed soundfont editor we can see the five velocity layers for each key:

Posted Image

At the moment, sf2xrni seems to be considering only the first layer that it comes across, which is good, but not a direct translation :)

Posted Image

I hope it's not too much more code to assign the keyzones correctly! :)

#20 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 26 June 2011 - 08:30

Hi again,

No worries, and thanks for the update! :)

So here is what I get so far - using the jRhodes3 soundfont again as our test case, loading the soundfont into the sfzed soundfont editor we can see the five velocity layers for each key:

<snip/>

At the moment, sf2xrni seems to be considering only the first layer that it comes across, which is good, but not a direct translation :)

<snip/>

I hope it's not too much more code to assign the keyzones correctly! :)


Today I dug in depth to my source, NRenoiseToools and NAudio, and found that this velocity-aware samples are available only after 2.7 - correct? NRenoiseTools supports only before 2.5 formats so it does not cover things like 'SampleSplitMap' element (which contains 'VelocityStart' and 'VelocityEnd' elements).

I'll revisit sd2xrni source when NRenoiseTools supports 2.7-or-later format.

#21 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 26 June 2011 - 20:06

Hi again,



Today I dug in depth to my source, NRenoiseToools and NAudio, and found that this velocity-aware samples are available only after 2.7 - correct? NRenoiseTools supports only before 2.5 formats so it does not cover things like 'SampleSplitMap' element (which contains 'VelocityStart' and 'VelocityEnd' elements).

I'll revisit sd2xrni source when NRenoiseTools supports 2.7-or-later format.


From what I've read from the release notes, you're correct in that XRNI only started to use multiple velocity layers in 2.7. I guess you've got as far as you can with the tools you have for now! Fingers crossed the NRenoiseTools libraries are updated soon! :)

#22 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 29 June 2011 - 08:26

From what I've read from the release notes, you're correct in that XRNI only started to use multiple velocity layers in 2.7. I guess you've got as far as you can with the tools you have for now! Fingers crossed the NRenoiseTools libraries are updated soon! :)


I have reported the enhancement issue to NRenoiseTools dev. and he came up with 2.7 support (only in devel repository yet) so I tried to implement SampleSplitMap support. But I cannot get it; I believe it's almost done but Renoise only loads the first sample into an entire sample area... Since there is no public documentation on how I can correctly create SampleSplitMap elements, I find it almost impossible to do it :(

I have updated sf2xrni code in github to reflect the latest NRenoiseTools changes, as well as packaged binary here http://dl.dropbox.co...xrni-latest.zip so that anyone can try and see what's wrong.

Thanks,
Atsushi Eno

#23 unaHm

unaHm

    Member

  • Normal Members
  • PipPip
  • 10 posts

Posted 12 July 2011 - 15:10

Have you had any responses to your request Atsushi? Not really being a programmer (for now) I can't help that much on the development side :)

A couple of the converted instruments I've worked on recently have loop points that are incorrect, although I know that looping in soundfonts can often be a bit 'questionable'! Most of those I've found tend to put a loop right at the end of the sample, on an extremely small section of that sample. It's not much of a problem though, as we should tweak the xrni file afterwards anyway :)

#24 atsushieno

atsushieno

    Member

  • Normal Members
  • PipPip
  • 14 posts
  • Gender:Male
  • Location:Japan

Posted 13 July 2011 - 00:13

Have you had any responses to your request Atsushi? Not really being a programmer (for now) I can't help that much on the development side :)


Oops, I once asked NRenoiseTools man but I already got a response and code, and I haven't asked any question to anyone so far. It's just left for some time I want to revisit with some new ideas, and I've been doing nothing as I'm now traveling around.

A couple of the converted instruments I've worked on recently have loop points that are incorrect, although I know that looping in soundfonts can often be a bit 'questionable'! Most of those I've found tend to put a loop right at the end of the sample, on an extremely small section of that sample. It's not much of a problem though, as we should tweak the xrni file afterwards anyway :)


Oh you can still send me or post new issues, I'll then try to find fixage :)

#25 Drop Shadow

Drop Shadow

    Big Daddy Member

  • Normal Members
  • PipPipPipPipPipPipPip
  • 434 posts
  • Gender:Male
  • Location:Copenhagen

Posted 18 October 2011 - 19:55

Great project. However, I can't open the program.

I've downloaded and installed Mono 2.10.6.
I open Mono Command Prompt, browse to the sf2xrni's location, try to run it, but nothing happens. What to do?