Subject: [linux-audio-dev] gui etc
From: Bill Schottstaedt (bil_AT_ccrma.Stanford.EDU)
Date: Mon Mar 13 2000 - 08:55:01 EST
On the subject of GUI's and so forth, in the gtk version
of Snd, you can include guile-gtk; the following code is
a simple exampe -- it adds a "play" option to the Snd
menu, which when activated fires up a dialog window with
a scale and a button, the button causing the current
sound to start playing, its amplitude controlled in
"real-time" by the scale:
(use-modules (gtk gtk) (gtk gdk))
(define amp 1.0)
(define play-dialog-menu (gtk-menu-item-new-with-label "play"))
(gtk-menu-append (sg-options-menu-widget) play-dialog-menu)
(gtk-widget-show play-dialog-menu)
(gtk-signal-connect play-dialog-menu "activate"
(lambda ()
(let* ((window (gtk-dialog-new))
(adj (gtk-adjustment-new 1.0 0.0 1.01 .01 .01 .01))
(scale (gtk-hscale-new adj))
(button (gtk-button-new-with-label "play")))
(gtk-box-pack-start (gtk-dialog-action-area window) scale #t #t 2)
(gtk-range-set-update-policy scale 'continuous)
(gtk-scale-set-digits scale 2)
(gtk-scale-set-draw-value scale #t)
(gtk-widget-show scale)
(gtk-signal-connect adj "value_changed"
(lambda ()
(set! amp (gtk-adjustment-value adj))))
(gtk-box-pack-start (gtk-dialog-action-area window) button #f #f 2)
(gtk-signal-connect button "clicked"
(lambda ()
(let* ((size 256)
(data (make-sound-data 1 size))
(bytes (* size 2))
(len (frames))
(beg 0)
(audio-fd (open-audio-output sndlib-default-device 22050 1
snd-16-linear-little-endian bytes)))
(if (not (= audio-fd -1))
(do ()
((or (abort?) (>= beg len))
(close-audio audio-fd))
(vct->sound-data (vct-scale! (samples->vct beg size) amp) data 0)
(write-audio audio-fd data size)
(set! beg (+ beg size)))))))
(gtk-widget-show button)
(gtk-widget-show window))))
This archive was generated by hypermail 2b28 : Mon Mar 13 2000 - 16:55:09 EST