From 74888d80749387f400f343b39973a6c6964382b1 Mon Sep 17 00:00:00 2001 From: Duncan McGreggor Date: Fri, 20 Sep 2024 22:13:47 -0500 Subject: [PATCH] More flexible high-level API for note playing. --- src/undermidi.lfe | 31 +++++++++++++++++++++++-------- 1 file changed, 23 insertions(+), 8 deletions(-) diff --git a/src/undermidi.lfe b/src/undermidi.lfe index a731937..4c15d17 100644 --- a/src/undermidi.lfe +++ b/src/undermidi.lfe @@ -52,17 +52,32 @@ ;; Notes API -(defun play-note (pid note) - (undermidi.device.conn:apply pid 'um.note 'play-note (list (um.note:make note)))) +(defun play-note + ((pid note) (when (is_atom note)) + (play-note pid (um.note:make note))) + ((pid note) + (undermidi.device.conn:apply pid 'um.note 'play-note (list note)))) -(defun play-notes (pid notes) - (undermidi.device.conn:apply pid 'um.note 'play-notes (list (um.note:make notes)))) +(defun play-notes + ((pid (= `(,head . ,_) notes)) (when (is_atom head)) + (play-notes pid (um.note:make notes))) + ((pid notes) + (undermidi.device.conn:apply pid 'um.note 'play-notes (list notes)))) -(defun play-notes (pid notes delay) - (undermidi.device.conn:apply pid 'um.note 'play-notes (list (um.note:make notes) delay))) +(defun play-notes + ((pid (= `(,head . ,_) notes) delay) (when (is_atom head)) + (play-notes pid (um.note:make notes) delay)) + ((pid notes delay) + (undermidi.device.conn:apply pid 'um.note 'play-notes (list notes delay)))) -(defun play-notes (pid notes delay repeats) - (undermidi.device.conn:apply pid 'um.note 'play-notes (list (um.note:make notes) delay repeats))) +(defun play-notes + ((pid (= `(,head . ,_) notes) delay repeats) (when (is_atom head)) + (play-notes pid (um.note:make notes) delay repeats)) + ((pid notes delay repeats) + (undermidi.device.conn:apply pid + 'um.note + 'play-notes + (list notes delay repeats)))) ;;; Aliases