-
Notifications
You must be signed in to change notification settings - Fork 57
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #85 from madderscientist/master
enable midi -> audio (re pull)
- Loading branch information
Showing
2 changed files
with
41 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
import fluidsynth | ||
|
||
|
||
def local_file_path(file_name: str) -> str: | ||
""" | ||
Return a file path to a file that is in the same directory as this file. | ||
""" | ||
from os.path import dirname, join | ||
|
||
return join(dirname(__file__), file_name) | ||
|
||
fs = fluidsynth.Synth() | ||
sfid = fs.sfload(local_file_path("example.sf2")) | ||
fs.midi2audio(local_file_path("1080-c01.mid"), local_file_path("1080-c01.wav")) | ||
# A Synth object can synthesize multiple files. For example: | ||
# fs.midi2audio(local_file_path("1080-c02.mid"), local_file_path("1080-c02.wav")) | ||
# fs.midi2audio(local_file_path("1080-c03.mid"), local_file_path("1080-c03.wav")) | ||
|
||
fs.delete() |