Jagernot: Difference between revisions
Jump to navigation
Jump to search
No edit summary |
No edit summary |
||
| (20 intermediate revisions by the same user not shown) | |||
| Line 1: | Line 1: | ||
Livecoding with [http://code.google.com/p/din din] | |||
din has | din has a [http://www.tcl.tk/man/tcl/tutorial/tcltutorial.html Tcl] / [http://www.tkdocs.com/tutorial/ Tk] interpreter for livecoding sound and GUI. Tcl/Tk is a convenient choice for livecoding in din because din and Tcl/Tk commands have the form: <pre>command_name arg1 arg2 ... argN</pre>You can mix din commands with Tcl/Tk commands, take advantage of powerful programming features of Tcl, GUI widgets of Tk and create, edit and evaluate code while din is live. | ||
<pre> | |||
< | |||
set code1 {set_bpm fm $v; set_bpm gate-l $v; set_bpm gate-r $v} ;# | # a livecode session in din | ||
set code2 {key $v} ;# changes | # may 18, 2010 | ||
# by jagernot | |||
# | |||
# code snippets we will execute to change different sound parameters in din. | |||
set code1 {set_bpm fm $v; set_bpm gate-l $v; set_bpm gate-r $v} ;# changes FM bpm and gater L and gater R bpm. | |||
set code2 {key $v} ;# changes key of din. $v is value in Hz. | |||
set code3 {set_delay all feedback [expr $v/100.0]} ;# changes feedback of L and R delay lines | set code3 {set_delay all feedback [expr $v/100.0]} ;# changes feedback of L and R delay lines | ||
# set_bpm, key and set_delay are built-in din commands. | # set_bpm, key and set_delay are built-in din commands implemented in C++ and accessible inside the Tcl/Tk interpreter | ||
# make a Tk based slider | |||
package require Tk; | |||
scale .s ;# slider is called scale in Tk. | |||
grid .s | |||
# slider will now show up in a window | |||
# slider handler | # slider handler | ||
proc slide {code v} { | proc slide {code v} { | ||
eval $code | eval $code ;# evaluate code snippet when you move the slider knob. | ||
} | } | ||
# | # | ||
# possibilities | |||
# | |||
# change FM bpm and gater L and R bpm | |||
set code $code1 | |||
.s configure -from 0 -to 240 -command {slide $code} ;# bpm range is from 0 to 240. | |||
# | # change key of din | ||
set code $code2 | set code $code2 | ||
.s configure -from 261 -to [expr 4*261] ;# | .s configure -from 261 -to [expr 4*261] ;# key range from middle C to 2 octaves above middle-C | ||
# | # change feedback on all delays | ||
set code $code3 | set code $code3 | ||
.s configure -from 0 -to 100 ;# slider range from 0 to 100 | .s configure -from 0 -to 100 ;# slider range from 0 to 100 | ||
</ | </pre> | ||
Latest revision as of 10:02, 19 May 2010
Livecoding with din
din has a Tcl / Tk interpreter for livecoding sound and GUI. Tcl/Tk is a convenient choice for livecoding in din because din and Tcl/Tk commands have the form:
command_name arg1 arg2 ... argN
You can mix din commands with Tcl/Tk commands, take advantage of powerful programming features of Tcl, GUI widgets of Tk and create, edit and evaluate code while din is live.
# a livecode session in din
# may 18, 2010
# by jagernot
#
# code snippets we will execute to change different sound parameters in din.
set code1 {set_bpm fm $v; set_bpm gate-l $v; set_bpm gate-r $v} ;# changes FM bpm and gater L and gater R bpm.
set code2 {key $v} ;# changes key of din. $v is value in Hz.
set code3 {set_delay all feedback [expr $v/100.0]} ;# changes feedback of L and R delay lines
# set_bpm, key and set_delay are built-in din commands implemented in C++ and accessible inside the Tcl/Tk interpreter
# make a Tk based slider
package require Tk;
scale .s ;# slider is called scale in Tk.
grid .s
# slider will now show up in a window
# slider handler
proc slide {code v} {
eval $code ;# evaluate code snippet when you move the slider knob.
}
#
# possibilities
#
# change FM bpm and gater L and R bpm
set code $code1
.s configure -from 0 -to 240 -command {slide $code} ;# bpm range is from 0 to 240.
# change key of din
set code $code2
.s configure -from 261 -to [expr 4*261] ;# key range from middle C to 2 octaves above middle-C
# change feedback on all delays
set code $code3
.s configure -from 0 -to 100 ;# slider range from 0 to 100