[CM] problems with common music 'process' and common lisp package system

hans j.schatzer at tin.it
Fri Mar 30 07:34:40 PDT 2012


Heinrich Taube <taube at ...> writes:

> 
> as long you can actually run the up-process inside SOME package into  
> which cm was loaded then i think this would have to be a pacakge  
> inheritance issue. if thats the case im going to guess that all the  
> process symbols (such as 'for' 'do' etc) need to be imported from  
> whatever package the process macro is defined in to whatever package  
> you import into.
> 
> but if up-process doesnt work from within the the original cm package  
> then there is must be som actual issue in the code and you will have  
> to send a back trace. but it looks like a macro expansion issue....
> 
> On Mar 29, 2012, at 11:17 AM, hans wrote:
> 
> > I can play these 2 functions - with loop and process, if they are
> > locally defined.
> >
> > (defun up-loop ()
> >  (loop for key from 60 to 72
> >        for beg from 0 by .1
> >        collect (make-instance 'midi :time beg
> >                     :keynum key
> >                     :duration 1)))
> >
> > (events (up-loop) "myscore.mid")
> >
> > (defun up-process ()
> >  (process for key from 60 to 72
> >        for beg from 0 by .1
> >        output (make-instance 'midi :time beg
> >                     :keynum key
> >                     :duration 1)))
> >
> > (events (up-process) "myscore.mid")
> >
> >
> > When I define the functions in a package, say automatic-jazz,
> > and import/load them with quicklisp (ql:quickload :automatic-jazz)
> >
> > (events (automatic-jazz:up-loop) "myscore.mid")
> > loads and runs o.k.
> >
> > But loading up-process
> >
> > gives errors like:
> > LOOP ERROR: Found 'FOR' where operator expected.
> > ERROR: (in macroexpansion of (PROCESS FOR I ...))
> > illegal loop syntax
> >
> > thanks for any advice or help
> > Hans
> >
> > _______________________________________________
> > Cmdist mailing list
> > Cmdist at ...
> > http://ccrma-mail.stanford.edu/mailman/listinfo/cmdist
> 


I am trying to create a test case to show the problem:

;1) load common music

;2) this second part runs o.k.
(cm)

(defun up-loop ()
  (loop for key from 60 to 72
        for beg from 0 by .1
        collect (make-instance 'midi :time beg :keynum key :duration 1)))

(events (up-loop) "myscore.mid")

(defun up-process ()
  (process for key from 60 to 72
           for beg from 0 by .1
           output (make-instance 'midi :time beg :keynum key :duration 1)))

(events (up-process) "myscore.mid")


;3) creating a package

*package*  ; #<PACKAGE "CM">

(defpackage #:automatic-jazz
  (:use #:cl #:cm)
  (:export #:up-loop #:up-process))

(in-package :automatic-jazz)

; o.k.
(defun up-loop ()
  (loop for key from 60 to 72
        for beg from 0 by .1
        collect (make-instance 'midi :time beg :keynum key :duration 1)))

; gives following error
(defun up-process ()
  (process for key from 60 to 72
           for beg from 0 by .1
           output (make-instance 'midi :time beg :keynum key :duration 1)))

LOOP ERROR: Found 'FOR' where operator expected.
clause context: 'FOR KEY FROM 60 TO 72 FOR BEG FROM 0 BY 0.1'
 in: LAMBDA NIL
     (CM:PROCESS
       AUTOMATIC-JAZZ::FOR
       AUTOMATIC-JAZZ::KEY
       AUTOMATIC-JAZZ::FROM
       60
       AUTOMATIC-JAZZ::TO
       72
       AUTOMATIC-JAZZ::FOR
       AUTOMATIC-JAZZ::BEG
       AUTOMATIC-JAZZ::FROM
       0
       AUTOMATIC-JAZZ::BY
       ...)

 caught ERROR:
   (in macroexpansion of (PROCESS FOR KEY ...))
   (hint: For more precise location, try *BREAK-ON-SIGNALS*.)
   illegal loop syntax

 compilation unit finished
   caught 1 ERROR condition

;4) using the new package
(cm)

; o.k.
(events (automatic-jazz:up-loop) "myscore.mid")

; gives following error
(events (automatic-jazz:up-process) "myscore.mid")

Execution of a form compiled with errors.
Form:
(PROCESS
  FOR
  KEY
  FROM
  60
  TO
  72
  FOR
  BEG
  FROM
  0
  BY
  0.1
  OUTPUT
  (MAKE-INSTANCE 'MIDI TIME BEG KEYNUM KEY DURATION 1))
Compile-time error:
(in macroexpansion of (PROCESS FOR KEY ...))
(hint: For more precise location, try *BREAK-ON-SIGNALS*.)
illegal loop syntax

Thank you
Hans










More information about the Cmdist mailing list