制作 midi:midifile 的实例
我正在为我正在进行的一个小项目使用 Lisp MIDI 库。首先,我尝试编写一个简单的 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。
谁能告诉我我在这里做错了什么?
I'm using a Lisp MIDI library for a small project I'm working on. Just to get started, I'm trying to write a simple MIDI file that plays middle C. However I can't seem to get this to work and can not find any documentation on how to do this sort of thing. Here is my code:
(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")))
It is creating a MIDI file but one of 0 seconds duration, which does not seem to have a middle C playing in it.
Can anyone tell me what I'm doing wrong here?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
David Lewis,该库的维护者之一,向我解释了我做错了什么。这是正确的代码:
David Lewis, one of the maintainers of the library, explained to me what I was doing wrong. Here is the correct code: