Comments (9)
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.
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.
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.
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.
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)
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)
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.
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.
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!
Here's an example from that
Supersaw.sf2
, it shows the same data I can see in Polyphone!
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:
- Take that and figure out how to convert/map into existing json/js structure that
smplr
likes. - 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.
I've just found how this is used in another related project, I think there's great inspiration and ideas to take from there:
- https://github.com/felixroos/sfumato/blob/main/src/index.ts
- https://loophole-letters.vercel.app/soundfonts (blog post from the author explaining how he did it)
from smplr.
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)
- When scheduling large number of notes, no sounds is being output HOT 14
- Error: "Relative module specifiers must start with “./”, “../” or “/”.`" HOT 1
- Outdated Documentation HOT 1
- onEnded has stopped working with version 0.10 HOT 2
- Playing notes does extra logging in the console HOT 2
- setVolume and reverb effect no longer working. HOT 4
- Version 0.11.0 - onStart does not fire when added to player.start({}) HOT 3
- Store the SoundFont objects in a list, and cannot reference them
- ElectricPiano.start fails silently without velocity parameter
- Support for using standarized-audio-context HOT 8
- Feature change not included in recent package published HOT 1
- TX81Z from ElectricPiano 404 HOT 3
- loading mp3 file HOT 1
- Non-integer note values do not work with Soundfont class HOT 4
- Playing back mp3 in Buffer - onEnded doesn't fire HOT 2
- Drum Machine: Roland missing ogg files, sampleNames issue with MFB-512 HOT 4
- Providing frequency for playback instead of notename/noteNumber HOT 5
- Error while importing Soundfont HOT 2
- Doesn't work (no sound) in mobile Safari and Chrome HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from smplr.