Code Monkey home page Code Monkey logo

Comments (9)

danigb avatar danigb commented on May 29, 2024 1

Hi @this-fifo

I've found this https://github.com/Mrtenz/soundfont2/ that looks very promising to convert sf2 files into smpr json.

from smplr.

danigb avatar danigb commented on May 29, 2024 1

Hi @this-fifo I've created a new sampler capable of reading .sf2 files directly. Only limited amount of features are implemented. Feel free to open another issue if you need any of them.

from smplr.

this-fifo avatar this-fifo commented on May 29, 2024 1

Thank you so much @danigb , you're truly amazing! 🙇‍♂️

I've tested it with my custom soundfonts and I've been pretty happy so far!

Also, I took the liberty to fix a small typo you had on the README.md for it through this PR #82 — feel free to disregard it or correct it in your own words.

Thank you so much once again!

from smplr.

danigb avatar danigb commented on May 29, 2024

Wow @this-fifo this is amazing. Very well presented all the points and problems 👏 Inspiring too 👍

First of all, the sample rate of 41000 is totally a bug, and could be the reason behind the clicks! I'll start by fixing that and test. Let me do it right now.

About the script: I didn't use it myself, but I'll give it a try. I don't have any idea why it generates samples <3s length. Do you have any sf file I can use for testing?

Keep you posted

from smplr.

this-fifo avatar this-fifo commented on May 29, 2024

Hey @danigb thank you so much for getting back to me so quickly, I'm glad that I was able to help you find that bug!

In terms of the soundfont_builder.rb script, the reason why it caps at 3 seconds is because that that is the default configuration in that file, there are 2 hardcoded constants of interest I found there

VELOCITY = 85
DURATION = Integer(3000)

https://github.com/gleitz/MIDI.js/blob/1433d3913d26c1e5f80b3fa0ab63c98584b0087d/generator/ruby/soundfont_builder.rb#L352-L353

That constant is used to create a MIDI event that lasts from 0 to 3 with velocity 85 this way:

track.events << NoteOn.new(0, note_value, VELOCITY, 0)
track.events << NoteOff.new(0, note_value, VELOCITY, DURATION)

https://github.com/gleitz/MIDI.js/blob/1433d3913d26c1e5f80b3fa0ab63c98584b0087d/generator/ruby/soundfont_builder.rb#L393-L394

Later, another thing that I'm not sure why it's done that way but, when it renders the audio with fluidsynth, it also sets the gain to 0.5 with -g 0.5 here: https://github.com/gleitz/MIDI.js/blob/1433d3913d26c1e5f80b3fa0ab63c98584b0087d/generator/ruby/soundfont_builder.rb#L405

As for test soundfonts, I'm using various I'm finding on this website https://musical-artifacts.com/artifacts?utf8=%E2%9C%93&formats=sf2 some are really cool like this Supersaw Collection

How did your tests go after the sample adjustment? While I think that that's a step forward, I think we should discuss ideas to incorporate loop points in the same script that renders the soundfonts into audio samples!

Appreciate any guidance or suggestions on what you think I should do to help here, I'm super excited about this project and definitely want to use it more!

from smplr.

danigb avatar danigb commented on May 29, 2024

In my initial tests the clicks seem to have disappeared, but I have not had time to test all the instruments.

Regarding your problem, I don't know how much automation you need. In case you don't need to convert many sf2 files it might be better to do it manually.

I have tested https://www.polyphone-soundfonts.com/download to extract the wave files. It works quite well. I've put the wav files into a repository: https://github.com/smpldsnds/supersaw

The next step would be to extract the sf2 information into json or another readable format and then to something smplr can read. I didn't have time to do it, but it seems there are several tools to convert sf2 files to json. I'm very open to PRs if you find one.

Good luck!

from smplr.

this-fifo avatar this-fifo commented on May 29, 2024

Wow, thank you @danigb !

This is really promising, I was able to parse a raw soundfont in the browser and get a nice structure to work with!

I think we could totally use that to convert the soundfont into a format smplr likes, but I'm also curious if we can find a way to just natively incorporate the soundfont without the need to pre-render it into samples ranging from A0 to G7.

I noticed, for example, that package extracts the pure samples from the Soundfont!

image

Here's an example from that Supersaw.sf2, it shows the same data I can see in Polyphone!

image

The sample data is also available at an instrument level, so we could get creative here to support it all the way!

That said, I see two potential things of value:

  1. Take that and figure out how to convert/map into existing json/js structure that smplr likes.
  2. New separate implementation for accepting raw sf2 into smplr, without the need for them to be pre-rendered!

PS: I should say this is also my first time working with soundfonts and things like this so apologies in advance as I am learning as I go🙇‍♂️

from smplr.

this-fifo avatar this-fifo commented on May 29, 2024

I've just found how this is used in another related project, I think there's great inspiration and ideas to take from there:

from smplr.

danigb avatar danigb commented on May 29, 2024

Nice! Block post and Felix work looks great! I'd say the loading a sf2 directly into smplr would be the best option! I'll take a look when I have time

from smplr.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.