[CM] Keyshortcuts

Bill Schottstaedt bil@ccrma.Stanford.EDU
Mon, 31 May 2004 04:02:27 -0700


 >  I tried C-x C-f but it does nothing on my box...

If there's no open sound, or the mouse is in the listener, C-x C-f
isn't bound to anything.  The main reason is that the listener is
considered a text widget and uses its key bindings.  As far as I know,
neither Motif (via Xt) nor Gtk support directly Emacs' notion of an
extended command (the C-x prefix).  To get C-x C-f to start the Open File
dialog in the listener:

;;; --------
;;; Motif version:

(define extended #f)     ; our extended mode flag

(XtAddEventHandler (list-ref (main-widgets) 4) KeyPressMask #f
   (lambda (w context event go)
     (let* ((bits (.state event))
	   (keysym (XKeycodeToKeysym (XtDisplay w)
				    (.keycode event)
				    (if (not (= (logand bits ShiftMask) 0)) 1 0))))
       (if (= (logand bits ControlMask) 0)
	  (set! extended #f)
	  ;; got C-<something>
	  (if (= (cadr keysym) 120) ; C-x
	      (set! extended #t)
	      (begin
		(if (and extended
			 (= (cadr keysym) 102)) ; C-x C-f
		    (open-file-dialog))
		(set! extended #f)))))))


;;; --------
;;; Gtk version:

(define extended #f)     ; our extended mode flag

(let ((listener (list-ref (main-widgets) 4)))
   (g_signal_connect_closure_by_id
    (GPOINTER listener)
    (g_signal_lookup "key_press_event" (G_OBJECT_TYPE (GTK_OBJECT listener)))
    0
    (g_cclosure_new (lambda (w event data)
		     (let ((bits (.state (GDK_EVENT_KEY event)))
			   (key (.keyval (GDK_EVENT_KEY event))))
		       (if (= (logand bits GDK_CONTROL_MASK) 0)
			   (set! extended #f)
			   ;; got C-<something>
			   (if (= key 120) ; C-x
			       (set! extended #t)
			       (begin
				 (if (and extended
					  (= key 102))
				     (open-file-dialog))
				 (set! extended #f))))
		       #f))
		   #f #f)
    #f))


;;; --------
;;; You could also use "actions" in Xt/Motif:

(define extended #f) ; our extended mode flag

(XtAppAddActions         ; add an action for C-x (to enter extended mode)
   (car (main-widgets))
   (list (list "Cx" (lambda args (set! extended #t)))))

(XtOverrideTranslations
   (list-ref (main-widgets) 4)
   (XtParseTranslationTable "Ctrl <Key>x: Cx()\n"))

(XtAppAddActions     ; add an "action" for C-x C-f
   (car (main-widgets))
   (list (list "CxCf"
               (lambda args
		(let ((listener (list-ref (main-widgets) 4)))
		  (if (not extended) ; if no preceding C-x, C-f moves cursor ahead one position
		      (XmTextSetCursorPosition listener (1+ (XmTextGetCursorPosition listener)))
		      (begin         ; else start the "Open File" dialog
			(set! extended #f)
			(open-file-dialog))))))))

(XtOverrideTranslations
   (list-ref (main-widgets) 4)
   (XtParseTranslationTable "Ctrl <Key>f: CxCf()\n"))

;;; but now C-x followed by anything other than C-f leaves extended = #t


--------------------------------------------------------------------------------

 > I want to "fill" a sound -- for example a human voice -- with another
 > frequency. Sometime in TV-movies one can hear such effect for example
 > in the TV-series "Stargate" if a symbiont speaks.

I haven't heard this effect, but it might be cross synthesis?
There's a function that does this in examp.scm.


 > Another example how to use this would be to tune music an octave
 > lower without changing its speed.

Try granular synthesis (the "expand" control, or the granulate
CLM generator), or the phas-vocoder, then perhaps ATSH?