📄 xsox
字号:
#!/usr/bin/wish -f## Graphical user interface for Sox sound file conversion utility.## set this to wherever your icons are installedset icondir /usr/local/lib### procedures to create the graphical objects #### main window title and iconproc mainwindow {} { global icondir wm title . XSox wm iconname . XSox wm iconbitmap . @$icondir/xsox.icon wm iconmask . @$icondir/xsox.mask}# menu bar and pull-down menusproc menubar {name} { # frame for menu bar frame .$name -relief raised -bd 2 pack .$name -side top -fill x -ipady 2 # menu buttons menubutton .$name.file -text File -menu .$name.file.menu button .$name.convert -text Convert -command {playorconvert sox} button .$name.play -text Play -command {playorconvert play} menubutton .$name.help -text Help -menu .$name.help.menu pack .$name.file .$name.convert .$name.play -side left -padx 4 pack .$name.help -side right # pull-down menus menu .$name.file.menu .$name.file.menu add command -label "Input Parameters..." \ -command {wm deiconify .input ; raise .input} .$name.file.menu add command -label "Output Parameters..." \ -command {wm deiconify .output ; raise .output} .$name.file.menu add command -label "Global Parameters..." \ -command {wm deiconify .globals ; raise .globals} .$name.file.menu add command -label Effects... \ -command {wm deiconify .effects ; raise .effects} .$name.file.menu add command -label About... -command AboutPopup .$name.file.menu add separator .$name.file.menu add command -label Quit -command {exit 0} menu .$name.help.menu .$name.help.menu add command -label "On XSox..." -command HelpOnXsox .$name.help.menu add command -label "On Basics..." -command HelpOnBasics .$name.help.menu add command -label "On Input Parameters..." \ -command HelpOnInputParameters .$name.help.menu add command -label "On Output Parameters..." \ -command HelpOnOutputParameters .$name.help.menu add command -label "On Global Parameters..." \ -command HelpOnGlobalParameters .$name.help.menu add command -label "On Effects..." \ -command HelpOnEffects tk_menuBar .$name .$name.file.menu .$name.help.menu}# main window graphic imageproc graphic {name} { global icondir label .$name -relief raised -bd 2 -bitmap @$icondir/xsox.xbm pack .$name}# popup window for file input or output parametersproc inputoutput {name} { toplevel .${name} if {$name == "input"} {wm title .$name "Input Parameters"} if {$name == "output"} {wm title .$name "Output Parameters"} frame .$name.file -bd 2 if {$name == "input"} {label .$name.file.label -text "Input File Name:"} if {$name == "output"} {label .$name.file.label -text "Output File Name:"} global ${name}file entry .$name.file.entry -width 25 -textvariable ${name}file -relief sunken bind .${name}.file.entry <KeyPress-Return> { } pack .$name.file.label .$name.file.entry -side left frame .$name.filetype -bd 2 frame .$name.filetype.filetype1 frame .$name.filetype.filetype2 frame .$name.filetype.filetype3 frame .$name.filetype.filetype4 global inputfiletypeenable checkbutton .$name.filetype.label -text "File Type:" -variable \ ${name}filetypeenable -command "widget_toggle \$${name}filetypeenable \ {.${name}.filetype.filetype1.auto .${name}.filetype.filetype1.aiff \ .${name}.filetype.filetype1.au .${name}.filetype.filetype1.hcom .${name}.filetype.filetype2.raw .${name}.filetype.filetype2.ub .${name}.filetype.filetype2.sb .${name}.filetype.filetype2.uw .${name}.filetype.filetype3.sw .${name}.filetype.filetype3.ul .${name}.filetype.filetype3.sf .${name}.filetype.filetype3.voc .${name}.filetype.filetype4.cdr .${name}.filetype.filetype4.dat .${name}.filetype.filetype4.smp .${name}.filetype.filetype4.wav}" global ${name}filetype radiobutton .${name}.filetype.filetype1.auto -text auto -variable \ ${name}filetype -width 4 -anchor w -state disabled -value auto radiobutton .${name}.filetype.filetype1.aiff -text aiff -variable \ ${name}filetype -width 4 -anchor w -state disabled -value aiff radiobutton .$name.filetype.filetype1.au -text au -variable \ ${name}filetype -width 4 -anchor w -state disabled -value au radiobutton .$name.filetype.filetype1.hcom -text hcom -variable \ ${name}filetype -width 4 -anchor w -state disabled -value hcom radiobutton .$name.filetype.filetype2.raw -text raw -variable \ ${name}filetype -width 4 -anchor w -state disabled -value raw radiobutton .$name.filetype.filetype2.ub -text ub -variable \ ${name}filetype -width 4 -anchor w -state disabled -value ub radiobutton .$name.filetype.filetype2.sb -text sb -variable \ ${name}filetype -width 4 -anchor w -state disabled -value sb radiobutton .$name.filetype.filetype2.uw -text uw -variable \ ${name}filetype -width 4 -anchor w -state disabled -value uw radiobutton .$name.filetype.filetype3.sw -text sw -variable \ ${name}filetype -width 4 -anchor w -state disabled -value sw radiobutton .$name.filetype.filetype3.ul -text ul -variable \ ${name}filetype -width 4 -anchor w -state disabled -value ul radiobutton .$name.filetype.filetype3.sf -text sf -variable \ ${name}filetype -width 4 -anchor w -state disabled -value sf radiobutton .$name.filetype.filetype3.voc -text voc -variable \ ${name}filetype -width 4 -anchor w -state disabled -value voc radiobutton .$name.filetype.filetype4.cdr -text cdr -variable \ ${name}filetype -width 4 -anchor w -state disabled -value cdr radiobutton .$name.filetype.filetype4.dat -text dat -variable \ ${name}filetype -width 4 -anchor w -state disabled -value dat radiobutton .$name.filetype.filetype4.smp -text smp -variable \ ${name}filetype -width 4 -anchor w -state disabled -value smp radiobutton .$name.filetype.filetype4.wav -text wav -variable \ ${name}filetype -width 4 -anchor w -state disabled -value wav pack .$name.filetype.filetype1.auto .$name.filetype.filetype1.aiff \ .$name.filetype.filetype1.au .$name.filetype.filetype1.hcom -side left pack .$name.filetype.filetype2.raw .$name.filetype.filetype2.ub \ .$name.filetype.filetype2.sb .$name.filetype.filetype2.uw -side left pack .$name.filetype.filetype3.sw .$name.filetype.filetype3.ul \ .$name.filetype.filetype3.sf .$name.filetype.filetype3.voc -side left pack .$name.filetype.filetype4.cdr .$name.filetype.filetype4.dat \ .$name.filetype.filetype4.smp .$name.filetype.filetype4.wav -side left pack .$name.filetype.label .$name.filetype.filetype1 \ .$name.filetype.filetype2 .$name.filetype.filetype3 \ .$name.filetype.filetype4 -anchor w frame .$name.samplerate -bd 2 global ${name}samplerateenable checkbutton .$name.samplerate.label -text "Sample Rate:" \ -variable ${name}samplerateenable -command \ "widget_toggle \$${name}samplerateenable {.${name}.samplerate.entry}" label .$name.samplerate.hz -text Hz global ${name}samplerate entry .$name.samplerate.entry -width 8 -textvariable ${name}samplerate \ -relief sunken -state disabled bind .${name}.samplerate.entry <KeyPress-Return> {validate_entry %W} pack .$name.samplerate.label .$name.samplerate.entry .$name.samplerate.hz \ -side left -padx 2 global ${name}swapbytes checkbutton .$name.swapbytes -text "Swap Byte Order" -variable \ ${name}swapbytes -anchor w frame .$name.sampletype -bd 2 frame .$name.sampletype.sampletype1 frame .$name.sampletype.sampletype2 global ${name}sampletypeenable checkbutton .$name.sampletype.label -text "Sample Type:" \ -variable ${name}sampletypeenable -command \ "widget_toggle \$${name}sampletypeenable { \ .${name}.sampletype.sampletype1.signed \ .${name}.sampletype.sampletype1.unsigned \ .${name}.sampletype.sampletype2.ulaw \ .${name}.sampletype.sampletype2.alaw}" global ${name}sampletypeenable radiobutton .$name.sampletype.sampletype1.signed -text signed \ -variable ${name}sampletype -width 8 -state disabled -value -s radiobutton .$name.sampletype.sampletype1.unsigned -text unsigned \ -variable ${name}sampletype -width 8 -state disabled -value -u radiobutton .$name.sampletype.sampletype2.ulaw -text u-law \ -variable ${name}sampletype -width 8 -state disabled -value -U radiobutton .$name.sampletype.sampletype2.alaw -text A-law \ -variable ${name}sampletype -width 8 -state disabled -value -A pack .$name.sampletype.sampletype1.signed \ .$name.sampletype.sampletype1.unsigned -side left pack .$name.sampletype.sampletype2.ulaw \ .$name.sampletype.sampletype2.alaw -side left -side left pack .$name.sampletype.label .$name.sampletype.sampletype1 \ .$name.sampletype.sampletype2 -anchor w frame .$name.samplesize -bd 2 frame .$name.samplesize.samplesize1 frame .$name.samplesize.samplesize2 global ${name}samplesizeenable checkbutton .$name.samplesize.label -text "Sample Size:" \ -variable ${name}samplesizeenable -command \ "widget_toggle \$${name}samplesizeenable { \ .${name}.samplesize.samplesize1.byte \ .${name}.samplesize.samplesize1.word \ .${name}.samplesize.samplesize1.long \ .${name}.samplesize.samplesize2.float \ .${name}.samplesize.samplesize2.double \ .${name}.samplesize.samplesize2.ieee \ }" global ${name}samplesize radiobutton .$name.samplesize.samplesize1.byte -text 8-bit \ -variable ${name}samplesize -width 6 -state disabled -value -b radiobutton .$name.samplesize.samplesize1.word -text 16-bit \ -variable ${name}samplesize -width 6 -state disabled -value -w radiobutton .$name.samplesize.samplesize1.long -text 32-bit \ -variable ${name}samplesize -width 6 -state disabled -value -l radiobutton .$name.samplesize.samplesize2.float -text float \ -variable ${name}samplesize -width 6 -state disabled -value -f radiobutton .$name.samplesize.samplesize2.double -text double \ -variable ${name}samplesize -width 6 -state disabled -value -d radiobutton .$name.samplesize.samplesize2.ieee -text ieee \ -variable ${name}samplesize -width 6 -state disabled -value -D pack .$name.samplesize.samplesize1.byte \ .$name.samplesize.samplesize1.word \ .$name.samplesize.samplesize1.long -side left pack .$name.samplesize.samplesize2.float \ .$name.samplesize.samplesize2.double \ .$name.samplesize.samplesize2.ieee -side left pack .$name.samplesize.label .$name.samplesize.samplesize1 \ .$name.samplesize.samplesize2 -anchor w frame .$name.channels -bd 2 global ${name}channelsenable checkbutton .$name.channels.label -text Channels: -variable \ ${name}channelsenable -command "widget_toggle \$${name}channelsenable {.${name}.channels.1 .${name}.channels.2 .${name}.channels.4}" global ${name}channels radiobutton .$name.channels.1 -text 1 -variable ${name}channels \ -state disabled -value 1 radiobutton .$name.channels.2 -text 2 -variable ${name}channels \ -state disabled -value 2 radiobutton .$name.channels.4 -text 4 -variable ${name}channels \ -state disabled -value 4 pack .$name.channels.label .$name.channels.1 .$name.channels.2 \ .$name.channels.4 -side left frame .$name.dismiss -relief groove -bd 2 button .$name.dismiss.button -text Dismiss -command "wm withdraw .$name" pack .$name.dismiss.button -pady 2 pack .$name.file .$name.samplerate .$name.filetype .$name.sampletype \ .$name.samplesize .$name.channels .$name.swapbytes -padx 2 -pady 2 \ -anchor w pack .$name.dismiss -expand 1 -fill x -padx 2 -pady 2 -anchor w global ${name}.samplerate set ${name}samplerate 8000 wm withdraw .$name .$name.filetype.filetype1.auto select .$name.sampletype.sampletype1.signed select .$name.samplesize.samplesize1.byte select .$name.channels.1 select}# popup window for global parametersproc globals {name} { global volumeenable volume toplevel .${name} wm title .$name "Global Parameters" frame .$name.volume -bd 2 checkbutton .${name}.volume.checkbutton -text "Scale Volume By:" \ -variable volumeenable -command \ "widget_toggle \$volumeenable {.${name}.volume.entry}" entry .${name}.volume.entry -width 6 -textvariable volume -relief sunken \ -stat disabled bind .${name}.volume.entry <KeyPress-Return> {validate_entry %W} pack .$name.volume.checkbutton .$name.volume.entry -side left frame .$name.dismiss -relief groove -bd 2 button .$name.dismiss.button -text Dismiss -command "wm withdraw .$name" pack .$name.dismiss.button -pady 2 pack .$name.volume .$name.dismiss -expand 1 -fill both -padx 2 -pady 2 \ -anchor w global volume set volume 1.0 wm withdraw .${name}}# popup window for effectsproc effects {name} { global effect echodelay echovolume vibrospeed vibrodepth centerfreq global filterwidth noise toplevel .$name wm title .$name Effects frame .$name.effect -bd 2 frame .$name.effect.effect1 frame .$name.effect.effect2 frame .$name.effect.effect3 label .$name.effect.checkbutton -text Effect: radiobutton .$name.effect.effect1.copy -text copy -variable effect \ -value copy -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect1.rate -text rate -variable effect \ -value rate -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect1.avg -text average -variable effect \ -value avg -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect2.stat -text stat -variable effect \ -value stat -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect2.echo -text echo -variable effect \ -value echo -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect2.vibro -text vibro -variable effect \ -value vibro -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect3.lowp -text "low pass" -variable effect \ -value lowp -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect3.highp -text "high pass" -variable effect \ -value highp -width 9 -anchor w -command {effects_toggle $effect} radiobutton .$name.effect.effect3.band -text "band pass" -variable effect \ -value band -width 9 -anchor w -command {effects_toggle $effect} pack .$name.effect.effect1.copy .$name.effect.effect1.rate \ .$name.effect.effect1.avg -side left pack .$name.effect.effect2.stat .$name.effect.effect2.echo \ .$name.effect.effect2.vibro -side left pack .$name.effect.effect3.lowp .$name.effect.effect3.highp \ .$name.effect.effect3.band -side left pack .$name.effect.checkbutton .$name.effect.effect1 .$name.effect.effect2 \ .$name.effect.effect3 -anchor w frame .$name.delay -bd 2 label .$name.delay.label1 -text "Echo Delay:" entry .$name.delay.entry1 -width 5 -textvariable echodelay -relief sunken bind .${name}.delay.entry1 <KeyPress-Return> {validate_entry %W} label .$name.delay.secs -text secs label .$name.delay.label2 -text "Echo Volume:" entry .$name.delay.entry2 -width 5 -textvariable echovolume -relief sunken bind .${name}.delay.entry2 <KeyPress-Return> {validate_entry %W} pack .$name.delay.label1 .$name.delay.entry1 .$name.delay.secs \ .$name.delay.label2 .$name.delay.entry2 -side left -padx 2 frame .$name.vibro -bd 2 label .$name.vibro.label1 -text "Vibro Speed:" entry .$name.vibro.entry1 -width 5 -textvariable vibrospeed -relief sunken bind .${name}.vibro.entry1 <KeyPress-Return> {validate_entry %W} label .$name.vibro.hz -text Hz label .$name.vibro.label2 -text "Vibro Depth:" entry .$name.vibro.entry2 -width 5 -textvariable vibrodepth -relief sunken bind .${name}.vibro.entry2 <KeyPress-Return> {validate_entry %W} pack .$name.vibro.label1 .$name.vibro.entry1 .$name.vibro.hz \ .$name.vibro.label2 .$name.vibro.entry2 -side left -padx 2 frame .$name.filter -bd 2 label .$name.filter.label1 -text "Center Frequency:" entry .$name.filter.entry1 -width 5 -textvariable centerfreq -relief sunken bind .${name}.filter.entry1 <KeyPress-Return> {validate_entry %W} label .$name.filter.hz -text Hz label .$name.filter.label2 -text Width: entry .$name.filter.entry2 -width 5 -textvariable filterwidth -relief sunken bind .${name}.filter.entry2 <KeyPress-Return> {validate_entry %W} label .$name.filter.label3 -text Hz checkbutton .$name.filter.noise -text Noise -variable noise -state disabled pack .$name.filter.label1 .$name.filter.entry1 .$name.filter.hz \ .$name.filter.label2 .$name.filter.entry2 .$name.filter.label3 \ .$name.filter.noise -side left -padx 2 frame .$name.dismiss -relief groove -bd 2 button .$name.dismiss.button -text Dismiss -command "wm withdraw .$name" pack .$name.dismiss.button -pady 2 .$name.effect.effect1.copy select global echodelay echovolume vibrospeed vibrodepth centerfreq filterwidth set echodelay 1.0 set echovolume 0.5 set vibrospeed 10.0 set vibrodepth 0.5 set centerfreq 4000 set filterwidth 1000 pack .$name.effect .$name.delay .$name.vibro .$name.filter -padx 2 \ -pady 2 -anchor w -expand 1 -fill both pack .$name.dismiss -expand 1 -fill both -padx 2 -pady 2 -anchor w wm withdraw .$name}### event handlers ###
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -