5

I'm trying to install pyfluidsynth on windows. I used pip install pyfluidsynth in the command prompt, but when I tried to import fluidsynth in my python code I get:

 ModuleNotFoundError: No module named 'FluidSynth'

When I tried to install FluidSynth (by using pip install fluidsynth) another binding package was installed with FluidSynth 0.2 from several years ago.

Can anybody help with specific details on how to install pyfluidsynth on windows and use it?

import FluidSynth

Traceback (most recent call last):
  File "<input>", line 1, in <module>
  File "C:\Program Files\JetBrains\PyCharm 2018.3.2\helpers\pydev\_pydev_bundle\pydev_import_hook.py", line 21, in do_import
    module = self._system_import(name, *args, **kwargs)
ModuleNotFoundError: No module named 'FluidSynth'
4

4 回答 4

2

对于最近的 FluidSynth 版本,似乎没有用于 ms-windows 的预构建二进制文件。(请注意,现在开发是在 github 上完成的;sourceforge 站点已经过时了。)最新的源代码版本在这里

但是 FluidSynth wiki 有在 ms-windows 上构建它的说明。

注意: FluidSynth(更准确地说,它的共享库)是使用pyfluidsynth. 请参阅自述文件

于 2019-01-13T10:32:53.140 回答
1

对我来说,以下工作:

  1. 转到以下链接并下载预编译 (?) 的流体合成 dll。
  2. 将您的流体合成 dll 的目录添加到路径环境变量中。
  3. 在 pyfluidsynth 包中。找到“fluidsynth.py”文件,并编辑它正在寻找库“lib = find_library('fluidsynth')...”的部分以搜索 dll 名称,对于 64 位版本,该名称为“libfluidsynth64”。
  4. 无论出于何种原因(可能是版本不匹配),函数“fluid_synth_set_reverb_full”和“fluid_synth_set_chorus_full”不受支持,因此请从“fluidsynth.py”中注释掉这些行。
  5. 就是这样。保存“fluidsynth.py”启动cmd,进入python,导入fluidsynth。

我还没有测试过fluidsynth 的所有功能,但是使用pretty_midi,我至少能够通过乐器声音字体播放midi。

希望这可以帮助!

于 2019-10-30T03:31:48.357 回答
0

在 Windows 上安装流体合成器

从 github 下载流体合成二进制文件:https ://github.com/FluidSynth/fluidsynth/releases

将提取的 zip 文件的 bin 添加到路径中:例如:C:\Users*您的用户名在此处**** 您提取的 zip 的路径 ***\fluidsynth-2.1.6-win10-x64\bin

下载流体合成python库:python流体合成的存储库是: https ://github.com/nwhitehead/pyfluidsynth 。 https://github.com/nwhitehead/pyfluidsynth/archive/master.zip

解压后,必须安装:

python setup.py install

解压出来的master.zip有fluidsynth.py这个python文件是要“导入”到python代码中的文件。在 test 文件夹中,它有安装测试中使用的 example.sf2:这两个文件的路径需要设置为您自己的位置。

import time
import fluidsynth

fs = fluidsynth.Synth()
fs.start()

sfid = fs.sfload("example.sf2")
fs.program_select(0, sfid, 0, 0)

fs.noteon(0, 60, 30)
fs.noteon(0, 67, 30)
fs.noteon(0, 76, 30)

time.sleep(1.0)

fs.noteoff(0, 60)
fs.noteoff(0, 67)
fs.noteoff(0, 76)

time.sleep(1.0)

fs.delete()

上面的 python 代码示例播放一个音符。让它工作确认一切正常。

于 2021-01-11T11:55:55.697 回答
0

对我来说,下一个作品:

  1. 称呼pip install --upgrade pyfluidsynth
  2. 从以下网址下载预编译的 DLL:https ://zdoom.org/downloads#Support
  3. 如果您使用 64x 版本将文件重命名libfluidsynth64.dlllibfluidsynth.dll
  4. 将其放入C:\Windows\System32
于 2021-10-23T12:27:29.427 回答