chfin/cl-portmidi

Example of program change?

Opened this issue · 2 comments

Hi, thank you for this library. How would I make a MIDI program change with this library?

I was able to do it with this by copying these functions into my program:

(defun make-message (status data1 data2)
  "=> an integer representing a MIDI message
Combines the integers `status`, `data1` and `data2` to a MIDI message."
  (let ((d2 (boole boole-and (ash data2 16) #xFF0000))
	(d1 (boole boole-and (ash data1 8) #xFF00))
	(st (boole boole-and status #xFF)))
    (boole boole-ior d2
	   (boole boole-ior d1 st))))

(defun make-message* (upper lower data1 data2) ;internal
  "=> a MIDI message as an integer
Works like `make-message` but combines `upper` and `lower` to the status byte."
  (let ((status (boole boole-ior
		       (boole boole-and (ash upper 4) #xF0)
		       (boole boole-and lower #xF))))
    (make-message status data1 data2)))

and then calling

(pm:write-short-midi *midi-out3* 0 (make-message* #0xC 0 (random 10) 0))

I wondered why make-message wasn't exported for use?

Thanks!

chfin commented

Hey, sorry for the late reply. I guess not exporting make-message and make-message* is an oversight on my part. I added them to the export list, so you should be able to use them directly now. Of course, it would be much nicer to have high-level functions for these commands (like note-on and note-off). PRs are welcome!

chfin commented

Leaving this open to indicate that high-level functions are still missing.