動かざることバグの如し

近づきたいよ 君の理想に

MacでMIDIファイルをコマンドから再生する

Macで落としてきたMIDIをその場で再生したかった

環境

MaxでMIDIが再生できない件

昔はIEで再生できてたMIDIChromeで再生できないのは当然のごとく、VLCとか主要な動画プレイヤーでも再生できない。。。

あのポンコツガラケーですら再生できるというのに

で、環境をなるべく汚さず、手っ取り早く再生できる方法が探した結果、timidityが一番良かった

インストール

コマンド一発

brew install timidity

再生

timidity 再生したいファイル.mid

helpだすと結構な量のオプションが出てくるw が、基本何もつけなくても再生されるはず

TiMidity++ version 2.15.0 (C) 1999-2018 Masanao Izumo <iz@onicos.co.jp>
The original version (C) 1995 Tuukka Toivonen <tt@cgs.fi>
TiMidity is free software and comes with ABSOLUTELY NO WARRANTY.

Usage:
  timidity [options] filename [...]

  Use "-" as filename to read a MIDI file from stdin

Options:
  -A n,m     --volume=n, --drum-power=m
               Amplify volume by n percent (may cause clipping),
                 and amplify drum power by m percent
     (a)     --[no-]volume-compensation
               Toggle amplify compensation (disabled by default)
  -a         --[no-]anti-alias
               Enable the anti-aliasing filter
  -B n,m     --buffer-fragments=n,m
               Set number of buffer fragments(n), and buffer size(2^m)
  -C n       --control-ratio=n
               Set ratio of sampling and control frequencies
  -c file    --config-file=file
               Read extra configuration file
  -D n       --drum-channel=n
               Play drums on channel n
  -E mode    --ext=mode
               TiMidity sequencer extensional modes:
                 mode = w/W : Enable/Disable Modulation wheel
                        p/P : Enable/Disable Portamento
                        v/V : Enable/Disable NRPN Vibrato
                        s/S : Enable/Disable Channel pressure
                        e/E : Enable/Disable Modulation Envelope
                        t/T : Enable/Disable Trace Text Meta Event at playing
                        o/O : Enable/Disable Overlapped voice
                        z/Z : Enable/Disable Temperament control
                        m<HH>: Define default Manufacture ID <HH> in two hex
                        M<HH>: Define system Manufacture ID <HH> in two hex
                        b<n>: Use tone bank <n> as the default
                        B<n>: Always use tone bank <n>
                        i<n/m>: Use program <n> on channel <m> as the default
                        I<n/m>: Always use program <n> on channel <m>
                        F<args>: For effect.  See below for effect options
                   default: -E wpvSEToz
  -F         --[no-]fast-panning
               Disable/Enable fast panning (toggle on/off, default is on)
  -f         --[no-]fast-decay
               Enable fast decay mode (toggle)
  -G <begin>-<end>[,<begin2>-<end2>,...](m)
  --segment=<begin>-<end>[,<begin2>-<end2>,...](m)
               Play just sub-segment(s), comma separated segments
                 Each segment is dash separated of two time values of:
                 <begin>-<end> - defaulted to 0-infinity
                 Playing from <begin> to <end>
                 Time format: [<minutes>:]<seconds>[.<milliseconds>]
                 'm' stands for using measure and beat instead of secs
                 Time format: <measure>[.<beat>] (one-origin)
  -H n       --force-keysig=n
               Force keysig number of sHarp(+)/flat(-) (-7..7)
  -h         --help
               Display this help message
  -i mode    --interface=mode
               Select user interface (see below for list)
  -j         --[no-]realtime-load
               Realtime load instrument (toggle on/off)
  -K n       --adjust-key=n
               Adjust key by n half tone (-24..24)
  -k msec    --voice-queue=msec
               Specify audio queue time limit to reduce voice
  -L path    --patch-path=path
               Append dir to search path
  -M name    --pcm-file=name
               Specify PCM filename (*.wav or *.aiff) to be played or:
                 "auto" : Play *.mid.wav or *.mid.aiff
                 "none" : Disable this feature (default)
  -m msec    --decay-time=msec
               Minimum time for a full volume sustained note to decay,
                 0 disables
  -N n       --interpolation=n
               Set the interpolation parameter (depends on -EFresamp option)
                 Linear interpolation is used if audio queue < 99%%
                 cspline, lagrange:
                   Toggle 4-point interpolation (default on)
                 newton:
                   n'th order Newton polynomial interpolation, n=1-57 odd
                 gauss:
                   n+1 point Gauss-like interpolation, n=1-34 (default 25)
  -O mode    --output-mode=mode
               Select output mode and format (see below for list)
             --flac-verify (for Ogg FLAC only)
               Verify a correct encoding
             --flac-padding=n (for Ogg FLAC only)
               Write a PADDING block of length n
             --flac-complevel=n (for Ogg FLAC only)
               Set compression level n:[0..8]
             --speex-quality=n (for Ogg Speex only)
               Encoding quality n:[0..10]
             --speex-vbr (for Ogg Speex only)
               Enable variable bit-rate (VBR)
             --speex-abr=n (for Ogg Speex only)
               Enable average bit-rate (ABR) at rate bps
             --speex-vad (for Ogg Speex only)
               Enable voice activity detection (VAD)
             --speex-dtx (for Ogg Speex only)
               Enable file-based discontinuous transmission (DTX)
             --speex-complexity=n (for Ogg Speex only)
               Set encoding complexity n:[0-10]
             --speex-nframes=n (for Ogg Speex only)
               Number of frames per Ogg packet n:[0-10]
  -o file    --output-file=file
               Output to another file (or device/server) (Use "-" for stdout)
  -P file    --patch-file=file
               Use patch file for all programs
  -p n       --polyphony=n
               Allow n-voice polyphony.  Optional auto polyphony reduction
     (a)     --[no-]polyphony-reduction
               Toggle automatic polyphony reduction.  Enabled by default
  -Q n[,...] --mute=n[,...]
               Ignore channel n (0: ignore all, -n: resume channel n)
     (t)     --temper-mute=n[,...]
               Quiet temperament type n (0..3: preset, 4..7: user-defined)
             --preserve-silence
               Do not drop initial silence.  Default: drop initial silence
  -q sec/n   --audio-buffer=sec/n
               Specify audio buffer in seconds
                 sec: Maxmum buffer, n: Filled to start (default is 5.0/100%%)
                 (size of 100%% equals device buffer size)
  -R msec      Pseudo reveb effect (set every instrument's release to msec)
                 if n=0, n is set to 800
  -S n       --cache-size=n
               Cache size (0 means no cache)
  -s freq    --sampling-freq=freq
               Set sampling frequency to freq (Hz or kHz)
  -T n       --adjust-tempo=n
               Adjust tempo to n%%,
                 120=play MOD files with an NTSC Amiga's timing
  -t code    --output-charset=code
               Output text language code:
                 code=auto  : Auto conversion by `LANG' environment variable
                              (UNIX only)
                      ascii : Convert unreadable characters to '.' (0x2e)
                      nocnv : No conversion
                      1251  : Convert from windows-1251 to koi8-r
                      euc   : EUC-japan
                      jis   : JIS
                      sjis  : shift JIS
  -U         --[no-]unload-instruments
               Unload instruments from memory between MIDI files
  -V power   --volume-curve=power
               Define the velocity/volume/expression curve
                 amp = vol^power (auto: 0, linear: 1, ideal: ~1.661, GS: ~2)
  -v         --version
               Display TiMidity version information
  -W mode    --wrd=mode
               Select WRD interface (see below for list)
  -x str     --config-string=str
               Read configuration str from command line argument
  -Z file    --freq-table=file
               Load frequency table (Use "pure" for pure intonation)
  pure<n>(m) --pure-intonation=n(m)
               Initial keysig number <n> of sharp(+)/flat(-) (-7..7)
                 'm' stands for minor mode
  --module=n
               Simulate behavior of specific synthesizer module by n
                 n=0       : TiMidity++ Default (default)
                   1-15    : GS family
                   16-31   : XG family
                   32-111  : SoundBlaster and other systhesizer modules
                   112-127 : TiMidity++ specification purposes

Effect options (-EF, --ext=F option):
  -EFdelay=d   Disable delay effect (default)
  -EFdelay=l   Enable Left delay
    [,msec]      `msec' is optional to specify left-right delay time
  -EFdelay=r   Enable Right delay
    [,msec]      `msec' is optional to specify left-right delay time
  -EFdelay=b   Enable rotate Both left and right
    [,msec]      `msec' is optional to specify left-right delay time
  -EFchorus=d  Disable MIDI chorus effect control
  -EFchorus=n  Enable Normal MIDI chorus effect control
    [,level]     `level' is optional to specify chorus level [0..127]
                 (default)
  -EFchorus=s  Surround sound, chorus detuned to a lesser degree
    [,level]     `level' is optional to specify chorus level [0..127]
  -EFreverb=d  Disable MIDI reverb effect control
  -EFreverb=n  Enable Normal MIDI reverb effect control
    [,level]     `level' is optional to specify reverb level [1..127]
  -EFreverb=g  Global reverb effect
    [,level]     `level' is optional to specify reverb level [1..127]
  -EFreverb=f  Enable Freeverb MIDI reverb effect control (default)
    [,level]     `level' is optional to specify reverb level [1..127]
  -EFreverb=G  Global Freeverb effect
    [,level]     `level' is optional to specify reverb level [1..127]
  -EFvlpf=d    Disable voice LPF
  -EFvlpf=c    Enable Chamberlin resonant LPF (12dB/oct) (default)
  -EFvlpf=m    Enable Moog resonant lowpass VCF (24dB/oct)
  -EFns=n      Enable the n th degree (type) noise shaping filter
                 n:[0..4] (for 8-bit linear encoding, default is 4)
                 n:[0..4] (for 16-bit linear encoding, default is 4)
  -EFresamp=d  Disable resamplation
  -EFresamp=l  Enable Linear resample algorithm
  -EFresamp=c  Enable C-spline resample algorithm
  -EFresamp=L  Enable Lagrange resample algorithm
  -EFresamp=n  Enable Newton resample algorithm
  -EFresamp=g  Enable Gauss-like resample algorithm (default)
                 -EFresamp affects the behavior of -N option

Alternative TiMidity sequencer extensional mode long options:
  --[no-]mod-wheel
  --[no-]portamento
  --[no-]vibrato
  --[no-]ch-pressure
  --[no-]mod-envelope
  --[no-]trace-text-meta
  --[no-]overlap-voice
  --[no-]temper-control
  --default-mid=<HH>
  --system-mid=<HH>
  --default-bank=n
  --force-bank=n
  --default-program=n/m
  --force-program=n/m
  --delay=(d|l|r|b)[,msec]
  --chorus=(d|n|s)[,level]
  --reverb=(d|n|g|f|G)[,level]
  --voice-lpf=(d|c|m)
  --noise-shaping=n
  --resample=(d|l|c|L|n|g)

Available interfaces (-i, --interface option):
  -id          dumb interface

Interface options (append to -i? option):
  `v'          more verbose (cumulative)
  `q'          quieter (cumulative)
  `t'          trace playing
  `l'          loop playing (some interface ignore this option)
  `r'          randomize file list arguments before playing
  `s'          sorting file list arguments before playing

Alternative interface long options:
  --verbose=n
  --quiet=n
  --[no-]trace
  --[no-]loop
  --[no-]random
  --[no-]sort

Available output modes (-O, --output-mode option):
  -OO          Libao mode
  -Od          Mac OS X pcm device
  -Ow          RIFF WAVE file
  -Or          Raw waveform data
  -Ou          Sun audio file
  -Oa          AIFF file
  -Ov          Ogg Vorbis
  -OF          FLAC
  -OS          Ogg Speex
  -Ol          List MIDI event
  -Om          Write MIDI file
  -OM          MOD -> MIDI file conversion

Output format options (append to -O? option):
  `S'          stereo
  `M'          monophonic
  `s'          signed output
  `u'          unsigned output
  `1'          16-bit sample width
  `2'          24-bit sample width
  `8'          8-bit sample width
  `l'          linear encoding
  `U'          U-Law encoding
  `A'          A-Law encoding
  `x'          byte-swapped output

Alternative output format long options:
  --output-stereo
  --output-mono
  --output-signed
  --output-unsigned
  --output-16bit
  --output-24bit
  --output-8bit
  --output-linear
  --output-ulaw
  --output-alaw
  --[no-]output-swab

Available WRD interfaces (-W, --wrd option):
  -Wt          TTY WRD tracer
  -Wd          dumb WRD tracer
  -W-          No WRD trace

いや、今でもメンテナンスされているの大変助かるわ