Lisp 制作midi:midifile的实例

Lisp 制作midi:midifile的实例,lisp,common-lisp,midi,Lisp,Common Lisp,Midi,我正在为一个我正在做的小项目使用。刚开始,我正试图编写一个简单的MIDI文件,播放中间的C。然而,我似乎无法让它工作,也找不到任何关于如何做这类事情的文档。这是我的密码: (defun make-track () (list (make-instance 'midi:note-on-message :time 0 :key 60 :velocity 100 :status 0) (make-ins

我正在为一个我正在做的小项目使用。刚开始,我正试图编写一个简单的MIDI文件,播放中间的C。然而,我似乎无法让它工作,也找不到任何关于如何做这类事情的文档。这是我的密码:

(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


有人能告诉我我做错了什么吗?

的维护者之一David Lewis向我解释了我做错了什么。以下是正确的代码:

(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)))