Making an instrument - how would I import a soundfont?

I’m trying to make a musical instrument that can play notes identically to how MIDI software would interpret a soundfont (.sf2) file. I’d like for players to be able to prolong notes by holding down a key.

The problem is: ROBLOX does not allow you to import soundfonts directly. The alternative I believe I am left with is to find a way to extract .wav audio from the .sf2 file somehow. All attempts so far have left me with a single pitch note audio file for my instrument that has a clear cut when looped, and doesn’t quite sound right when I try to shift it into a different note with PitchShift effects.

Anyone seen a past implementation that worked, or just have any clever ideas?
Is there a way I can extract multiple pitched loopable audios from soundfonts that will sound good enough in ROBLOX?

image

1 Like

you can just skip to certain times in the audio.

I have one audio file, and it’s just one musical note. How would skipping to certain times change the note?

What I would probably do is use FL Studio and Sforzando or some similar setup, play each note in an octave for that respective instrument, and just import each of those 12 sound bytes into Roblox.

Trying to do it with PitchShiftSoundEffect wouldn’t work because you’d need to have an increase/decrease of 0.09090909 and so on for each note, and we don’t have that kind of numerical precision on Roblox. Additionally, PitchShiftSoundEffect is quite approximate, though it might be okay to use it if you want to use a round number when going down or up an octave. (0.5 or 2.0)

As far as looping goes, to my knowledge nobody has managed to really implement that yet in a “true” fashion because it’s complicated, I think with the newer Audio API and it’s respective instances you might be able to create some kind of Sample-Based Synthesis. But I can’t think of any easy way to do that off the top of my head, and I would say flat out that it isn’t worth it unless music is the core part of your experience/creation.

A possible way to fake it might be to use a long note when recording your samples, a few seconds long, and loop just the end bit of it, at the point where the sound’s volume doesn’t decay anymore. When the player lets go of the note you can fade the volume of the sound quickly so it doesn’t just abruptly stop. The loop should be relatively seamless as long as there’s no reverb or any other effects applied when you’re recording the sound. (Adding effects during playback should be fine, though.)

1 Like

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.