我来使用mingus试图在
python中重现一些音符.基于
answered here,我尝试过:
from mingus.midi import fluidsynth
fluidsynth.init('/home/btc/Escritorio/SinestesiaRCB/gfx/ViolinsLong.sf2',"alsa")
fluidsynth.play_Note(64,0,100)
#Also tried with Note("C-5") and so forth
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: No preset found on channel 9 [bank=128 prog=0]
For General MIDI compatibility, the default sound font instrument
assignments are bank 0, program 0 (“Acoustic Grand Piano”) for
channels 0–8 and 10–15, and bank 128, program 0 (“Default Drum Set”)
for channel 9. Apparently, your sound font does not have the latter.
This does not matter if your MIDI file does not assume General MIDI
compatible instruments and does not try to play drum sounds on channel
9.
但除此之外,这可能会让事情变得更加清晰,我仍然不知道如何解决它.
另外,如果我使用same file作为第一个链接的答案,那么我得到的错误是这个(并且不知道如何解决它):
fluidsynth: warning: Failed to set thread to high priority
fluidsynth: warning: Failed to pin the sample data to RAM; swapping is possible.
更新
使用sudo权限运行程序会删除此错误,但它不会发出声音.这样,我得到的错误是:
QStandardPaths: XDG_RUNTIME_DIR not set, defaulting to ‘/tmp/runtime-root’
我认为在fluidynth驱动程序中选择的驱动程序模式可能存在问题,但我已尝试使用相同的结果(alsa,oss等).为了完整起见,我在VM中运行它,其中的其他声音在我的主机扬声器中正确再现.
但是基于this answer,我想它应该通过传递给它正确的声音环境变量来解决.我不知道.我尝试过:
pkexec env DISPLAY=$DISPLAY XAUTHORITY=$XAUTHORITY python3 /home/btc/Escritorio/SinestesiaRCB/SinestesiaRCB.py
需要文件的完整路径,因为这需要sudo权限并更改其工作目录,最后出现相同的错误:XDG_RUNTIME_DIR.
更新2
如果我使用sudo -E选项运行它,错误将替换为新错误:
QStandardPaths: wrong ownership on runtime directory /run/user/1000, 1000 instead of 0
我正在阅读in some webs,1000用户应该是默认用户而不是root用户.
因此,我做了一个:
sudo chown root:root /run/user/1000
只是尝试,然后应用程序运行没有失败,但它仍然没有响.
更新3
基于this example和this Q&A,我已经尝试了两次使用时间睡眠,并且在播放play_note之后(也在之前)使用raw_input,但它仍然没有发出声音.