Batocera 4.1 新增 Fluidsynth MIDI音樂支援

為何需要 Fluidsynth MIDI 音樂

Batocera 為何要設定 MIDI 。因為部份 PC9801 / x68000 的遊戲有些支援 GM MIDI ,如當時有許多著名的遊戲(像是《東方Project》初期作、Falcom 的 RPG 等,Konami 的 惡魔城 )。這些遊戲常常使用 MIDI 音樂或依賴外部音源(如 Roland MT-32、SC-55、GM MIDI )。這時 Fluidsynth 就上場了!它可以讀取高品質 SoundFont(例如模仿 SC-55/SC-88 的音源),讓你聽到接近原始音效的音樂。

按裝 Fluidsynth Service 檔

由於 Batocera 在 4.1 的版本有 Fluidsynth 的主程式,也有 1 個 FluidR3_GM.sf2 缺的只是 1 個 service 檔。這裡使用 service 有 1 個主要是目地是因為它可以被 Emulationstation 的介面上控制是否可自動啟動或關閉,甚至重新啟動等。這會比 hard-code 在程式裡有較多彈性

1:首先 SSH 進你的 Batocera 主機
2:執行
mkdir -p /userdata/system/services
3:vi /userdata/system/services/fluidsynthService
把下方的程式碼貼上 。貼完按 :wq 寫入並退出 vi

#!/bin/bash
###
### Batocera.PLUS
### Alexandre Freire dos Santos
### Start/Stop FluidSynth as a server process
###

function startFluidsynth()
{
    if ! [ -e '/dev/snd/seq' ]
    then
        modprobe snd_seq

        if ! [ -e '/dev/snd/seq' ]
        then
            return 1
        fi
    fi

    fluidsynth --midi-driver  alsa_seq \
               --audio-driver alsa \
               --no-shell \
               --server \
               --quiet \
               /usr/share/soundfonts/FluidR3_GM.sf2 \
               > /dev/null 2>&1
}


function stopFluidsynth()
{
    if [ "$(pidof -s fluidsynth)" ]
    then
        killall -15 fluidsynth > /dev/null 2>&1
    fi

    if lsmod | grep -qE '^[ ]*snd_seq[ ]'
    then
        modprobe -r snd_seq
    fi
}

function restartFluidsynth()
{
    startFluidsynth
    sleep 0.5
    stopFluidsynth
}

case  in
    start)
        startFluidsynth &
        ;;
    stop)
        stopFluidsynth
        ;;
    restart)
        restartFluidsynth
        ;;
    *)
        echo "usage: $(basename "
#!/bin/bash
###
### Batocera.PLUS
### Alexandre Freire dos Santos
### Start/Stop FluidSynth as a server process
###
function startFluidsynth()
{
if ! [ -e '/dev/snd/seq' ]
then
modprobe snd_seq
if ! [ -e '/dev/snd/seq' ]
then
return 1
fi
fi
fluidsynth --midi-driver  alsa_seq \
--audio-driver alsa \
--no-shell \
--server \
--quiet \
/usr/share/soundfonts/FluidR3_GM.sf2 \
> /dev/null 2>&1
}
function stopFluidsynth()
{
if [ "$(pidof -s fluidsynth)" ]
then
killall -15 fluidsynth > /dev/null 2>&1
fi
if lsmod | grep -qE '^[ ]*snd_seq[ ]'
then
modprobe -r snd_seq
fi
}
function restartFluidsynth()
{
startFluidsynth
sleep 0.5
stopFluidsynth
}
case ${1} in
start)
startFluidsynth &
;;
stop)
stopFluidsynth
;;
restart)
restartFluidsynth
;;
*)
echo "usage: $(basename "${0}") start | stop | restart"
exit 1 
esac
exit 0
") start | stop | restart" exit 1 esac exit 0

4: 執行 chmod 755 /userdata/system/services/fluidsynthService

5:在 Emulationstation 的介面上執行重開機。

6: 在 Emulationstation 的 MAIN MENU → SYSTEM SETTINGS → SERVICES. 你就會看到 fluidsynthService 的按鈕。1 個是啟用,1 個是關閉。依自已本身的需求選擇。

Batocera system settings

測試

選擇 1 個有支援 GM MIDI 的遊戲,在 1 開始跑記憶體檢測時把開 Retroarch 的 Menu. 選擇設定->audio->midi->output 按左或右選擇你的 output device ,通常有 Synth 字串的那個就是。之後我是建議把 config 存檔。這樣才不會每次都要設定。

batocera Midi

延伸閱讀

blog.ocam.live
blog.ocam.live

關注科技新聞、SEO、人工智慧、電玩模擬器、程式設言、與 IT 日常等議題,深入簡出文章的說明並持續追蹤相關新聞的發展與報導。