Groups keyboard shortcuts have been updated
Dismiss
See shortcuts

about make-instrument

22 views
Skip to first unread message

Minoru

unread,
Feb 9, 2023, 10:04:40 PM2/9/23
to Extempore
Hi, all

;; When making an original instrument, I write something like ....
;;
;; (bind-func osc_c ........)
;; (bind-func inst1_note ......)
;; (bind-func inst1_fx ......)
;; (make-instrument inst1 inst1)
;; (bind-func dsp:DSP .. (inst1 in time ...) ...)
;; (dsp:set! dsp)
;; (play-note (now) inst1 ..... ) and ok, it sounds !!
;;
;; Then I rewrite something on inst1_note, because of changing sounds,
;; some values, adding another osc or modulator, fixing something, and so on,
;; on extempore ver 0.70, it is very easy to get the result of rewriting,
;; just re-evaluate
;; (bind-func inst1_note ......) after rewriting inst1_note,
;; then,
;; (play-note (now) inst1 ..... ) makes another sounds according to
;; the changes made. If it's not so good, I just rewrite it again !
;;
;; But, on ver 0.89, it's impossible to do the same thing.
;; After modifying inst1_note, re-evaluate
;; (bind-func inst1_note ......)
;; but, inst1 makes just same sounds, nothing changes !
;; So I think I forget to do this ....
;; (make-instrument inst1 inst1) again, but this results just an error message as follows ..
;; Compiler Error inst1 already bound .......
;;
;; It seems that the possible way is changing the name of instrument inst1
;; to inst2 or something else, but here is a new instrument as a result !
;; that is,
;;
;; (make-instrument inst2 inst1)
;;
;; 1st argument inst2 means name of new instrument, it's possible to have the name I want,
;; 2nd inst1 means inst1_note and inst1_fx, the former is modified one,
;;
;; (bind-func dsp:DSP ..
;; (inst2 in time ...) ...)
;; or
;; (bind-func dsp:DSP ....
;; (+ (inst1 in time ...)
;; (inst2 in time ...)) ...) if I want to compare 2 sounds ....
;;
;; Then I'd like to change something again, I have to make another instrument again!
;; One change needs one more new instrument and no use old instuments behind it ! and so on ...
;; Really I just want to modify the inst1, it's not what I want to make/add new instrument !
;;
;; But original make-instrument doesn't seem to allow an instrument to be re-defined.
;;
;; So finally I made make-instrument-a3 (anytime-anywhere-anyplace),
;; now I can do many trials and errors on not only inst1_note but also inst_fx,
;; and get the modified instrument inst1, by ..
;;
;; (make-instrument-a3 inst1 inst1)
;;
;; now here is the modified inst1 without compile error,
;; without making any new instrument which wastes space and memory.
;;
;; And this function's arguments are same,
;; yes, how to use this function is all the same as original make-instrument,
;; like above and below examples ....


(define-macro (make-instrument-a3 defname synthname . args)
    `(let  ((inst-name-str (atom->string (quote ,defname))))
         (if (impc:ti:globalvar-exists? inst-name-str)
              (begin
                  (log-info "already exists, redefining :" inst-name-str)
                  (set!  *impc:ti:globalvar-cache*
                            (cl:delete (assoc inst-name-str *impc:ti:globalvar-cache*)
                                              *impc:ti:globalvar-cache*))))
         (eval  (append '(make-instrument ,defname ,synthname) (quote ,args))
                   (interaction-environment))))


;; after rewriting inst1_note and/or inst1_fx, I just do something like this ...

(begin
    (make-instrument-a3 inst1 inst1)
    (bind-func dsp
         (lambda (in time chan dat)
              (inst1 in time chan dat))))

;; now, inst1 already became a modified inst1 without changing it's name,
;; then (play-note (now) inst1 .... ), I hear another new sounds,
;; when inst1 has been being played in the loop playing code,
;; the sound is breaking up just in a moment, but immediately being played again
;; with new sounds according to the code modified.

;; This function calls the original make-instrument to do "make-instrument" in this code,
;; so I think there is no any problem ..... and hope so !
;; I use this make-instrument-a3 not only after modifying inst_note but also
;; when first definition of inst1, because it calls original make-instrument
;; in both cases.


Reply all
Reply to author
Forward
0 new messages