README_CL.txt (3568B)
1 README_CL.txt for PortMidi 2 Roger B. Dannenberg 3 17 Jan 2007 4 5 This is a Common Lisp interface to PortMidi. 6 7 On Mac OSX, you need to build PortMidi as a dynamic link library 8 before you can use PortMidi from Common Lisp. 9 10 You can build PortMidi as a dynamic link library by running this: 11 12 cd portmidi 13 make -F pm_mac/Makefile.osx install-with-xcode 14 15 This is just a shortcut for: 16 17 cd portmidi/pm_mac 18 sudo xcodebuild -project pm_mac.xcodeproj -configuration Deployment install DSTROOT=/ 19 20 You can check the file and the architecture for which it is built using: 21 file /usr/local/lib/libportmidi.dylib 22 23 If you've done this install of portmidi, then you should also have 24 /usr/local/include/portmidi.h 25 This will be necessary to successfully build the cffi interface below. 26 27 To test PortMidi with Common Lisp, I (RBD) am using SBCL, which I 28 downloaded from http://prdownloads.sourceforge.net/sbcl. Currently, I use 29 sbcl-0.9.17-x86-darwin-binary.tar.bz2 30 To install this, I unpacked it by just double-clicking in the finder. Then, 31 from a command window, I became root using "sudo sh", and then typed: 32 # INSTALL_ROOT=/usr/local 33 # sh install.sh 34 # exit 35 36 I also downloaded cffi-061012.tar.gz from 37 http://common-lisp.net/project/cffi/tarballs/?M=D 38 39 To compile cffi, use the following, where "/Lisp/cffi/" is replaced by 40 the actual directory of cffi, e.g. 41 "/Users/rbd/sbcl-0.9.17-x86-darwin/cffi-061012": 42 43 % sbcl 44 * (require 'asdf) 45 * (push "/Lisp/cffi/" asdf:*central-registry*) 46 * (asdf:oos 'asdf:load-op :cffi) 47 * (quit) 48 49 Download Common Music's portmidi module from cvs and build the c side: 50 (Replace "/Lisp" with your lisp directory, e.g. 51 "/Users/rbd/sbcl-0.9.17-x86-darwin". These cvs commands will create 52 a new directory, portmidi.) 53 54 % cd /Lisp 55 % export CVSROOT=:pserver:anonymous@commonmusic.cvs.sourceforge.net:/cvsroot/commonmusic 56 % cvs login # press Return at password prompt 57 % cvs checkout portmidi 58 % cd portmidi 59 % ./configure 60 % make 61 % cd .. 62 63 Now compile/load the portmidi module just like cffi. Again, change 64 "/Lisp/cffi/" and "/Lisp/portmidi" to correspond to your local file system. 65 (Note that /Lisp becomes your lisp directory, and "cffi" becomes your 66 cffi folder name, e.g. "cffi-061012". 67 68 % sbcl 69 * (require 'asdf) 70 * (push "/Lisp/cffi/" asdf:*central-registry*) 71 * (asdf:oos 'asdf:load-op :cffi) 72 * (push "/Lisp/portmidi/" asdf:*central-registry*) 73 * (asdf:oos 'asdf:load-op :portmidi) 74 75 Look in the file /Lisp/portmidi/test.lisp for a test of the lisp interface to 76 portmidi. For example, while still running sbcl: 77 78 * (pm:portmidi) ; initialize portmidi 79 * (pt:start) ; start time 80 * (pt:time) ; get time 81 * (pprint (pm:GetDeviceInfo)) ; get list of devices 82 ((:ID 0 :NAME "IAC Driver Bus 1" :TYPE :INPUT :OPEN NIL) 83 (:ID 1 :NAME "IAC Driver Bus 1" :TYPE :OUTPUT :OPEN NIL)) 84 85 Notice that test.lisp assumes MIDI input devices are connected 86 and uses some hard-wired device numbers, so it may not run 87 as is without error. 88 89 Since test.lisp uses some Common Music calls, I (RBD) wrote a 90 simpler test, test-no-cm.lisp, which is in the same folder as 91 this (README_CL.txt) file. To use it, first check that the 92 values for outid (4) and inid (1) actually match PortMidi device 93 id's for output and input devices, and make sure the input 94 device is a keyboard that can generate a middle-C -- otherwise 95 the program will hang waiting for input. Run sbcl from this 96 pm_cl folder, and type: 97 98 (load "test-no-cm.lisp") 99 100 The program pauses frequently by calling (READ), so you 101 should type t or something, then <RETURN> to continue. 102 103 104 (Thanks to Leigh Smith and Rick Taube)