From mlang@home.delysid.org Sun Dec 16 19:22:23 2001 Date: 26 Mar 2001 14:48:02 +0200 From: Mario Lang Reply-To: ecasound-list@wakkanet.fi To: ecasound-list@wakkanet.fi Subject: [ecasound] Completion for ecasound via Zsh Hi Guys. I recently switched shell to zsh, and had a serious look at the completion system. I can tell you, it is a hit, and bash has some years to go to actually reach the level of customisability of Zsh. What follows is the completion code for ecasound I managed to write till now. Just in advance, there are many things to do left, and I am open to suggestions! Quick install: You need Zsh >3.1.6 (take the latest beta release), the new completion system of zsh needs to get initialized, so do something like: autoload -U compinstall compinstall you will get a menu with some options to customize. Afterwards, compinstall has written some definitions to ~/.zshrc. YOu need to create your own function directory now, such as mkdir ~/.zshfns place the script below named _ecasound in there and add the following line to the beginning of your .zshrc (actually, before the compinit call): fpath=(~/.zshfns $fpath) now ecasound completion should work. Do ecasound - and hit tab over and over again, and be amazed :-). This type of building command-lines for ecasound could actually make you switch shell :-). So, here we go. And remember, I am constantly doing improvments, so send me any suggestions, but contact me before you start doing work on your own. Note that the following goes into a file _ecasound and that #compdef ecasound has to be the first line of the file. #compdef ecasound # Completion definition for ecasound under Zsh >3.1.6. # # by Mario Lang . # # Please send me any improvments you make as diff # file to the above e-mail. # # # This file should be named _ecasound and placed in one of the # fpath directories. # # TODO (top most = most important): # * Implement controllers: # Actually, it would be nice to have fx-params complete with description. # Which means -ef1:100,50 -kl: should show # completing resonant bandpass filter parameters # 1 -- center frequency # 2 -- width (Hz) # # The whole parameter description mechanism (case $state in below) should # be changed into some array which can be used for lookup. # * Generalize the option definitons when # doing todo-list-item above so that completion can be used # for all eca tools (ecasignalview, ...) # * Introduce grouping of the different option types (hmm, I once knew how this worked...) # * Fix sort order of power-of-two completions (e.g. -b: or -z:db,) # * Fix TAB behaviour with -z:db # (db gets listed without a comma, # this is absolutely in contrast to the rest of all # options (e.g. -z: which indicates that there has to # be something after -z) # * finish io) which isnt quite correct at the time about file extensions # * Make the awk stuff in i/o completion nicer # * LADSPA completion (perhaps even with arguemtns from the xml desc?) # # local context state line local expl typeset -A opt_args _arguments \ '-c[Start in interactive mode]' \ '-d\:-[Debug level]:debug level' \ '-D[Print all debug information to stderr]' \ '-q[Quiet mode, no output]' \ '--help[Show help]' \ '--version[Show version information]' \ '-n\:-[Set the name of chainsetup]:chainsetup name' \ '-s\:-[Create a new chainsetup from file]:chainsetup file:_files' \ '-sr\:-[Set internal sampling rate]:Internal sampling rate:(8000 11025 22050 44100 48000)' \ '*-a\:-[Select active signal chains]:chain name' \ '-b\:-[Sets the size of buffer in samples]:buffer size:(1 2 4 8 16 32 64 128 256 512 1024 2048 4096 8192 16384 32768 65536)' \ '-m\:-[Force use of specified mix mode]:Mix mode:((auto\:Automatic simple\:Only\ one\ input/cain/output normal\:Normal\ single-threaded\ mode))' \ '-r[Use realtime scheduling policy (SCHED_FIFO)]' \ '-r\:-[Use realtime scheduling policy (SCHED_FIFO)]:sched_priority' \ '-x[Truncate outputs]' \ '*-z\:-[Enable feature]:feature:->z' \ '-t\:-[Set processing time in seconds]:seconds (int/float)' \ '-tl[Enable looping]' \ '*-f\:-[Set sampling parameters for the following input/output files]: :->f' \ '*-y\:-[Set starting position for last specified input/output]:seconds' \ '*-i\:-[Specifies a new input source]:input source:->io' \ '*-o\:-[Specifies a new output source]:output source:->io' \ '*-Md\:-[Set the active MIDI-device]:device name:_files' \ '*-Mms\:-[Send MMC start/stop to MIDI device-id]:device id' \ '*-mss[Sends MIDI-sync to the selected MIDI-device]' \ '*-pf\:-[Use the first preset found from file as chain operator]:preset file:_files -g *.epp' \ '*-pn\:-[Find preset from global preset database]:preset name:->pn' \ '*-ev[Analyze sample data to find max apm value without clipping]' \ '*-ezf[Find the optimal value for DC-adjusting]' \ '*-eS\:-[Audio stamp]:stamp-id (int)' \ '*-ea\:-[Amplify signal]:amplification value (percent)' \ '*-eac\:-[Amplify signal of channel]: :->eac' \ '*-eaw\:-[Amplify singal (clipping)]: :->eaw' \ '*-eal\:-[Limits audio level]:limit (percent)' \ '*-ec\:-[Compressor (a simple one)]: :->ec' \ '*-eca\:-[A more advanced compressor]: :->eca' \ '*-enm\:-[Noise gate. (each channel is processes separately)]: :-enm' \ '*-ei\:-[Pitch shifter (modifies audio pitch by altering its length)]:pitch-shift (percent)' \ '*-epp\:-[Normal pan effect]:panning (0=left, 50=center, 100=right)' \ '*-ezx\:-[Adjusts the signal DC (use -ezf to find optimal values)]: :-ezx' \ '*-eemb\:-[Pulse gate]: :-eemb' \ '*-eemp\:-[Pulse gate (hz)]: :->eemp' \ '*-eemt\:-[Tremolo effect]: :->eemt' \ '*-ef1\:-[Resonant bandpass filter]: :->ef1' \ '*-ef3\:-[Resonant lowpass filter]: :->ef3' \ '*-ef4\:-[Resonant lowpass filter (3rd-order, 36dB)]: :->ef4' \ '*-efa\:-[Allpass filter]: :->efa' \ '*-efc\:-[Comb filter]: :->efc' \ '*-efb\:-[Bandpass filter]: :->efb' \ '*-efh\:-[Highpass filter]:cutoff frequency' \ '*-efi\:-[Inverse comb filter]: :->efi' \ '*-efl\:-[Lowpass filter]:cutoff frequency' \ '*-efr\:-[Bandreject filter]: :->efr' \ '*-efs\:-[Resonator (resonating bandpass filter)]: :->efs' \ '*-erc\:-[Copy channel]: :->erc' \ '*-erm\:-[Mix all channels to one channel]:to channel' \ '*-etc\:-[Chorus]: :->etc' \ '*-etd\:-[Delay effect]: :->etd' \ '*-ete\:-[A more advanced reverb effect]: :-ete' \ '*-etf\:-[Fake-stereo effect]:delay time (msec)' \ '*-etl\:-[Flanger]: :->etl' \ '*-etm\:-[Multitap delay]: :->etm' \ '*-etp\:-[Phaser]: :->etp' \ '*-etr\:-[Reverb effect]: :->etr' \ '*-el\:-[LADSPA Plugin]: :->el' \ '*-eli\:-[LADSPA Plugin]: :->el' \ '*-gc\:-[Time crop gate]: :->gc' \ '*-ge\:-[Threshold gate]: :->ge' \ && return 0 case $state in f) if compset -P '*,*,*,'; then _values 'interleaving' \ 'i[interleaved stream format]' \ 'n[noninterleaved]' elif compset -P '*,*,'; then _message 'sampling rate' elif compset -P '*,'; then _message 'channels' else _values 'Sampling parameters' \ 'u8[unsigned 8-bit]' \ 's16_le[signed 16-bit little endian]' \ 's16_be[signed 16-bit big endian]' \ 's24_le[signed 24-bit little endian]' \ 's24_be[signed 24-bit big endian]' \ 's32_le[signed 32-bit little endian]' \ 's32_be[signed 32-bit big endian]' \ 'f32_le[32-bit float (little endian)]' \ 'f32_be[32-bit float (big endian)]' fi ;; z) if compset -P 'db,'; then _values 'buffer size in sample frames' \ '0[default]' '1' '2' '4' '8' '16' #??? Kai? else db=('db:enable double-buffering') other=('nodb:disable double-buffering' 'nointbuf:prevents realtime device from doing extra internal buffering' 'xruns:processing will be halted when a under/overrun occurs' 'psr:enable the precise-sample-rates') _describe 'enable feature' \ db -S ',' -- \ other fi ;; io) if compset -P 'alsa,'; then if [[ -e /proc/asound ]]; then eval `cat /proc/asound/cards|grep "^[[:digit:]]"|awk 'BEGIN {print "_values '\''ALSA device'\''" }; {print "'\''" $1 "[" $6, $7, $8, $9 "]'\''"}'||echo _message Wrong` else _message 'No ALSA information in proc filesystem' fi else _description files expl 'input/output files' _files "$expl[@]" -g '*.(aif|aiff|mid|wav|ewf|mp3|mp2)' _values 'streams' \ 'stdin' 'stdout' _values 'Realtime devices' \ '/dev/dsp' \ 'alsa[ALSA device]' \ 'null[Null device]' fi ;; pn) eval `cat /usr/share/ecasound/effect_presets|grep "^[[:alpha:]]"|awk 'BEGIN {print "_values '\''preset name'\'' "}; {print "'\''" $1 "'\''"}'` ;; eac) if compset -P '*,'; then _message 'channel' else _message 'amplification value (percent)' fi ;; eaw) if compset -P '*,*,'; then _message 'max-clipped-samples' elif compset -P '*,'; then _message 'channel' else _message 'amplification value (percent)' fi ;; ec) if compset -P '*,'; then _message 'threshold (0.0-1.0)' else _message 'compression rate in decibels' fi ;; eca) if compset -P '*,*,*,'; then _message 'compression rate' elif compset -P '*,*,'; then _message 'fast compression rate (0.0-1.0)' elif compset -P '*,'; then _message 'release-time (seconds)' else _message 'peak-level-%' fi ;; enm) if compset -P '*,*,*,*,'; then _message 'release-time (msec)' elif compset -P '*,*,*,'; then _message 'post-hold-time (msec)' elif compset -P '*,*,'; then _message 'attack-time (msec)' elif compset -P '*,'; then _message 'pre-hold-time (msec)' else _message 'threshold-level-%' fi ;; ezx) if compset -Q '*,'; then _message 'right CD fix value' else _message 'left DC fix value' fi ;; eemb) if compset -P '*,'; then _message 'on time (msec)' else _message 'pulse frequency (beats per minute)' fi ;; eemp) if compset -P '*,'; then _message 'on time (percent)' else _message 'pulse frequency (hz)' fi ;; eemt) if compset -P '*,'; then _message 'depth (percent)' else _message 'tremolo speed (beats per second)' fi ;; ef1) if compset -P '*,'; then _message 'width (Hz)' else _message 'center frequency' fi ;; ef3) if compset -P '*,*,'; then _message 'gain' elif compset -P '*,'; then _message 'resonance' else _message 'cutoff frequency' fi ;; ef4) if compset -P '*,'; then _message 'resonance' else _message 'cutoff' fi ;; efa) if compset -P '*,'; then _message 'feedback (percent)' else _message 'delay (samples)' fi ;; efc) if compset -P '*,'; then _message 'radius (0-1.0)' else _message 'delay (samples)' fi ;; efb) if compset -P '*,'; then _message 'width (Hz)' else _message 'center frequency' fi ;; efi) if compset -P '*,'; then _message 'radius (0-1.0)' else _message 'delay (samples)' fi ;; efr) if compset -P '*,'; then _message 'width (Hz)' else _message 'center frequency' fi ;; efs) if compset -P '*,'; then _message 'width (Hz)' else _message 'center frequency' fi ;; erc) if compset -P '*,'; then _message 'to channel' else _message 'from channel' fi ;; etc) if compset -Q '*,*,*,'; then _message 'lfo frequency' elif compset -P '*,*,'; then _message 'feedback (percent)' elif compset -P '*,'; then _message 'variance time (samples)' else _message 'delay time (msec)' fi ;; etd) if compset -Q '*,*,*,'; then _message 'mix (wet) (percent)' elif compset -P '*,*,'; then _message 'number of delays' elif compset -P '*,'; then _values 'surround mode' '0[normal]' '1[surround]' '2[stereo-spread]' else _message 'delay time (msec)' fi ;; ete) if compset -P '*,*,'; then _message 'the amount of reverbed signal added to the original (wet) (percent)' elif compset -P '*,'; then _message 'the feedback level given in percents' else _message 'room size given in meters' fi ;; etl) if compset -Q '*,*,*,'; then _message 'lfo frequency' elif compset -P '*,*,'; then _message 'feedback (percent)' elif compset -P '*,'; then _message 'variance time (samples)' else _message 'delay time (msec)' fi ;; etm) if compset -P '*,*,'; then _message 'mix (wet) (percents)' elif compset -P '*,'; then _message 'number of delays' else _message 'delay time (msec)' fi ;; etp) if compset -Q '*,*,*,'; then _message 'lfo frequency' elif compset -P '*,*,'; then _message 'feedback (percent)' elif compset -P '*,'; then _message 'variance time (samples)' else _message 'delay time (msec)' fi ;; etr) if compset '*,*,'; then _message 'feedback (percents)' elif compset -P '*,'; then _message 'surround mode' # We could do nice _values here, but the docu (manpage) is very unclear about # what one can put here else _message 'delay time (msec)' fi ;; el) _message 'unique LADSPA name/number' # Actually this part could be full of magic. # * Determine LADSPA Plugin path from ecasoundrc # * Use some way to extract a LADSPA name/number list with descriptions. # * Perhaps even build up parameter descriptions ;; gc) if compset -P '*,'; then _message 'length how long gate remains open' else _message 'start time' fi ;; gc) if compset -P '*,*,'; then _values 'volume mode' 'rms' elif compset -P '*,'; then _message 'close threshold (percents)' else _message 'open threshold (percents)' fi ;; esac -- CYa, Mario Homepage(s): http://delysid.org | http://piss.at/ Absolutely nothing should be concluded from these figures except that no conclusion can be drawn from them. -- Joseph L. Brothers, Linux/PowerPC Project) -- To unsubscribe send message 'unsubscribe' in the body of the message to .