Convert SoundFont to .wav files for each note
Asked Answered
F

6

7

Is there a simple way of converting a sound font file to .wav files (or any common music format, really), separate for each note?

So let's say I had a sound font a.sfz; I would like to get out of it a list of files A0.wav, A#0.wav, B0.wav, C1.wav, C#1.wav, etc.

In particular, I want to have a .wav for each note, which seems to me is not something the sound font has by itself (it seems that it only has samples a few notes apart -- I assume software is supposed to alter the pitch of the samples contained in the sound fonts to get the remaining notes' sounds, but I'd like to somehow generate the .wav files for all notes directly, so that I won't need to alter the pitch of the samples in any way).

If there's some software that does this, perfect, please provide a link, but I haven't found any (all those that I found only generate .wav files a few notes apart). If not, how would I go about doing this programmatically?

Foret answered 1/5, 2012 at 3:17 Comment(0)
A
3

Under Linux you can use SWAMI (http://www.swamiproject.org/) to manage the soundfont file (in SF2 format).

Averett answered 2/1, 2015 at 10:2 Comment(2)
Thanks, this worked for me. I tried to extract the .wav samples from the MuseScore SoundFonts. I didn't manage to do it with sf2extract but I could extract all samples via the GUI in SWAMI.Oakes
Glad to know. Maybe you can upvote my answer. ;-)Averett
K
2

On Ubuntu, sf2extract in the gigtools package can extract all the samples from an SF2 file as WAVs.

Kelwunn answered 1/2, 2021 at 16:39 Comment(0)
P
1

Import your sf file into audacity as Import>Raw Data.

You can then export it as an audio file such a wav or mp3

I got some new audio patches that were sf2 and my composition software didn't recognise them. Did an internet search and came up with nothing. So I did this audacity thing and it worked for me. Specifically to what you asked, my file was a trumpet playing a scale of notes. I deleted all notes but the first and exported that single note. I copied the export (wav) into my soundbank folder and was able to compose in different pitches with via one small file. And now... about 30 other instruments to apply this to!

Paperweight answered 16/7, 2016 at 2:32 Comment(0)
E
0

You can write a program to do this. Use the RtAudio library and Fluidsynth to programmatically generate all the pitches that you want to play. When these pitches are generated, write them out as wave files. This program could be reused for any sound font from then on. You can find the libraries by using google.

Esbenshade answered 1/5, 2012 at 5:36 Comment(1)
Almost any question on this site could be answered with "you can write a program to do this".Averett
U
0

I've written a simple tool for this. Node.js is required to be installed.

Instructions for Linux (adapt for other OS):

  1. Create new nodejs module:
    mkdir midigen && cd midigen && npm init -y && npm i --save midi-writer-js
    
  2. Create index.js with the following content:

    const fs = require('fs');
    const MidiWriter = require('midi-writer-js');
    
    for (let octave = 0; octave <= 8; octave++) {
      for (const note of ['C', 'C#', 'D', 'D#', 'E', 'F', 'F#',  'G', 'G#', 'A', 'A#', 'B']) {
        const track = new MidiWriter.Track();
        track.addEvent(new MidiWriter.ProgramChangeEvent({ instrument: 10 }));
        track.addEvent(new MidiWriter.NoteEvent({ pitch: [`${note}${octave}`], duration: '8', velocity: 100 }));
        fs.writeFileSync(`${note}${octave}.mid`, new MidiWriter.Writer(track).buildFile());
      }
    }
    
    
  3. Feel free to modify octave range, instrument type (to match your SoundFont), duration and volume (velocity)
  4. Run node .
  5. Install your SoundFont
  6. Convert generated midi files to wav files:
    for f in *.mid; do timidity $f -Ow -o ${f%.mid}.wav; done
    
Umeko answered 25/9, 2019 at 18:55 Comment(0)
P
0

To convert SF2 Soundfont file into sound sampled Wav files, you can convert SF2 into SFZ files directories thanks Polyphone application. This application will create a SFZ repertory where you can find *.sfz editable text file(s) and a sub-directory containing all the Wav files extracted from the initial SF2 file. You can download the application, whatever is your os, on "https://www.polyphone-soundfonts.com/download". To load SF2 file you click on home left top icon, then click on "Open sound bank" (or something like my menus are in french...) and select your SF2 file to convert. Do a double click on the desired SF2 file (if you've already loaded other SF2 files for example)

Peachey answered 12/11, 2023 at 11:47 Comment(1)
Your answer could be improved with additional supporting information. Please edit to add further details, such as citations or documentation, so that others can confirm that your answer is correct. You can find more information on how to write good answers in the help center.Landscape

© 2022 - 2024 — McMap. All rights reserved.