2017年3月18日土曜日

How to get 東方BGM on VGS music data as MP3

describe how to make 東方VGS's MP3 file in Mac or Linux (terminal).

pre-requests

- git
- gcc (using xcode in Mac)
- gnu-make

step 1: make MML compiler (vgs2mml)

cd ~
git clone https://github.com/suzukiplan/vgs-mml-compiler.git
cd vgs-mml-compiler
git submodule init
git submodule update
make
./vgs2mml

step 2: make BGM decoder

cd ~/vgs-mml-compiler/example
make
./decoder

step 3: get 東方VGS MML data

cd ~
git clone https://github.com/suzukiplan/Touhou-VGS-MML-data.git

step 4: Make wav file from MML

cd ~/Touhou-VGS-MML-data/data
~/vgs-mml-compiler/vgs2mml BSLOT000.mml BSLOT000.bgm
~/vgs-mml-compiler/example/decoder BSLOT000.bgm BSLOT000.wav

step 5: use MP3 encoder

brew install lame
lame BSLOT000.wav

extra step: how to modify playing options

edit source code, and try step 2 again.
vi ~/vgs-mml-compiler/example/decoder.c

ex) Modify loop count

edit here.

loop 1 time (original) 
while (vgsdec_get_value(context, VGSDEC_REG_PLAYING) && vgsdec_get_value(context, VGSDEC_REG_LOOP_COUNT) == 0) {

loop 2 times
while (vgsdec_get_value(context, VGSDEC_REG_PLAYING) && vgsdec_get_value(context, VGSDEC_REG_LOOP_COUNT) < 2) {

ex) Disable KOBUSHI:

comment out or delete here.