我正在使用Lisp MIDI library来处理我正在进行的小型项目。刚开始,我正在尝试编写一个播放中间C的简单MIDI文件。但是我似乎无法使其工作,也无法找到有关如何执行此类操作的任何文档。这是我的代码:
(defun make-track ()
(list
(make-instance 'midi:note-on-message
:time 0
:key 60
:velocity 100
:status 0)
(make-instance 'midi:note-off-message
:time 128
:key 60 :velocity 100
:status 0)))
(defun make-tracks ()
(list (make-track)))
(defun try-to-write-midi-file ()
(let* ((my-midi-file (make-instance 'midi:midifile
:format 1
:tracks (make-tracks)
:division 25)))
(midi:write-midi-file my-midi-file "opus.mid")))
正在创建一个MIDI文件,但持续时间为0秒,其中似乎没有中间的C播放。
谁能告诉我这里我做错了什么?
答案 0 :(得分:4)
(defun make-track ()
(list
;; The STATUS values you give to your messages gives the sequencer channel
;; information but, rather than taking the channel as you'd expect to see it
;; (i.e. an integer between 0-15), it takes it in the form the MIDI itself
;; uses, which for NOTE-ON is (+ 144 channel) and for NOTE-OFF is
;; (+ 128 channel).
(make-instance 'midi:note-on-message
:time 0
:key 60
:velocity 100
:status 144)
(make-instance 'midi:note-off-message
:time 128
:key 60 :velocity 100
:status 128)))