#! /bin/csh # # wave2lisp : from the wave data to .lisp file (csh script) # # by Takuya Fujishima, fujishim@ccrma, on Feb.25,28, 1998 # # usage: Type # wave2lisp [remote-machine-name] abc/xyz.aiff # to have xyz.sms and xyz.lisp at your current directory. # You can specify the remote-machine-name (it should a black next hardware). # NOTE that the character after the first occurrence of one of c,h,t,u # is taken as the fundamental frequency. # # CONSTANTS # # debug mode #set DEBUG = "echo" set DEBUG = "" # remote machine # tentative---in case no machine is specified set next_machine = cmn6 # and revise it ifmachine name is given as well if ($#argv == 2) then set next_machine = $1 shift endif set work_file = wave2lisp_work$$.snd set filename = $1:t set filebody = $filename:r # # CHECK THE OS ENVIRONMENT # if ! ( $OSTYPE == "linux" ) then echo "this is for linux only." exit 1; endif # # HELP # if ($#argv == 0) then echo "wave2lisp: wavedata to .sms and .lisp file conversion" echo "USAGE EXAMPLE:" echo " % wave2lisp [machine] abc/filename.aiff" echo "It will work on abc/xyz.aiff (or xyz.aif, xyz.snd)." echo "Temp-files and the results, xyz.{sms,lisp} will be at the working directory. " echo " " echo "NOTE:" echo " 1. analysis parameter is chosen based on the character after the first one of [chtu]" echo " in the input file --- c,g,d,a." echo " 2. You can give the fullpaths as the argument, but the results" echo " are stored in the working directory." echo " 3. if you give 2 args, the first arg is used as the remote machine name." exit 1 endif # # prepare $work_file in the home directory # # if target is aiff, or aif, convert it to snd by sox. # if target is snd, just make a link. # otherwise give up. # # if ( -e ~/$work_file ) then # echo "We already have ~/$work_file : Do you want to use it (y)?" # echo "(otherwise it is erased and a new one is generated)" # set ans = $< # switch ($ans) # case "yY" : # goto label_sms_anal # endsw #endif if ( $1:e == "aiff" || $1:e == "aif" ) then echo "converting $1 to ~/$work_file..." $DEBUG sox -t .aiff $1 -t .au -c 1 ~/$work_file echo "done." else if ( $1:e == "snd" ) then ln -s $1 ~/$work_file > /dev/null # in case they are identical, that's fine. else echo "file extension is neither aiff nor snd" exit 1 endif endif label_sms_anal: # # start smsAnal on remote machine, according to the file type: # the second character of the filename is checked to determine # which parameter set should be used # set filetype = `echo $filebody | gawk '{sub(/^[^chtu]*[chtu]/,"");print substr($0,0,1);}'` echo "doing smsAnal with parameters for filetype = $filetype = ..." echo "(This takes tens of minutes)" switch ( $filetype ) case 'c' : $DEBUG rsh $next_machine smsAnal \ -format 3 -stype 0 -direct 0 -rate 120 \ -swin 3.5 -twin 2 -lfreq 0 -hfreq 12000 -magt 0.3 \ -dfund 131 -lfund 117 -hfund 147 -maxe 20 \ -freqd 0.45 -peakc 0.2 -fundc 1.0 -npart 60 \ -clean 1 -minl 0.1 -maxs 0.1 -stoc 1 \ -ncoeff 25 $work_file $filebody.sms breaksw case 'g' : $DEBUG rsh $next_machine smsAnal \ -format 3 -stype 0 -direct 0 -rate 120 \ -swin 3.5 -twin 2 -lfreq 0 -hfreq 12000 -magt 0.3 \ -dfund 196 -lfund 175 -hfund 220 -maxe 20 \ -freqd 0.45 -peakc 0.2 -fundc 1.0 -npart 60 \ -clean 1 -minl 0.1 -maxs 0.1 -stoc 1 \ -ncoeff 25 $work_file $filebody.sms breaksw case 'd' : $DEBUG rsh $next_machine smsAnal \ -format 3 -stype 0 -direct 0 -rate 120 \ -swin 3.5 -twin 2 -lfreq 0 -hfreq 12000 -magt 0.3 \ -dfund 293 -lfund 261 -hfund 329 -maxe 20 \ -freqd 0.45 -peakc 0.2 -fundc 1.0 -npart 60 \ -clean 1 -minl 0.1 -maxs 0.1 -stoc 1 \ -ncoeff 25 $work_file $filebody.sms breaksw case 'a' : $DEBUG rsh $next_machine smsAnal \ -format 3 -stype 0 -direct 0 -rate 120 \ -swin 3.5 -twin 2 -lfreq 0 -hfreq 12000 -magt 0.3 \ -dfund 440 -lfund 392 -hfund 494 -maxe 20 \ -freqd 0.45 -peakc 0.2 -fundc 1.0 -npart 60 \ -clean 1 -minl 0.1 -maxs 0.1 -stoc 1 \ -ncoeff 25 $work_file $filebody.sms breaksw default : echo "the second character of the file name is not proper (other than c,g,d,a)" exit 1 endsw # # convert the .sms file to .lisp file (all at home dir) # $DEBUG rsh $next_machine '~/ATS/smsToATS' $filebody.sms $filebody.lisp $filebody # # bring both .sms and .lisp into the current directory # $DEBUG mv ~/$filebody.{lisp,sms} . # # cleaning up # echo "want to clear working .snd file? (y/n)" set ans = $< switch ($ans) case "yY" : $DEBUG rm ~/$workfile breaksw endsw exit 0