NoSloppy

SoundFontConverter

Oct 27th, 2021 (edited)
818
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Bash 69.08 KB | None | 0 0
  1. #!/bin/sh
  2.     shopt -s extglob
  3.     IFS=$'\n'
  4.  
  5.     echo "Hello, welcome to the Soundfont converter."
  6.     echo "To convert a soundfont from CFX to Proffie, enter 'CtoP'"
  7.     echo "To convert a soundfont from CFX to Xenopixel, enter 'CtoX'"
  8.     echo "To convert a soundfont from Proffie to CFX, enter 'PtoC'"
  9.     echo "To convert a soundfont from Proffie to Xenopixel, enter 'PtoX'"
  10.     echo "To convert a soundfont from Xenopixel to CFX, enter 'XtoC'"
  11.     echo "To convert a soundfont from Xenopixel to Proffie, enter 'XtoP'"
  12.     echo "To rename a Proffie soundfont for ideal performance, enter 'PtoP'"
  13.  
  14.  
  15.  
  16.     read boardchoice
  17.  
  18. if [ "$boardchoice" = "CtoP" ]; then
  19.     echo "You chose CFX to Proffie Soundfont converter."
  20.     echo "Do you wish to convert a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  21.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  22.  
  23.     read selection
  24.  
  25.     if [ "$selection" = "1" ]; then
  26.         echo "You chose to convert a single soundfont. Please enter the name of the font folder containting the soundfont files."
  27.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  28.        
  29.         read input
  30.         dirs=$(find "$input" -maxdepth 0 -type d)
  31.        
  32.         echo "Found the following soundfont folder:"
  33.         echo $dirs
  34.         echo "Does this folder only contain one soundfont? (y/n)"
  35.        
  36.         read input2
  37.  
  38.         if [ "$input2" = "y" ]; then
  39.             echo "Continuing conversion"
  40.         else
  41.             echo "Aborting program"
  42.             exit
  43.         fi
  44.        
  45.     elif [ "$selection" = "2" ]; then
  46.         echo "You chose to convert several soundfonts. Each soundfont must be in a single subfolder."
  47.         echo "Please enter the name of the folder containing the soundfont folders."
  48.        
  49.         read input
  50.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  51.        
  52.         echo "Found the following directories for soundfonts:"
  53.         echo $dirs
  54.         echo "Does each of these folders only contain one soundfont? (y/n)"
  55.  
  56.         read input2
  57.  
  58.         if [ "$input2" = "y" ]; then
  59.             echo "Continuing conversion"
  60.         else
  61.             echo "Aborting program"
  62.             exit
  63.         fi
  64.        
  65.     else
  66.         echo "Your selection is invalid. Aborting program"
  67.         exit
  68.     fi
  69.  
  70.     echo "Do you wish a detailed conversion progess report ('1') or only the imporant steps ('2')?"
  71.     echo "Warning, the detailed report will produce a lot of console output!"
  72.  
  73.     read verbosity
  74.  
  75.     if [ "$verbosity" = "1" ]; then
  76.         echo "Logging progress to console"
  77.     else
  78.         echo "Logging only important steps"
  79.     fi
  80.  
  81.     for dir in ${dirs[@]}; do
  82.            
  83.         sounds=$(find "$dir" -type f -name '*.wav')
  84.  
  85.         echo Converting soundfont in "${dir}".
  86.  
  87.         targetpath="Converted_to_Proffie"
  88.         mkdir -p "${targetpath}"
  89.         mkdir -p "${targetpath}/${dir}/bgndrag"
  90.         mkdir -p "${targetpath}/${dir}/bgnlb"
  91.         mkdir -p "${targetpath}/${dir}/bgnlock"
  92.         mkdir -p "${targetpath}/${dir}/bgnmelt"
  93.         #mkdir -p "${targetpath}/${dir}/blst"
  94.         #mkdir -p "${targetpath}/${dir}/boot"
  95.         mkdir -p "${targetpath}/${dir}/clsh"
  96.         mkdir -p "${targetpath}/${dir}/ccchange"
  97.         mkdir -p "${targetpath}/${dir}/drag"
  98.         mkdir -p "${targetpath}/${dir}/enddrag"
  99.         mkdir -p "${targetpath}/${dir}/endlb"
  100.         mkdir -p "${targetpath}/${dir}/endlock"
  101.         mkdir -p "${targetpath}/${dir}/font"
  102.         mkdir -p "${targetpath}/${dir}/force"
  103.         mkdir -p "${targetpath}/${dir}/hum"
  104.         mkdir -p "${targetpath}/${dir}/in"
  105.         mkdir -p "${targetpath}/${dir}/lb"
  106.         mkdir -p "${targetpath}/${dir}/lock"
  107.         mkdir -p "${targetpath}/${dir}/melt"
  108.         mkdir -p "${targetpath}/${dir}/out"
  109.         mkdir -p "${targetpath}/${dir}/preon"
  110.         mkdir -p "${targetpath}/${dir}/pstoff"
  111.         mkdir -p "${targetpath}/${dir}/slsh"
  112.         mkdir -p "${targetpath}/${dir}/spin"
  113.         mkdir -p "${targetpath}/${dir}/stab"
  114.         mkdir -p "${targetpath}/${dir}/swingh"
  115.         mkdir -p "${targetpath}/${dir}/swingl"
  116.         mkdir -p "${targetpath}/${dir}/swng"
  117.         mkdir -p "${targetpath}/${dir}/tracks"
  118.  
  119.         blastercounter=1
  120.         bootcounter=1
  121.         clashcounter=1
  122.         colorcounter=1
  123.         dragcounter=1
  124.         enddragcounter=1
  125.         endlockcounter=1
  126.         fontcounter=1
  127.         forcecounter=1
  128.         hswingcounter=1
  129.         humcounter=1
  130.         lockupcounter=1
  131.         lswingcounter=1
  132.         poweroffcounter=1
  133.         poweroncounter=1
  134.         preoncounter=1
  135.         spincounter=1
  136.         stabcounter=1
  137.         startdragcounter=1
  138.         startlockcounter=1
  139.         swingcounter=1
  140.         trackcounter=1
  141.        
  142.         for src in ${sounds[@]}; do
  143.             case "${src##*/}" in
  144.  
  145.                 blaster*([0-9]).wav)
  146.                 if [ $blastercounter = 2 ]; then
  147.                     mkdir -p "${targetpath}/${dir}/blst"
  148.                     mv "${target}" "./${targetpath}/${dir}/blst/${targetfile}"
  149.                     echo "Moving ${targetfile} into ${dir}/blst subfolder"
  150.                 fi
  151.                 if [ "$blastercounter" -lt 10 ]; then
  152.                     targetfile=$(printf %q "blst0$blastercounter.wav") 
  153.                 else
  154.                     targetfile=$(printf %q "blst$blastercounter.wav")
  155.                 fi
  156.                 if [ $blastercounter -ge 2 ]; then
  157.                     target="./${targetpath}/${dir}/blst/${targetfile}"
  158.                 else
  159.                     target="./${targetpath}/${dir}/${targetfile}"
  160.                 fi
  161.                 if [ "$verbosity" = "1" ]; then
  162.                     echo "Converting ${src} to ${target}"
  163.                 fi
  164.                 rsync -ab "${src}" "${target}"
  165.                 blastercounter=$((blastercounter+1))
  166.                 ;;
  167.  
  168.                 boot*([0-9]).wav)
  169.                 if [ $bootcounter = 2 ]; then
  170.                     mkdir -p "${targetpath}/${dir}/boot"
  171.                     mv "${target}" "./${targetpath}/${dir}/boot/${targetfile}"
  172.                     echo "Moving ${targetfile} into ${dir}/boot subfolder"
  173.                 fi
  174.                 if [ "$bootcounter" -lt 10 ]; then
  175.                     targetfile=$(printf %q "boot0$bootcounter.wav")
  176.                 else
  177.                     targetfile=$(printf %q "boot$bootcounter.wav")
  178.                 fi
  179.                 if [ $bootcounter -ge 2 ]; then
  180.                     target="./${targetpath}/${dir}/boot/${targetfile}"
  181.                 else
  182.                     target="./${targetpath}/${dir}/${targetfile}"
  183.                 fi
  184.                 if [ "$verbosity" = "1" ]; then
  185.                     echo "Converting ${src} to ${target}"
  186.                 fi
  187.                 rsync -ab "${src}" "${target}"
  188.                 bootcounter=$((bootcounter+1))
  189.                 ;;
  190.  
  191.                 boot*([0-9]).wav)
  192.                 if [ "$bootcounter" -lt 10 ]; then
  193.                     targetfile=$(printf %q "boot0$bootcounter.wav")
  194.                 else
  195.                     targetfile=$(printf %q "boot$bootcounter.wav")
  196.                 fi
  197.                 bootcounter=$((bootcounter+1))
  198.                 target="./$targetpath/${dir}/boot/$targetfile"
  199.                 if [ "$verbosity" = "1" ]; then
  200.                     echo "Converting ${src} to ${target}"
  201.                 fi
  202.                 rsync -ab "${src}" "${target}"
  203.                 ;;
  204.                
  205.                 clash*([0-9]).wav)
  206.                 if [ "$clashcounter" -lt 10 ]; then
  207.                     targetfile=$(printf %q "clsh0$clashcounter.wav")   
  208.                 else
  209.                     targetfile=$(printf %q "clsh$clashcounter.wav")
  210.                 fi
  211.                 clashcounter=$((clashcounter+1))
  212.                 target="./$targetpath/${dir}/clsh/$targetfile"
  213.                 if [ "$verbosity" = "1" ]; then
  214.                     echo "Converting ${src} to ${target}"
  215.                 fi
  216.                 rsync -ab "${src}" "${target}"
  217.                 ;;
  218.                
  219.                 color*([0-9]).wav)
  220.                 targetfile=$(printf %q "ccchage$colorcounter.wav")
  221.                 colorcounter=$((colorcounter+1))
  222.                 target="./$targetpath/${dir}/ccchange/$targetfile"
  223.                 if [ "$verbosity" = "1" ]; then
  224.                     echo "Converting ${src} to ${target}"
  225.                 fi
  226.                 rsync -ab "${src}" "${target}"
  227.                 ;;
  228.                
  229.                 drag*([0-9]).wav)
  230.                 if [ "$dragcounter" -lt 10 ]; then
  231.                     targetfile=$(printf %q "drag0$dragcounter.wav")
  232.                 else
  233.                     targetfile=$(printf %q "drag$dragcounter.wav")
  234.                 fi
  235.                 dragcounter=$((dragcounter+1))
  236.                 target="./$targetpath/${dir}/drag/$targetfile"
  237.                 if [ "$verbosity" = "1" ]; then
  238.                     echo "Converting ${src} to ${target}"
  239.                 fi
  240.                 rsync -ab "${src}" "${target}"
  241.                 ;;
  242.                
  243.                 enddrag*([0-9]).wav)
  244.                 targetfile=$(printf %q "enddrag$enddragcounter.wav")
  245.                 enddragcounter=$((enddragcounter+1))
  246.                 target="./$targetpath/${dir}/enddrag/$targetfile"
  247.                 if [ "$verbosity" = "1" ]; then
  248.                     echo "Converting ${src} to ${target}"
  249.                 fi
  250.                 rsync -ab "${src}" "${target}"
  251.                 ;;
  252.  
  253.                 endlock*([0-9]).wav)
  254.                 targetfile=$(printf %q "endlock$endlockcounter.wav")
  255.                 endlockcounter=$((endlockcounter+1))
  256.                 target="./$targetpath/${dir}/endlock/$targetfile"
  257.                 if [ "$verbosity" = "1" ]; then
  258.                     echo "Converting ${src} to ${target}"
  259.                 fi
  260.                 rsync -ab "${src}" "${target}"
  261.                 ;;
  262.                
  263.                 font*([0-9]).wav)
  264.                 if [ "$fontcounter" -lt 10 ]; then
  265.                     targetfile=$(printf %q "font0$fontcounter.wav")
  266.                 else
  267.                     targetfile=$(printf %q "font$fontcounter.wav")
  268.                 fi
  269.                 fontcounter=$((fontcounter+1))
  270.                 target="./$targetpath/${dir}/font/$targetfile"
  271.                 if [ "$verbosity" = "1" ]; then
  272.                     echo "Converting ${src} to ${target}"
  273.                 fi
  274.                 rsync -ab "${src}" "${target}"
  275.                 ;;
  276.                
  277.                 force*|combo*([0-9]).wav)
  278.                 if [ "$forcecounter" -lt 10 ]; then
  279.                     targetfile=$(printf %q "force0$forcecounter.wav")  
  280.                 else
  281.                     targetfile=$(printf %q "force$forcecounter.wav")
  282.                 fi
  283.                 forcecounter=$((forcecounter+1))
  284.                 target="./$targetpath/${dir}/force/$targetfile"
  285.                 if [ "$verbosity" = "1" ]; then
  286.                     echo "Converting ${src} to ${target}"
  287.                 fi
  288.                 rsync -ab "${src}" "${target}"
  289.                 ;;
  290.                
  291.                 hswing*([0-9]).wav)
  292.                 if [ "$hswingcounter" -lt 10 ]; then
  293.                     targetfile=$(printf %q "swingh0$hswingcounter.wav")
  294.                 else
  295.                     targetfile=$(printf %q "swingh$hswingcounter.wav")
  296.                 fi
  297.                 hswingcounter=$((hswingcounter+1))
  298.                 target="./$targetpath/${dir}/swingh/$targetfile"
  299.                 if [ "$verbosity" = "1" ]; then
  300.                     echo "Converting ${src} to ${target}"
  301.                 fi
  302.                 rsync -ab "${src}" "${target}"
  303.                 ;;
  304.  
  305.                 hum**([0-9]).wav)
  306.                 if [ "$humcounter" -lt 10 ]; then
  307.                     targetfile=$(printf %q "hum0$humcounter.wav")  
  308.                 else
  309.                     targetfile=$(printf %q "hum$humcounter.wav")
  310.                 fi
  311.                 humcounter=$((humcounter+1))
  312.                 target="./$targetpath/${dir}/hum/$targetfile"
  313.                 if [ "$verbosity" = "1" ]; then
  314.                     echo "Converting ${src} to ${target}"
  315.                 fi
  316.                 rsync -ab "${src}" "${target}"
  317.                 ;;             
  318.  
  319.                 lswing*([0-9]).wav)
  320.                 if [ "$lswingcounter" -lt 10 ]; then
  321.                     targetfile=$(printf %q "swingl0$lswingcounter.wav")
  322.                 else
  323.                     targetfile=$(printf %q "swingl$lswingcounter.wav")
  324.                 fi
  325.                 lswingcounter=$((lswingcounter+1))
  326.                 target="./$targetpath/${dir}/swingl/$targetfile"
  327.                 if [ "$verbosity" = "1" ]; then
  328.                     echo "Converting ${src} to ${target}"
  329.                 fi
  330.                 rsync -ab "${src}" "${target}"
  331.                 ;;
  332.  
  333.                 lock**([0-9]).wav)
  334.                 if [ "$lockupcounter" -lt 10 ]; then
  335.                     targetfile=$(printf %q "lock0$lockupcounter.wav")  
  336.                 else
  337.                     targetfile=$(printf %q "lock$lockupcounter.wav")
  338.                 fi
  339.                 lockupcounter=$((lockupcounter+1))
  340.                 target="./$targetpath/${dir}/lock/$targetfile"
  341.                 if [ "$verbosity" = "1" ]; then
  342.                     echo "Converting ${src} to ${target}"
  343.                 fi
  344.                 rsync -ab "${src}" "${target}"
  345.                 ;;
  346.  
  347.                 poweroff*|pwroff*([0-9]).wav)
  348.                 if [ "$poweroffcounter" -lt 10 ]; then
  349.                     targetfile=$(printf %q "in0$poweroffcounter.wav")  
  350.                 else
  351.                     targetfile=$(printf %q "in$poweroffcounter.wav")
  352.                 fi
  353.                 poweroffcounter=$((poweroffcounter+1))
  354.                 target="./$targetpath/${dir}/in/$targetfile"
  355.                 if [ "$verbosity" = "1" ]; then
  356.                     echo "Converting ${src} to ${target}"
  357.                 fi
  358.                 rsync -ab "${src}" "${target}"
  359.                 ;;
  360.  
  361.                 poweron**([0-9]).wav)
  362.                 if [ "$poweroncounter" -lt 10 ]; then
  363.                     targetfile=$(printf %q "out0$poweroncounter.wav")  
  364.                 else
  365.                     targetfile=$(printf %q "out$poweroncounter.wav")
  366.                 fi
  367.                 poweroncounter=$((poweroncounter+1))
  368.                 target="./$targetpath/${dir}/out/$targetfile"
  369.                 if [ "$verbosity" = "1" ]; then
  370.                     echo "Converting ${src} to ${target}"
  371.                 fi
  372.                 rsync -ab "${src}" "${target}"
  373.                 ;;
  374.  
  375.                 preon*([0-9]).wav)
  376.                 if [ "$preoncounter" -lt 10 ]; then
  377.                     targetfile=$(printf %q "preon0$preoncounter.wav")  
  378.                 else
  379.                     targetfile=$(printf %q "preon$preoncounter.wav")
  380.                 fi
  381.                 preoncounter=$((preoncounter+1))
  382.                 target="./${targetpath}/${dir}/preon/${targetfile}"
  383.                 if [ "$verbosity" = "1" ]; then
  384.                     echo "Converting ${src} to ${target}"
  385.                 fi
  386.                 rsync -ab "${src}" "${target}"
  387.                 ;;
  388.  
  389.                 spin*([0-9]).wav)
  390.                 if [ "$spincounter" -lt 10 ]; then
  391.                     targetfile=$(printf %q "spin0$spincounter.wav")
  392.                 else
  393.                     targetfile=$(printf %q "spin$spincounter.wav")
  394.                 fi
  395.                 spincounter=$((spincounter+1))
  396.                 target="./$targetpath/${dir}/spin/$targetfile"
  397.                 if [ "$verbosity" = "1" ]; then
  398.                     echo "Converting ${src} to ${target}"
  399.                 fi
  400.                 rsync -ab "${src}" "${target}"
  401.                 ;;         
  402.  
  403.                 stab*([0-9]).wav)
  404.                 if [ "$stabcounter" -lt 10 ]; then
  405.                     targetfile=$(printf %q "stab0$stabcounter.wav")
  406.                 else
  407.                     targetfile=$(printf %q "stab$stabcounter.wav")
  408.                 fi
  409.                 stabcounter=$((stabcounter+1))
  410.                 target="./$targetpath/${dir}/stab/$targetfile"
  411.                 if [ "$verbosity" = "1" ]; then
  412.                     echo "Converting ${src} to ${target}"
  413.                 fi
  414.                 rsync -ab "${src}" "${target}"
  415.                 ;;
  416.  
  417.                 startdrag*([0-9]).wav)
  418.                 targetfile=$(printf %q "bgndrag$startdragcounter.wav")
  419.                 startdragcounter=$((startdragcounter+1))
  420.                 target="./$targetpath/${dir}/bgndrag/$targetfile"
  421.                 if [ "$verbosity" = "1" ]; then
  422.                     echo "Converting ${src} to ${target}"
  423.                 fi
  424.                 rsync -ab "${src}" "${target}"
  425.                 ;;
  426.  
  427.                 startlock*([0-9]).wav)
  428.                 targetfile=$(printf %q "bgnlock$startlockcounter.wav")
  429.                 startlockcounter=$((startlockcounter+1))
  430.                 target="./$targetpath/${dir}/bgnlock/$targetfile"
  431.                 if [ "$verbosity" = "1" ]; then
  432.                     echo "Converting ${src} to ${target}"
  433.                 fi
  434.                 rsync -ab "${src}" "${target}"
  435.                 ;;
  436.  
  437.                 swing*([0-9]).wav)
  438.                 if [ "$swingcounter" -lt 10 ]; then
  439.                     targetfile=$(printf %q "swng0$swingcounter.wav")   
  440.                 else
  441.                     targetfile=$(printf %q "swng$swingcounter.wav")
  442.                 fi
  443.                 swingcounter=$((swingcounter+1))
  444.                 target="./$targetpath/${dir}/swng/$targetfile"
  445.                 if [ "$verbosity" = "1" ]; then
  446.                     echo "Converting ${src} to ${target}"
  447.                 fi
  448.                 rsync -ab "${src}" "${target}"
  449.                 ;;
  450.                
  451.                 track*([0-9]).wav)
  452.                 if [ "$trackcounter" -lt 10 ]; then
  453.                     targetfile=$(printf %q "track0$trackcounter.wav")  
  454.                 else
  455.                     targetfile=$(printf %q "track$trackcounter.wav")
  456.                 fi
  457.                 trackcounter=$((trackcounter+1))
  458.                 target="./$targetpath/${dir}/tracks/$targetfile"
  459.                 if [ "$verbosity" = "1" ]; then
  460.                     echo "Converting ${src} to ${target}"
  461.                 fi
  462.                 rsync -ab "${src}" "${target}"
  463.                 ;;
  464.                
  465.                 *)
  466.                 echo "No match found, ignoring file $src"
  467.  
  468.             esac
  469.         done
  470.  
  471.         echo Coverted soundfont saved in "${targetpath}"
  472.     done
  473.  
  474.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  475.     echo "before the conversion and was renamed to avoid accidental overwriting."
  476.     echo " "
  477.  
  478. #-------------------------------------------------------------------------------------------------------------------------------------
  479.  
  480. elif [ "$boardchoice" = "CtoX" ]; then
  481.     echo "You chose CFX to Xenopixel Soundfont converter."
  482.     echo "Do you wish to convert a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  483.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  484.  
  485.     read selection
  486.  
  487.     if [ "$selection" = "1" ]; then
  488.         echo "You chose to convert a single soundfont. Please enter the name of the font folder containting the soundfont files."
  489.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  490.        
  491.         read input
  492.         dirs=$(find "$input" -maxdepth 0 -type d)
  493.        
  494.         echo "Found the following soundfont folder:"
  495.         echo $dirs
  496.         echo "Does this folder only contain one soundfont? (y/n)"
  497.        
  498.         read input2
  499.  
  500.         if [ "$input2" = "y" ]; then
  501.             echo "Continuing conversion"
  502.         else
  503.             echo "Aborting program"
  504.             exit
  505.         fi
  506.        
  507.     elif [ "$selection" = "2" ]; then
  508.         echo "You chose to convert several soundfonts. Each soundfont must be in a single subfolder."
  509.         echo "Please enter the name of the folder containing the soundfont folders."
  510.        
  511.         read input
  512.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  513.        
  514.         echo "Found the following directories for soundfonts:"
  515.         echo $dirs
  516.         echo "Does each of these folders only contain one soundfont? (y/n)"
  517.  
  518.         read input2
  519.  
  520.         if [ "$input2" = "y" ]; then
  521.             echo "Continuing conversion"
  522.         else
  523.             echo "Aborting program"
  524.             exit
  525.         fi
  526.        
  527.     else
  528.         echo "Your selection is invalid. Aborting program"
  529.         exit
  530.     fi
  531.  
  532.     echo "Do you wish a detailed conversion progess report ('1') or only the imporant steps ('2')?"
  533.     echo "Warning, the detailed report will produce a lot of console output!"
  534.  
  535.     read verbosity
  536.  
  537.     if [ "$verbosity" = "1" ]; then
  538.         echo "Logging progress to console"
  539.     else
  540.         echo "Logging only important steps"
  541.     fi
  542.  
  543.     for dir in ${dirs[@]}; do
  544.            
  545.         sounds=$(find "$dir" -type f -name '*.wav')
  546.  
  547.         echo Converting soundfont in "${dir}".
  548.  
  549.         targetpath="Converted_to_Xenopixel"
  550.         mkdir -p "${targetpath}"
  551.         mkdir -p "${targetpath}/${dir}/set"
  552.         mkdir -p "${targetpath}/${dir}/tracks"
  553.         blastercounter=1
  554.         bootcounter=1
  555.         clashcounter=1
  556.         # colorcounter=1
  557.         dragcounter=1
  558.         # endlockcounter=1
  559.         fontcounter=1
  560.         forcecounter=1
  561.         hswingcounter=1
  562.         humcounter=1
  563.         lswingcounter=1
  564.         poweroffcounter=1
  565.         poweroncounter=1
  566.         lockcounter=1
  567.         lockupcounter=1
  568.         preoncounter=1
  569.         # spincounter=1
  570.         # stabcounter=1
  571.         # swingcounter=1
  572.         trackcounter=1
  573.  
  574.         for src in ${sounds[@]}; do
  575.             case "${src##*/}" in
  576.  
  577.             blaster*([0-9]).wav)
  578.             targetfile="blaster ($blastercounter).wav"
  579.             blastercounter=$((blastercounter+1))
  580.             target="./${targetpath}/${dir}/${targetfile}"
  581.             if [ "$verbosity" = "1" ]; then
  582.                 echo "Converting ${src} to ${target}"
  583.             fi
  584.             rsync -ab "${src}" "${target}"
  585.             ;;
  586.            
  587.     # boot sounds are converted to 'power on.wav and live in the 'set' folder.
  588.     # If there are more than one converted, the last one will be the resulting file.
  589.             boot*([0-9]).wav)
  590.             targetfile="power on.wav"
  591.             bootcounter=$((bootcounter+1))
  592.             target="./$targetpath/${dir}/set/$targetfile"
  593.             if [ "$verbosity" = "1" ]; then
  594.                 echo "Converting ${src} to ${target}"
  595.             fi
  596.             rsync -ab "${src}" "${target}"
  597.             ;;
  598.            
  599.             clash*([0-9]).wav)
  600.             targetfile="clash ($clashcounter).wav"
  601.             clashcounter=$((clashcounter+1))
  602.             target="./$targetpath//${dir}/$targetfile"
  603.             if [ "$verbosity" = "1" ]; then
  604.                 echo "Converting ${src} to ${target}"
  605.             fi
  606.             rsync -ab "${src}" "${target}"
  607.             ;;
  608.            
  609.     # color sounds are currently not supported by Xenopixel and therefore ignored.
  610.     # Uncomment counter above and code here and adapt targetfile if needed later.          
  611.     #       color*([0-9]).wav)
  612.     #       targetfile="color ($colorcounter).wav"
  613.     #       colorcounter=$((colorcounter+1))
  614.     #       target="./${targetpath}/${dir}/${targetfile}"
  615.     #       if [ "$verbosity" = "1" ]; then
  616.     #           echo "Converting ${src} to ${target}"
  617.     #       fi
  618.     #       rsync -ab "${src}" "${target}"
  619.     #       ;;
  620.            
  621.             drag*([0-9]).wav)
  622.             targetfile="drag ($dragcounter).wav"
  623.             dragcounter=$((dragcounter+1))
  624.             target="./$targetpath//${dir}/$targetfile"
  625.             if [ "$verbosity" = "1" ]; then
  626.                 echo "Converting ${src} to ${target}"
  627.             fi
  628.             rsync -ab "${src}" "${target}"
  629.             ;;
  630.            
  631.     # endlock sounds are currently not supported by Xenopixel and therefore ignored.
  632.     # Uncomment counter above and code here and adapt targetfile if needed later.  
  633.     #       endlock*([0-9]).wav)
  634.     #       targetfile="endlock ($endlockcounter).wav"
  635.     #       endlockcounter=$((endlockcounter+1))
  636.     #       target="./${targetpath}/${dir}/${targetfile}"
  637.     #       if [ "$verbosity" = "1" ]; then
  638.     #           echo "Converting ${src} to ${target}"
  639.     #       fi
  640.     #       rsync -ab "${src}" "${target}"
  641.     #       ;;
  642.            
  643.             font*([0-9]).wav)
  644.             targetfile="font ($fontcounter).wav"
  645.             fontcounter=$((fontcounter+1))
  646.             target="./$targetpath//${dir}/$targetfile"
  647.             if [ "$verbosity" = "1" ]; then
  648.                 echo "Converting ${src} to ${target}"
  649.             fi
  650.             rsync -ab "${src}" "${target}"
  651.             ;;
  652.            
  653.             force*|combo*([0-9]).wav)
  654.             targetfile="force ($forcecounter).wav"
  655.             forcecounter=$((forcecounter+1))
  656.             target="./$targetpath//${dir}/$targetfile"
  657.             if [ "$verbosity" = "1" ]; then
  658.                 echo "Converting ${src} to ${target}"
  659.             fi
  660.             rsync -ab "${src}" "${target}"
  661.             ;;
  662.            
  663.             hum*|humM*([0-9]).wav)
  664.             targetfile="hum ($humcounter).wav"
  665.             humcounter=$((humcounter+1))
  666.             target="./$targetpath//${dir}/$targetfile"
  667.             if [ "$verbosity" = "1" ]; then
  668.                 echo "Converting ${src} to ${target}"
  669.             fi
  670.             rsync -ab "${src}" "${target}"
  671.             ;;
  672.            
  673.             poweroff*|pwroff*([0-9]).wav)
  674.             targetfile="in ($poweroffcounter).wav"
  675.             poweroffcounter=$((poweroffcounter+1))
  676.             target="./$targetpath//${dir}/$targetfile"
  677.             if [ "$verbosity" = "1" ]; then
  678.                 echo "Converting ${src} to ${target}"
  679.             fi
  680.             rsync -ab "${src}" "${target}"
  681.             ;;
  682.            
  683.             lock**([0-9]).wav)
  684.             targetfile="lock ($lockcounter).wav"
  685.             lockcounter=$((lockcounter+1))
  686.             target="./$targetpath//${dir}/$targetfile"
  687.             if [ "$verbosity" = "1" ]; then
  688.                 echo "Converting ${src} to ${target}"
  689.             fi
  690.             rsync -ab "${src}" "${target}"
  691.             ;;
  692.            
  693.             poweron**([0-9]).wav)
  694.             targetfile="out ($poweroncounter).wav"
  695.             poweroncounter=$((poweroncounter+1))
  696.             target="./$targetpath//${dir}/$targetfile"
  697.             if [ "$verbosity" = "1" ]; then
  698.                 echo "Converting ${src} to ${target}"
  699.             fi
  700.             rsync -ab "${src}" "${target}"
  701.             ;;
  702.  
  703.             hswing*([0-9]).wav)
  704.             targetfile="hswing ($hswingcounter).wav"
  705.             hswingcounter=$((hswingcounter+1))
  706.             target="./$targetpath//${dir}/$targetfile"
  707.             if [ "$verbosity" = "1" ]; then
  708.                 echo "Converting ${src} to ${target}"
  709.             fi
  710.             rsync -ab "${src}" "${target}"
  711.             ;;
  712.            
  713.             lswing*([0-9]).wav)
  714.             targetfile="lswing ($lswingcounter).wav"
  715.             lswingcounter=$((lswingcounter+1))
  716.             target="./$targetpath//${dir}/$targetfile"
  717.             if [ "$verbosity" = "1" ]; then
  718.                 echo "Converting ${src} to ${target}"
  719.             fi
  720.             rsync -ab "${src}" "${target}"
  721.             ;;
  722.  
  723.             preon*([0-9]).wav)
  724.             targetfile="preon ($preoncounter).wav"
  725.             if [ "$preoncounter" -ge 5 ]; then
  726.                 preoncounter=1
  727.             else
  728.                 preoncounter=$((preoncounter+1))
  729.             fi
  730.             target="./$targetpath/$targetfile"
  731.             target="./$targetpath/${dir}/set/$targetfile"
  732.             if [ "$verbosity" = "1" ]; then
  733.                 echo "Converting ${src} to ${target}"
  734.             fi
  735.             rsync -ab "${src}" "${target}"
  736.             ;;
  737.  
  738.     # spin sounds are currently not supported by Xenopixel and therefore ignored.
  739.     # Uncomment counter above and code here and adapt targetfile if needed later.
  740.     #       spin*([0-9]).wav)
  741.     #       targetfile="spin ($spincounter).wav"
  742.     #       spincounter=$((spincounter+1))
  743.     #       target="./${targetpath}/${dir}/${targetfile}"
  744.     #       if [ "$verbosity" = "1" ]; then
  745.     #           echo "Converting ${src} to ${target}"
  746.     #       fi
  747.     #       rsync -ab "${src}" "${target}"
  748.     #       ;;     
  749.  
  750.     # stab sounds are currently not supported by Xenopixel and therefore ignored.
  751.     # Uncomment counter above and code here and adapt targetfile if needed later.
  752.     #       stab*([0-9]).wav)
  753.     #       targetfile="stab ($stabcounter).wav"
  754.     #       stabcounter=$((stabcounter+1))
  755.     #       target="./${targetpath}/${dir}/${targetfile}"
  756.     #       if [ "$verbosity" = "1" ]; then
  757.     #           echo "Converting ${src} to ${target}"
  758.     #       fi
  759.     #       rsync -ab "${src}" "${target}"
  760.     #       ;;
  761.  
  762.     # Accent Swings are currently not supported by Xenopixel and therefore ignored.
  763.     # Uncomment and adapt targetfile if needed later.      
  764.     #       swng*([0-9]).wav)
  765.     #       targetfile="swing ($swingcounter).wav"
  766.     #       swingcounter=$((swingcounter+1))
  767.     #       target="./${targetpath}/${dir}/${targetfile}"
  768.     #       if [ "$verbosity" = "1" ]; then
  769.     #           echo "Converting ${src} to ${target}"
  770.     #       fi
  771.     #       rsync -ab "${src}" "${target}"
  772.     #       ;;
  773.            
  774.             track*([0-9]).wav)
  775.             targetfile="track ($trackcounter).wav"
  776.             trackcounter=$((trackcounter+1))
  777.             target="./$targetpath/${dir}/tracks/$targetfile"
  778.             if [ "$verbosity" = "1" ]; then
  779.                 echo "Converting ${src} to ${target}"
  780.             fi
  781.             rsync -ab "${src}" "${target}"
  782.             ;;
  783.                
  784.                 *)
  785.                 echo "No match found, ignoring file $src"
  786.  
  787.             esac
  788.         done
  789.  
  790.         echo Coverted soundfont saved in "${targetpath}"
  791.     done
  792.  
  793.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  794.     echo "before the conversion and was renamed to avoid accidental overwriting."
  795.     echo " "
  796.  
  797. #-------------------------------------------------------------------------------------------------------------------------------------
  798.  
  799. elif [ "$boardchoice" = "PtoC" ]; then
  800.     echo "You chose Proffie to CFX Soundfont converter."
  801.     echo "Do you wish to convert a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  802.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  803.  
  804.     read selection
  805.  
  806.     if [ "$selection" = "1" ]; then
  807.         echo "You chose to convert a single soundfont. Please enter the name of the font folder containting the soundfont files."
  808.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  809.        
  810.         read input
  811.         dirs=$(find "$input" -maxdepth 0 -type d)
  812.        
  813.         echo "Found the following soundfont folder:"
  814.         echo $dirs
  815.         echo "Does this folder only contain one soundfont? (y/n)"
  816.        
  817.         read input2
  818.  
  819.         if [ "$input2" = "y" ]; then
  820.             echo "Continuing conversion"
  821.         else
  822.             echo "Aborting program"
  823.             exit
  824.         fi
  825.        
  826.     elif [ "$selection" = "2" ]; then
  827.         echo "You chose to convert several soundfonts. Each soundfont must be in a single subfolder."
  828.         echo "Please enter the name of the folder containing the soundfont folders."
  829.        
  830.         read input
  831.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  832.        
  833.         echo "Found the following directories for soundfonts:"
  834.         echo $dirs
  835.         echo "Does each of these folders only contain one soundfont? (y/n)"
  836.  
  837.         read input2
  838.  
  839.         if [ "$input2" = "y" ]; then
  840.             echo "Continuing conversion"
  841.         else
  842.             echo "Aborting program"
  843.             exit
  844.         fi
  845.        
  846.     else
  847.         echo "Your selection is invalid. Aborting program"
  848.         exit
  849.     fi
  850.  
  851.     echo "Do you wish a detailed conversion progess report ('1') or only the imporant steps ('2')?"
  852.     echo "Warning, the detailed report will produce a lot of console output!"
  853.  
  854.     read verbosity
  855.  
  856.     if [ "$verbosity" = "1" ]; then
  857.         echo "Logging progress to console"
  858.     else
  859.         echo "Logging only important steps"
  860.     fi
  861.  
  862.  
  863. for dir in ${dirs[@]}; do
  864.            
  865.         sounds=$(find "$dir" -type f -name '*.wav')
  866.  
  867.         echo Converting soundfont in "${dir}".
  868.  
  869.         targetpath="Converted_to_CFX/${dir}"
  870.         mkdir -p "${targetpath}"
  871.  
  872.         bgndragcounter=1
  873.         bgnlockcounter=1
  874.         blstcounter=1
  875.         bootcounter=1
  876.         clshcounter=1
  877.         ccchangecounter=1
  878.         dragcounter=1
  879.         enddragcounter=1
  880.         endlockcounter=1
  881.         fontcounter=1
  882.         forcecounter=1
  883.         humcounter=1
  884.         incounter=1
  885.         lockcounter=1
  886.         outcounter=1
  887.         preoncounter=1
  888.         spincounter=1
  889.         stabcounter=1
  890.         swinghcounter=1
  891.         swinglcounter=1
  892.         swngcounter=1
  893.         trackcounter=1
  894.  
  895.         for src in ${sounds[@]}; do
  896.             case "${src##*/}" in
  897.  
  898.                 bgndrag*([0-9]).wav)
  899.                 targetfile=$(printf %q "startdrag$bgndragcounter.wav")
  900.                 bgndragcounter=$((bgndragcounter+1))
  901.                 target="./${targetpath}/${targetfile}"
  902.                 if [ "$verbosity" = "1" ]; then
  903.                     echo "Converting ${src} to ${target}"
  904.                 fi
  905.                 rsync -ab "${src}" "${target}"
  906.                 ;;
  907.  
  908.                 bgnlock*([0-9]).wav)
  909.                 targetfile=$(printf %q "startlock$bgnlockcounter.wav")
  910.                 bgnlockcounter=$((bgnlockcounter+1))
  911.                 target="./${targetpath}/${targetfile}"
  912.                 if [ "$verbosity" = "1" ]; then
  913.                     echo "Converting ${src} to ${target}"
  914.                 fi
  915.                 rsync -ab "${src}" "${target}"
  916.                 ;;
  917.  
  918.                 blst*([0-9]).wav)
  919.                 if [ "$blstcounter" -eq 1 ]; then
  920.                     targetfile=$(printf %q "blaster.wav")  
  921.                 else
  922.                     targetfile=$(printf %q "blaster$blstcounter.wav")
  923.                 fi
  924.                 blstcounter=$((blstcounter+1))
  925.                 target="./${targetpath}/${targetfile}"
  926.                 if [ "$verbosity" = "1" ]; then
  927.                     echo "Converting ${src} to ${target}"
  928.                 fi
  929.                 rsync -ab "${src}" "${target}"
  930.                 ;;
  931.                
  932.                 boot*([0-9]).wav)
  933.                 if [ "$bootcounter" -eq 1 ]; then
  934.                     targetfile=$(printf %q "boot.wav") 
  935.                 else
  936.                     targetfile=$(printf %q "boot$bootcounter.wav")
  937.                 fi
  938.                 bootcounter=$((bootcounter+1))
  939.                 target="./$targetpath/$targetfile"
  940.                 if [ "$verbosity" = "1" ]; then
  941.                     echo "Converting ${src} to ${target}"
  942.                 fi
  943.                 rsync -ab "${src}" "${target}"
  944.                 ;;
  945.                
  946.                 clsh*([0-9]).wav)
  947.                 targetfile=$(printf %q "clash$clshcounter.wav")
  948.                 clshcounter=$((clshcounter+1))
  949.                 target="./$targetpath/$targetfile"
  950.                 if [ "$verbosity" = "1" ]; then
  951.                     echo "Converting ${src} to ${target}"
  952.                 fi
  953.                 rsync -ab "${src}" "${target}"
  954.                 ;;
  955.                
  956.                 ccchange*([0-9]).wav)
  957.                 if [ "$ccchangecounter" -eq 1 ]; then
  958.                     targetfile=$(printf %q "color.wav")
  959.                 else
  960.                     targetfile=$(printf %q "color$ccchangecounter.wav")
  961.                 fi
  962.                 ccchangecounter=$((ccchangecounter+1))
  963.                 target="./$targetpath/$targetfile"
  964.                 if [ "$verbosity" = "1" ]; then
  965.                     echo "Converting ${src} to ${target}"
  966.                 fi
  967.                 rsync -ab "${src}" "${target}"
  968.                 ;;
  969.                
  970.                 drag*([0-9]).wav)
  971.                 if [ "$dragcounter" -eq 1 ]; then
  972.                     targetfile=$(printf %q "drag.wav") 
  973.                 else
  974.                     targetfile=$(printf %q "drag$dragcounter.wav")
  975.                 fi
  976.                 dragcounter=$((dragcounter+1))
  977.                 target="./$targetpath/$targetfile"
  978.                 if [ "$verbosity" = "1" ]; then
  979.                     echo "Converting ${src} to ${target}"
  980.                 fi
  981.                 rsync -ab "${src}" "${target}"
  982.                 ;;
  983.  
  984.                 enddrag*([0-9]).wav)
  985.                 targetfile=$(printf %q "enddrag$enddragcounter.wav")
  986.                 enddragcounter=$((enddragcounter+1))
  987.                 target="./$targetpath/$targetfile"
  988.                 if [ "$verbosity" = "1" ]; then
  989.                     echo "Converting ${src} to ${target}"
  990.                 fi
  991.                 rsync -ab "${src}" "${target}"
  992.                 ;;
  993.  
  994.                 endlock*([0-9]).wav)
  995.                 targetfile=$(printf %q "endlock$endlockcounter.wav")
  996.                 endlockcounter=$((endlockcounter+1))
  997.                 target="./$targetpath/$targetfile"
  998.                 if [ "$verbosity" = "1" ]; then
  999.                     echo "Converting ${src} to ${target}"
  1000.                 fi
  1001.                 rsync -ab "${src}" "${target}"
  1002.                 ;;
  1003.                
  1004.                 font*([0-9]).wav)
  1005.                 if [ "$fontcounter" -eq 1 ]; then
  1006.                     targetfile=$(printf %q "font.wav") 
  1007.                 else
  1008.                     targetfile=$(printf %q "font$fontcounter.wav")
  1009.                 fi
  1010.                 fontcounter=$((fontcounter+1))
  1011.                 target="./$targetpath/$targetfile"
  1012.                 if [ "$verbosity" = "1" ]; then
  1013.                     echo "Converting ${src} to ${target}"
  1014.                 fi
  1015.                 rsync -ab "${src}" "${target}"
  1016.                 ;;
  1017.                
  1018.                 force*|quote*([0-9]).wav)
  1019.                 if [ "$forcecounter" -eq 1 ]; then
  1020.                     targetfile=$(printf %q "force.wav")
  1021.                 else
  1022.                     targetfile=$(printf %q "force$forcecounter.wav")
  1023.                 fi
  1024.                 forcecounter=$((forcecounter+1))
  1025.                 target="./$targetpath/$targetfile"
  1026.                 if [ "$verbosity" = "1" ]; then
  1027.                     echo "Converting ${src} to ${target}"
  1028.                 fi
  1029.                 rsync -ab "${src}" "${target}"
  1030.                 ;;
  1031.                
  1032.                 hum*([0-9]).wav)
  1033.                 targetfile=$(printf %q "humM$humcounter.wav")
  1034.                 humcounter=$((humcounter+1))
  1035.                 target="./$targetpath/$targetfile"
  1036.                 if [ "$verbosity" = "1" ]; then
  1037.                     echo "Converting ${src} to ${target}"
  1038.                 fi
  1039.                 rsync -ab "${src}" "${target}"
  1040.                 ;;
  1041.                
  1042.                 in*([0-9]).wav)
  1043.                 if [ "$incounter" -eq 1 ]; then
  1044.                     targetfile=$(printf %q "poweroff.wav") 
  1045.                 elif [ "$incounter" -eq 2 ]; then
  1046.                     targetfile=$(printf %q "pwroff$incounter.wav")
  1047.                 elif [ "$incounter" -ge 3 ]; then
  1048.                     targetfile=$(printf %q "poweroff$((incounter-1)).wav")
  1049.                 fi
  1050.                 incounter=$((incounter+1))
  1051.                 target="./$targetpath/$targetfile"
  1052.                 if [ "$verbosity" = "1" ]; then
  1053.                     echo "Converting ${src} to ${target}"
  1054.                 fi
  1055.                 rsync -ab "${src}" "${target}"
  1056.                 ;;
  1057.                
  1058.                 lock*([0-9]).wav)
  1059.                 if [ "$lockcounter" -eq 1 ]; then
  1060.                     targetfile=$(printf %q "lockup.wav")   
  1061.                 else
  1062.                     targetfile=$(printf %q "lockup$lockcounter.wav")
  1063.                 fi
  1064.                 lockcounter=$((lockcounter+1))
  1065.                 target="./$targetpath/$targetfile"
  1066.                 if [ "$verbosity" = "1" ]; then
  1067.                     echo "Converting ${src} to ${target}"
  1068.                 fi
  1069.                 rsync -ab "${src}" "${target}"
  1070.                 ;;
  1071.                
  1072.                 out*([0-9]).wav)
  1073.                 if [ "$outcounter" -eq 1 ]; then
  1074.                     targetfile=$(printf %q "poweron.wav")  
  1075.                 else
  1076.                     targetfile=$(printf %q "poweron$outcounter.wav")
  1077.                 fi
  1078.                 outcounter=$((outcounter+1))
  1079.                 target="./$targetpath/$targetfile"
  1080.                 if [ "$verbosity" = "1" ]; then
  1081.                     echo "Converting ${src} to ${target}"
  1082.                 fi
  1083.                 rsync -ab "${src}" "${target}"
  1084.                 ;;
  1085.  
  1086.                 preon*([0-9]).wav)
  1087.                 targetfile=$(printf %q "preon$preoncounter.wav")
  1088.                 preoncounter=$((preoncounter+1))
  1089.                 target="./$targetpath/$targetfile"
  1090.                 if [ "$verbosity" = "1" ]; then
  1091.                     echo "Converting ${src} to ${target}"
  1092.                 fi
  1093.                 rsync -ab "${src}" "${target}"
  1094.                 ;;
  1095.  
  1096.                 spin*([0-9]).wav)
  1097.                 targetfile=$(printf %q "spin$spincounter.wav")
  1098.                 spincounter=$((spincounter+1))
  1099.                 target="./$targetpath/$targetfile"
  1100.                 if [ "$verbosity" = "1" ]; then
  1101.                     echo "Converting ${src} to ${target}"
  1102.                 fi
  1103.                 rsync -ab "${src}" "${target}"
  1104.                 ;;
  1105.  
  1106.                 stab*([0-9]).wav)
  1107.                 targetfile=$(printf %q "stab$stabcounter.wav")
  1108.                 stabcounter=$((stabcounter+1))
  1109.                 target="./$targetpath/$targetfile"
  1110.                 if [ "$verbosity" = "1" ]; then
  1111.                     echo "Converting ${src} to ${target}"
  1112.                 fi
  1113.                 rsync -ab "${src}" "${target}"
  1114.                 ;;
  1115.  
  1116.                 swingh*([0-9]).wav)
  1117.                 targetfile=$(printf %q "hswing$swinghcounter.wav")
  1118.                 swinghcounter=$((swinghcounter+1))
  1119.                 target="./$targetpath/$targetfile"
  1120.                 if [ "$verbosity" = "1" ]; then
  1121.                     echo "Converting ${src} to ${target}"
  1122.                 fi
  1123.                 rsync -ab "${src}" "${target}"
  1124.                 ;;
  1125.                
  1126.                 swingl*([0-9]).wav)
  1127.                 targetfile=$(printf %q "lswing$swinglcounter.wav")
  1128.                 swinglcounter=$((swinglcounter+1))
  1129.                 target="./$targetpath/$targetfile"
  1130.                 if [ "$verbosity" = "1" ]; then
  1131.                     echo "Converting ${src} to ${target}"
  1132.                 fi
  1133.                 rsync -ab "${src}" "${target}"
  1134.                 ;;
  1135.  
  1136.                 swng*([0-9]).wav)
  1137.                 targetfile=$(printf %q "swing$swngcounter.wav")
  1138.                 swngcounter=$((swngcounter+1))
  1139.                 target="./$targetpath/$targetfile"
  1140.                 if [ "$verbosity" = "1" ]; then
  1141.                     echo "Converting ${src} to ${target}"
  1142.                 fi
  1143.                 rsync -ab "${src}" "${target}"
  1144.                 ;;
  1145.                
  1146.                 track*([0-9]).wav)
  1147.                 targetfile=$(printf %q "track$trackcounter.wav")
  1148.                 trackcounter=$((trackcounter+1))
  1149.                 if [ "$verbosity" = "1" ]; then
  1150.                     echo "Converting ${src} to ${target}"
  1151.                 fi
  1152.                 rsync -ab "${src}" "${target}"
  1153.                 ;;
  1154.                
  1155.                 *)
  1156.                 echo "No match found, ignoring file $src"
  1157.  
  1158.             esac
  1159.         done
  1160.  
  1161.         echo Coverted soundfont saved in "${targetpath}"
  1162.     done
  1163.  
  1164.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  1165.     echo "before the conversion and was renamed to avoid accidental overwriting."
  1166.     echo " "
  1167.  
  1168. #-------------------------------------------------------------------------------------------------------------------------------------
  1169.  
  1170. elif [ "$boardchoice" = "PtoX" ]; then
  1171.     echo "You chose Proffie to Xenopixel Soundfont converter."
  1172.     echo "Do you wish to convert a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  1173.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  1174.  
  1175.     read selection
  1176.  
  1177.     if [ "$selection" = "1" ]; then
  1178.         echo "You chose to convert a single soundfont. Please enter the name of the font folder containting the soundfont files."
  1179.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  1180.        
  1181.         read input
  1182.         dirs=$(find "$input" -maxdepth 0 -type d)
  1183.        
  1184.         echo "Found the following soundfont folder:"
  1185.         echo $dirs
  1186.         echo "Does this folder only contain one soundfont? (y/n)"
  1187.        
  1188.         read input2
  1189.  
  1190.         if [ "$input2" = "y" ]; then
  1191.             echo "Continuing conversion"
  1192.         else
  1193.             echo "Aborting program"
  1194.             exit
  1195.         fi
  1196.        
  1197.     elif [ "$selection" = "2" ]; then
  1198.         echo "You chose to convert several soundfonts. Each soundfont must be in a single subfolder."
  1199.         echo "Please enter the name of the folder containing the soundfont folders."
  1200.        
  1201.         read input
  1202.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  1203.        
  1204.         echo "Found the following directories for soundfonts:"
  1205.         echo $dirs
  1206.         echo "Does each of these folders only contain one soundfont? (y/n)"
  1207.  
  1208.         read input2
  1209.  
  1210.         if [ "$input2" = "y" ]; then
  1211.             echo "Continuing conversion"
  1212.         else
  1213.             echo "Aborting program"
  1214.             exit
  1215.         fi
  1216.        
  1217.     else
  1218.         echo "Your selection is invalid. Aborting program"
  1219.         exit
  1220.     fi
  1221.  
  1222.     echo "Do you wish a detailed conversion progess report ('1') or only the imporant steps ('2')?"
  1223.     echo "Warning, the detailed report will produce a lot of console output!"
  1224.  
  1225.     read verbosity
  1226.  
  1227.     if [ "$verbosity" = "1" ]; then
  1228.         echo "Logging progress to console"
  1229.     else
  1230.         echo "Logging only important steps"
  1231.     fi
  1232.  
  1233.  
  1234.     for dir in ${dirs[@]}; do
  1235.            
  1236.         sounds=$(find "$dir" -type f -name '*.wav')
  1237.  
  1238.         echo Converting soundfont in "${dir}".
  1239.  
  1240.         targetpath="Converted_to_Xenopixel"
  1241.         mkdir -p "${targetpath}"
  1242.         mkdir -p "${targetpath}/${dir}/set"
  1243.         mkdir -p "${targetpath}/${dir}/tracks"
  1244.  
  1245.         blstcounter=1
  1246.         bootcounter=1
  1247.         clshcounter=1
  1248.         # colorcounter=1
  1249.         dragcounter=1
  1250.         # endlockcounter=1
  1251.         fontcounter=1
  1252.         forcecounter=1
  1253.         humcounter=1
  1254.         incounter=1
  1255.         lockcounter=1
  1256.         outcounter=1
  1257.         preoncounter=1
  1258.         swinghcounter=1
  1259.         swinglcounter=1
  1260.         # spincounter=1
  1261.         # stabcounter=1
  1262.         # swngcounter=1
  1263.         trackcounter=1
  1264.  
  1265.         for src in ${sounds[@]}; do
  1266.             case "${src##*/}" in
  1267.             blst*([0-9]).wav)
  1268.             targetfile="blaster ($blstcounter).wav"
  1269.             blstcounter=$((blstcounter+1))
  1270.             target="./${targetpath}/${dir}/${targetfile}"
  1271.             if [ "$verbosity" = "1" ]; then
  1272.                 echo "Converting ${src} to ${target}"
  1273.             fi
  1274.             rsync -ab "${src}" "${target}"
  1275.             ;;
  1276.                
  1277.     # boot sounds are converted to 'power on.wav and live in the 'set' folder.
  1278.     # If there are more than one converted, the last one will be the resulting file.
  1279.             boot*([0-9]).wav)
  1280.             targetfile="power on.wav"
  1281.             bootcounter=$((bootcounter+1))
  1282.             target="./$targetpath/${dir}/set/$targetfile"
  1283.             if [ "$verbosity" = "1" ]; then
  1284.                 echo "Converting ${src} to ${target}"
  1285.             fi
  1286.             rsync -ab "${src}" "${target}"
  1287.             ;;
  1288.            
  1289.             clsh*([0-9]).wav)
  1290.             targetfile="clash ($clshcounter).wav"
  1291.             clshcounter=$((clshcounter+1))
  1292.             target="./${targetpath}/${dir}/${targetfile}"
  1293.             if [ "$verbosity" = "1" ]; then
  1294.                 echo "Converting ${src} to ${target}"
  1295.             fi
  1296.             rsync -ab "${src}" "${target}"
  1297.             ;;
  1298.            
  1299.          # color sounds are currently not supported by Xenopixel and therefore ignored.
  1300.          # Uncomment counter above and code here and adapt targetfile if needed later.         
  1301.             color*([0-9]).wav)
  1302.             targetfile="color ($colorcounter).wav"
  1303.             colorcounter=$((colorcounter+1))
  1304.             target="./${targetpath}/${dir}/${targetfile}"
  1305.             if [ "$verbosity" = "1" ]; then
  1306.                 echo "Converting ${src} to ${target}"
  1307.             fi
  1308.             rsync -ab "${src}" "${target}"
  1309.             ;;
  1310.            
  1311.             drag*([0-9]).wav)
  1312.             targetfile="drag ($dragcounter).wav"
  1313.             dragcounter=$((dragcounter+1))
  1314.             target="./${targetpath}/${dir}/${targetfile}"
  1315.             if [ "$verbosity" = "1" ]; then
  1316.                 echo "Converting ${src} to ${target}"
  1317.             fi
  1318.             rsync -ab "${src}" "${target}"
  1319.             ;;
  1320.            
  1321.         # endlock sounds are currently not supported by Xenopixel and therefore ignored.
  1322.         # Uncomment counter above and code here and adapt targetfile if needed later.  
  1323.         #   endlock*([0-9]).wav)
  1324.         #   targetfile="endlock ($endlockcounter).wav"
  1325.         #   endlockcounter=$((endlockcounter+1))
  1326.         #   target="./${targetpath}/${dir}/${targetfile}"
  1327.         #   if [ "$verbosity" = "1" ]; then
  1328.         #       echo "Converting ${src} to ${target}"
  1329.         #   fi
  1330.         #   rsync -ab "${src}" "${target}"
  1331.         #   ;;
  1332.            
  1333.             font*([0-9]).wav)
  1334.             targetfile="font ($fontcounter).wav"
  1335.             fontcounter=$((fontcounter+1))
  1336.             target="./${targetpath}/${dir}/${targetfile}"
  1337.             if [ "$verbosity" = "1" ]; then
  1338.                 echo "Converting ${src} to ${target}"
  1339.             fi
  1340.             rsync -ab "${src}" "${target}"
  1341.             ;;
  1342.            
  1343.             force*|quote*([0-9]).wav)
  1344.             targetfile="force ($forcecounter).wav"
  1345.             forcecounter=$((forcecounter+1))
  1346.             target="./${targetpath}/${dir}/${targetfile}"
  1347.             if [ "$verbosity" = "1" ]; then
  1348.                 echo "Converting ${src} to ${target}"
  1349.             fi
  1350.             rsync -ab "${src}" "${target}"
  1351.             ;;
  1352.            
  1353.             hum*([0-9]).wav)
  1354.             targetfile="hum ($humcounter).wav"
  1355.             humcounter=$((humcounter+1))
  1356.             target="./${targetpath}/${dir}/${targetfile}"
  1357.             if [ "$verbosity" = "1" ]; then
  1358.                 echo "Converting ${src} to ${target}"
  1359.             fi
  1360.             rsync -ab "${src}" "${target}"
  1361.             ;;
  1362.            
  1363.             in*([0-9]).wav)
  1364.             targetfile="in ($incounter).wav"
  1365.             incounter=$((incounter+1))
  1366.             target="./${targetpath}/${dir}/${targetfile}"
  1367.             if [ "$verbosity" = "1" ]; then
  1368.                 echo "Converting ${src} to ${target}"
  1369.             fi
  1370.             rsync -ab "${src}" "${target}"
  1371.             ;;
  1372.            
  1373.             lock*([0-9]).wav)
  1374.             targetfile="lock ($lockcounter).wav"
  1375.             lockcounter=$((lockcounter+1))
  1376.             target="./${targetpath}/${dir}/${targetfile}"
  1377.             if [ "$verbosity" = "1" ]; then
  1378.                 echo "Converting ${src} to ${target}"
  1379.             fi
  1380.             rsync -ab "${src}" "${target}"
  1381.             ;;
  1382.            
  1383.             out*([0-9]).wav)
  1384.             targetfile="out ($outcounter).wav"
  1385.             outcounter=$((outcounter+1))
  1386.             target="./${targetpath}/${dir}/${targetfile}"
  1387.             if [ "$verbosity" = "1" ]; then
  1388.                 echo "Converting ${src} to ${target}"
  1389.             fi
  1390.             rsync -ab "${src}" "${target}"
  1391.             ;;
  1392.             swingh*([0-9]).wav)
  1393.             targetfile="swingh ($swinghcounter).wav"
  1394.             swinghcounter=$((swinghcounter+1))
  1395.             target="./${targetpath}/${dir}/${targetfile}"
  1396.             if [ "$verbosity" = "1" ]; then
  1397.                 echo "Converting ${src} to ${target}"
  1398.             fi
  1399.             rsync -ab "${src}" "${target}"
  1400.             ;;
  1401.            
  1402.             swingl*([0-9]).wav)
  1403.             targetfile="swingl ($swinglcounter).wav"
  1404.             swinglcounter=$((swinglcounter+1))
  1405.             target="./${targetpath}/${dir}/${targetfile}"
  1406.             if [ "$verbosity" = "1" ]; then
  1407.                 echo "Converting ${src} to ${target}"
  1408.             fi
  1409.             rsync -ab "${src}" "${target}"
  1410.             ;;
  1411.  
  1412.             preon*([0-9]).wav)
  1413.             targetfile="preon ($preoncounter).wav"
  1414.             if [ "$preoncounter" -ge 5 ]; then
  1415.                 preoncounter=1
  1416.             else
  1417.                 preoncounter=$((preoncounter+1))
  1418.             fi
  1419.             target="./$targetpath/$targetfile"
  1420.             target="./$targetpath/${dir}/set/$targetfile"
  1421.             if [ "$verbosity" = "1" ]; then
  1422.                 echo "Converting ${src} to ${target}"
  1423.             fi
  1424.             rsync -ab "${src}" "${target}"
  1425.             ;;
  1426.  
  1427.     # spin sounds are currently not supported by Xenopixel and therefore ignored.
  1428.     # Uncomment counter above and code here and adapt targetfile if needed later.
  1429.     #       spin*([0-9]).wav)
  1430.     #       targetfile="spin ($spincounter).wav"
  1431.     #       spincounter=$((spincounter+1))
  1432.     #       target="./${targetpath}/${dir}/${targetfile}"
  1433.     #       if [ "$verbosity" = "1" ]; then
  1434.     #           echo "Converting ${src} to ${target}"
  1435.     #       fi
  1436.     #       rsync -ab "${src}" "${target}"
  1437.     #       ;;     
  1438.  
  1439.     # stab sounds are currently not supported by Xenopixel and therefore ignored.
  1440.     # Uncomment counter above and code here and adapt targetfile if needed later.
  1441.     #       stab*([0-9]).wav)
  1442.     #       targetfile="stab ($stabcounter).wav"
  1443.     #       stabcounter=$((stabcounter+1))
  1444.     #       target="./${targetpath}/${dir}/${targetfile}"
  1445.     #       if [ "$verbosity" = "1" ]; then
  1446.     #           echo "Converting ${src} to ${target}"
  1447.     #       fi
  1448.     #       rsync -ab "${src}" "${target}"
  1449.     #       ;;
  1450.     # Accent Swings are currently not supported by Xenopixel and therefore ignored.
  1451.     # Uncomment and adapt targetfile if needed later.      
  1452.     #       swng*([0-9]).wav)
  1453.     #       targetfile="swing ($swingcounter).wav"
  1454.     #       swingcounter=$((swingcounter+1))
  1455.     #       target="./${targetpath}/${dir}/${targetfile}"
  1456.     #       if [ "$verbosity" = "1" ]; then
  1457.     #           echo "Converting ${src} to ${target}"
  1458.     #       fi
  1459.     #       rsync -ab "${src}" "${target}"
  1460.     #       ;;
  1461.                
  1462.             track*([0-9]).wav)
  1463.             targetfile="track ($trackcounter).wav"
  1464.             trackcounter=$((trackcounter+1))
  1465.             target="./$targetpath/${dir}/tracks/$targetfile"
  1466.             if [ "$verbosity" = "1" ]; then
  1467.                 echo "Converting ${src} to ${target}"
  1468.             fi
  1469.             rsync -ab "${src}" "${target}"
  1470.             ;;
  1471.            
  1472.                 *)
  1473.                 echo "No match found, ignoring file $src"
  1474.  
  1475.             esac
  1476.         done
  1477.  
  1478.         echo Coverted soundfont saved in "${targetpath}"
  1479.     done
  1480.  
  1481.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  1482.     echo "before the conversion and was renamed to avoid accidental overwriting."
  1483.     echo " "
  1484.  
  1485. #-------------------------------------------------------------------------------------------------------------------------------------
  1486.  
  1487. elif [ "$boardchoice" = "XtoC" ]; then
  1488.     echo "You chose Xenopixel to CFX Soundfont converter."
  1489.     echo "Do you wish to convert a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  1490.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  1491.  
  1492.     read selection
  1493.  
  1494.     if [ "$selection" = "1" ]; then
  1495.         echo "You chose to convert a single soundfont. Please enter the name of the font folder containting the soundfont files."
  1496.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  1497.        
  1498.         read input
  1499.         dirs=$(find "$input" -maxdepth 0 -type d)
  1500.        
  1501.         echo "Found the following soundfont folder:"
  1502.         echo $dirs
  1503.         echo "Does this folder only contain one soundfont? (y/n)"
  1504.        
  1505.         read input2
  1506.  
  1507.         if [ "$input2" = "y" ]; then
  1508.             echo "Continuing conversion"
  1509.         else
  1510.             echo "Aborting program"
  1511.             exit
  1512.         fi
  1513.        
  1514.     elif [ "$selection" = "2" ]; then
  1515.         echo "You chose to convert several soundfonts. Each soundfont must be in a single subfolder."
  1516.         echo "Please enter the name of the folder containing the soundfont folders."
  1517.        
  1518.         read input
  1519.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  1520.        
  1521.         echo "Found the following directories for soundfonts:"
  1522.         echo $dirs
  1523.         echo "Does each of these folders only contain one soundfont? (y/n)"
  1524.  
  1525.         read input2
  1526.  
  1527.         if [ "$input2" = "y" ]; then
  1528.             echo "Continuing conversion"
  1529.         else
  1530.             echo "Aborting program"
  1531.             exit
  1532.         fi
  1533.        
  1534.     else
  1535.         echo "Your selection is invalid. Aborting program"
  1536.         exit
  1537.     fi
  1538.  
  1539.     echo "Do you wish a detailed conversion progess report ('1') or only the imporant steps ('2')?"
  1540.     echo "Warning, the detailed report will produce a lot of console output!"
  1541.  
  1542.     read verbosity
  1543.  
  1544.     if [ "$verbosity" = "1" ]; then
  1545.         echo "Logging progress to console"
  1546.     else
  1547.         echo "Logging only important steps"
  1548.     fi
  1549.  
  1550.     for dir in ${dirs[@]}; do
  1551.            
  1552.         sounds=$(find "$dir" -type f -name '*.wav')
  1553.  
  1554.         echo Converting soundfont in "${dir}".
  1555.  
  1556.         targetpath="Converted_to_CFX/${dir}"
  1557.         mkdir -p "${targetpath}"
  1558.    
  1559.         blastercounter=1
  1560.         # bootcounter=1
  1561.         clashcounter=1
  1562.         # colorcounter=1
  1563.         dragcounter=1
  1564.         # endlockcounter=1
  1565.         fontcounter=1
  1566.         forcecounter=1
  1567.         hswingcounter=1
  1568.         humcounter=1
  1569.         incounter=1
  1570.         lockcounter=1
  1571.         lswingcounter=1
  1572.         outcounter=1
  1573.         # preoncounter=1
  1574.         # spincounter=1
  1575.         # stabcounter=1
  1576.         # swingcounter=1
  1577.         trackcounter=1
  1578.  
  1579.         for src in ${sounds[@]}; do
  1580.             case "${src##*/}" in
  1581.  
  1582.                 blaster**([0-9]).wav)
  1583.                 if [ "$blastercounter" -eq 1 ]; then
  1584.                     targetfile=$(printf %q "blaster.wav")  
  1585.                 else
  1586.                     targetfile=$(printf %q "blaster$blastercounter.wav")
  1587.                 fi
  1588.                 blastercounter=$((blastercounter+1))
  1589.                 target="./${targetpath}/${targetfile}"
  1590.                 if [ "$verbosity" = "1" ]; then
  1591.                     echo "Converting ${src} to ${target}"
  1592.                 fi
  1593.                 rsync -ab "${src}" "${target}"
  1594.                 ;;
  1595.                
  1596.         # boot sounds are currently not supported by Xenopixel and therefore ignored.
  1597.         # Uncomment counter above and code here and adapt targetfile if needed later.
  1598.         #       boot**([0-9]).wav)
  1599.         #       targetfile=$(printf %q "boot$bootcounter.wav")
  1600.         #       bootcounter=$((bootcounter+1))
  1601.         #       target="./$targetpath/$targetfile"
  1602.         #       if [ "$verbosity" = "1" ]; then
  1603.         #           echo "Converting ${src} to ${target}"
  1604.         #       fi
  1605.         #       rsync -ab "${src}" "${target}"
  1606.         #       ;;
  1607.                
  1608.                 clash**([0-9]).wav)
  1609.                 targetfile=$(printf %q "clash$clashcounter.wav")
  1610.                 clashcounter=$((clashcounter+1))
  1611.                 target="./$targetpath/$targetfile"
  1612.                 if [ "$verbosity" = "1" ]; then
  1613.                     echo "Converting ${src} to ${target}"
  1614.                 fi
  1615.                 rsync -ab "${src}" "${target}"
  1616.                 ;;
  1617.                
  1618.         # color sounds are currently not supported by Xenopixel and therefore ignored.
  1619.         # Uncomment counter above and code here and adapt targetfile if needed later.
  1620.         #       color**([0-9]).wav)
  1621.         #       targetfile=$(printf %q "color$colorcounter.wav")
  1622.         #       colorcounter=$((colorcounter+1))
  1623.         #       target="./$targetpath/$targetfile"
  1624.         #       if [ "$verbosity" = "1" ]; then
  1625.         #           echo "Converting ${src} to ${target}"
  1626.         #       fi
  1627.         #       rsync -ab "${src}" "${target}"
  1628.         #       ;;
  1629.                
  1630.                 drag**([0-9]).wav)
  1631.                 if [ "$dragcounter" -eq 1 ]; then
  1632.                     targetfile=$(printf %q "drag.wav") 
  1633.                 else
  1634.                     targetfile=$(printf %q "drag$dragcounter.wav")
  1635.                 fi
  1636.                 dragcounter=$((dragcounter+1))
  1637.                 target="./$targetpath/$targetfile"
  1638.                 if [ "$verbosity" = "1" ]; then
  1639.                     echo "Converting ${src} to ${target}"
  1640.                 fi
  1641.                 rsync -ab "${src}" "${target}"
  1642.                 ;;
  1643.  
  1644.         # endlock sounds are currently not supported by Xenopixel and therefore ignored.
  1645.         # Uncomment counter above and code here and adapt targetfile if needed later.  
  1646.         #       endlock*([0-9]).wav)
  1647.         #       targetfile=$(printf %q "endlock$endlockcounter.wav")
  1648.         #       endlockcounter=$((endlockcounter+1))
  1649.         #       target="./$targetpath/$targetfile"
  1650.         #       if [ "$verbosity" = "1" ]; then
  1651.         #           echo "Converting ${src} to ${target}"
  1652.         #       fi
  1653.         #       rsync -ab "${src}" "${target}"
  1654.         #       ;;
  1655.                
  1656.                 font**([0-9]).wav)
  1657.                 if [ "$fontcounter" -eq 1 ]; then
  1658.                     targetfile=$(printf %q "font.wav") 
  1659.                 else
  1660.                     targetfile=$(printf %q "font$fontcounter.wav")
  1661.                 fi
  1662.                 fontcounter=$((fontcounter+1))
  1663.                 target="./$targetpath/$targetfile"
  1664.                 if [ "$verbosity" = "1" ]; then
  1665.                     echo "Converting ${src} to ${target}"
  1666.                 fi
  1667.                 rsync -ab "${src}" "${target}"
  1668.                 ;;
  1669.                
  1670.                 force**([0-9]).wav)
  1671.                 if [ "$forcecounter" -eq 1 ]; then
  1672.                     targetfile=$(printf %q "force.wav")
  1673.                 else
  1674.                     targetfile=$(printf %q "force$forcecounter.wav")
  1675.                 fi
  1676.                 forcecounter=$((forcecounter+1))
  1677.                 target="./$targetpath/$targetfile"
  1678.                 if [ "$verbosity" = "1" ]; then
  1679.                     echo "Converting ${src} to ${target}"
  1680.                 fi
  1681.                 rsync -ab "${src}" "${target}"
  1682.                 ;;
  1683.                
  1684.                 hum**([0-9]).wav)
  1685.                 targetfile=$(printf %q "humM$humcounter.wav")
  1686.                 humcounter=$((humcounter+1))
  1687.                 target="./$targetpath/$targetfile"
  1688.                 if [ "$verbosity" = "1" ]; then
  1689.                     echo "Converting ${src} to ${target}"
  1690.                 fi
  1691.                 rsync -ab "${src}" "${target}"
  1692.                 ;;
  1693.                
  1694.                 in**([0-9]).wav)
  1695.                 if [ "$incounter" -eq 1 ]; then
  1696.                     targetfile=$(printf %q "poweroff.wav") 
  1697.                 elif [ "$incounter" -eq 2 ]; then
  1698.                     targetfile=$(printf %q "pwroff$incounter.wav")
  1699.                 elif [ "$incounter" -ge 3 ]; then
  1700.                     targetfile=$(printf %q "poweroff$((incounter-1)).wav")
  1701.                 fi
  1702.                 incounter=$((incounter+1))
  1703.                 target="./$targetpath/$targetfile"
  1704.                 if [ "$verbosity" = "1" ]; then
  1705.                     echo "Converting ${src} to ${target}"
  1706.                 fi
  1707.                 rsync -ab "${src}" "${target}"
  1708.                 ;;
  1709.                
  1710.                 lock**([0-9]).wav)
  1711.                 if [ "$lockcounter" -eq 1 ]; then
  1712.                     targetfile=$(printf %q "lockup.wav")   
  1713.                 else
  1714.                     targetfile=$(printf %q "lockup$lockcounter.wav")
  1715.                 fi
  1716.                 lockcounter=$((lockcounter+1))
  1717.                 target="./$targetpath/$targetfile"
  1718.                 if [ "$verbosity" = "1" ]; then
  1719.                     echo "Converting ${src} to ${target}"
  1720.                 fi
  1721.                 rsync -ab "${src}" "${target}"
  1722.                 ;;
  1723.                
  1724.                 out**([0-9]).wav)
  1725.                 if [ "$outcounter" -eq 1 ]; then
  1726.                     targetfile=$(printf %q "poweron.wav")  
  1727.                 else
  1728.                     targetfile=$(printf %q "poweron$outcounter.wav")
  1729.                 fi
  1730.                 outcounter=$((outcounter+1))
  1731.                 target="./$targetpath/$targetfile"
  1732.                 if [ "$verbosity" = "1" ]; then
  1733.                     echo "Converting ${src} to ${target}"
  1734.                 fi
  1735.                 rsync -ab "${src}" "${target}"
  1736.                 ;;
  1737.  
  1738.                 hswing**([0-9]).wav)
  1739.                 targetfile=$(printf %q "hswing$hswingcounter.wav")
  1740.                 hswingcounter=$((hswingcounter+1))
  1741.                 target="./$targetpath/$targetfile"
  1742.                 if [ "$verbosity" = "1" ]; then
  1743.                     echo "Converting ${src} to ${target}"
  1744.                 fi
  1745.                 rsync -ab "${src}" "${target}"
  1746.                 ;;
  1747.                
  1748.                 lswing**([0-9]).wav)
  1749.                 targetfile=$(printf %q "lswing$lswingcounter.wav")
  1750.                 lswingcounter=$((lswingcounter+1))
  1751.                 target="./$targetpath/$targetfile"
  1752.                 if [ "$verbosity" = "1" ]; then
  1753.                     echo "Converting ${src} to ${target}"
  1754.                 fi
  1755.                 rsync -ab "${src}" "${target}"
  1756.                 ;;
  1757.  
  1758.         # Accent Swings are currently not supported by Xenopixel and therefore ignored.
  1759.         # Uncomment and adapt targetfile if needed later.  
  1760.         #       swng**([0-9]).wav)
  1761.         #       targetfile=$(printf %q "swing$swingcounter.wav")
  1762.         #       swingcounter=$((swingcounter+1))
  1763.         #       target="./$targetpath/$targetfile"
  1764.         #       if [ "$verbosity" = "1" ]; then
  1765.         #           echo "Converting ${src} to ${target}"
  1766.         #       fi
  1767.         #       rsync -ab "${src}" "${target}"
  1768.         #       ;;
  1769.                
  1770.                 track**([0-9]).wav)
  1771.                 targetfile=$(printf %q "track$trackcounter.wav")
  1772.                 trackcounter=$((trackcounter+1))
  1773.                 if [ "$verbosity" = "1" ]; then
  1774.                     echo "Converting ${src} to ${target}"
  1775.                 fi
  1776.                 rsync -ab "${src}" "${target}"
  1777.                 ;;
  1778.                
  1779.                 *)
  1780.                 echo "No match found, ignoring file $src"
  1781.  
  1782.             esac
  1783.         done
  1784.  
  1785.         echo Coverted soundfont saved in "${targetpath}"
  1786.     done
  1787.  
  1788.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  1789.     echo "before the conversion and was renamed to avoid accidental overwriting."
  1790.     echo " "
  1791.  
  1792. #-------------------------------------------------------------------------------------------------------------------------------------
  1793.  
  1794. elif [ "$boardchoice" = "XtoP" ]; then
  1795.     echo "You chose Xenopixel to Proffie Soundfont converter."
  1796.     echo "Do you wish to convert a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  1797.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  1798.  
  1799.     read selection
  1800.  
  1801.     if [ "$selection" = "1" ]; then
  1802.         echo "You chose to convert a single soundfont. Please enter the name of the font folder containting the soundfont files."
  1803.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  1804.        
  1805.         read input
  1806.         dirs=$(find "$input" -maxdepth 0 -type d)
  1807.        
  1808.         echo "Found the following soundfont folder:"
  1809.         echo $dirs
  1810.         echo "Does this folder only contain one soundfont? (y/n)"
  1811.        
  1812.         read input2
  1813.  
  1814.         if [ "$input2" = "y" ]; then
  1815.             echo "Continuing conversion"
  1816.         else
  1817.             echo "Aborting program"
  1818.             exit
  1819.         fi
  1820.        
  1821.     elif [ "$selection" = "2" ]; then
  1822.         echo "You chose to convert several soundfonts. Each soundfont must be in a single subfolder."
  1823.         echo "Please enter the name of the folder containing the soundfont folders."
  1824.        
  1825.         read input
  1826.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  1827.        
  1828.         echo "Found the following directories for soundfonts:"
  1829.         echo $dirs
  1830.         echo "Does each of these folders only contain one soundfont? (y/n)"
  1831.  
  1832.         read input2
  1833.  
  1834.         if [ "$input2" = "y" ]; then
  1835.             echo "Continuing conversion"
  1836.         else
  1837.             echo "Aborting program"
  1838.             exit
  1839.         fi
  1840.        
  1841.     else
  1842.         echo "Your selection is invalid. Aborting program"
  1843.         exit
  1844.     fi
  1845.  
  1846.     echo "Do you wish a detailed conversion progess report ('1') or only the imporant steps ('2')?"
  1847.     echo "Warning, the detailed report will produce a lot of console output!"
  1848.  
  1849.     read verbosity
  1850.  
  1851.     if [ "$verbosity" = "1" ]; then
  1852.         echo "Logging progress to console"
  1853.     else
  1854.         echo "Logging only important steps"
  1855.     fi
  1856.  
  1857.  
  1858.     for dir in ${dirs[@]}; do
  1859.            
  1860.         sounds=$(find "$dir" -type f -name '*.wav')
  1861.  
  1862.         echo Converting soundfont in "${dir}".
  1863.  
  1864.         targetpath="Converted_to_Proffie"
  1865.         mkdir -p "${targetpath}"
  1866.         mkdir -p "${targetpath}/${dir}/bgndrag"
  1867.         mkdir -p "${targetpath}/${dir}/bgnlb"
  1868.         mkdir -p "${targetpath}/${dir}/bgnlock"
  1869.         mkdir -p "${targetpath}/${dir}/bgnmelt"
  1870.         mkdir -p "${targetpath}/${dir}/blst"
  1871.         mkdir -p "${targetpath}/${dir}/boot"
  1872.         mkdir -p "${targetpath}/${dir}/clsh"
  1873.         mkdir -p "${targetpath}/${dir}/ccchange"
  1874.         mkdir -p "${targetpath}/${dir}/drag"
  1875.         mkdir -p "${targetpath}/${dir}/enddrag"
  1876.         mkdir -p "${targetpath}/${dir}/endlb"
  1877.         mkdir -p "${targetpath}/${dir}/endlock"
  1878.         mkdir -p "${targetpath}/${dir}/font"
  1879.         mkdir -p "${targetpath}/${dir}/force"
  1880.         mkdir -p "${targetpath}/${dir}/hum"
  1881.         mkdir -p "${targetpath}/${dir}/in"
  1882.         mkdir -p "${targetpath}/${dir}/lb"
  1883.         mkdir -p "${targetpath}/${dir}/lock"
  1884.         mkdir -p "${targetpath}/${dir}/melt"
  1885.         mkdir -p "${targetpath}/${dir}/out"
  1886.         mkdir -p "${targetpath}/${dir}/preon"
  1887.         mkdir -p "${targetpath}/${dir}/pstoff"
  1888.         mkdir -p "${targetpath}/${dir}/slsh"
  1889.         mkdir -p "${targetpath}/${dir}/spin"
  1890.         mkdir -p "${targetpath}/${dir}/stab"
  1891.         mkdir -p "${targetpath}/${dir}/swingh"
  1892.         mkdir -p "${targetpath}/${dir}/swingl"
  1893.         mkdir -p "${targetpath}/${dir}/swng"
  1894.         mkdir -p "${targetpath}/${dir}/tracks"
  1895.  
  1896.         blastercounter=1
  1897.         # bootcounter=1
  1898.         clashcounter=1
  1899.         # colorcounter=1
  1900.         dragcounter=1
  1901.         # endlockcounter=1
  1902.         fontcounter=1
  1903.         forcecounter=1
  1904.         hswingcounter=1
  1905.         humcounter=1
  1906.         incounter=1
  1907.         lockcounter=1
  1908.         lswingcounter=1
  1909.         outcounter=1
  1910.         # preoncounter=1
  1911.         # spincounter=1
  1912.         # stabcounter=1
  1913.         # swingcounter=1
  1914.         trackcounter=1
  1915.  
  1916.         for src in ${sounds[@]}; do
  1917.             case "${src##*/}" in
  1918.  
  1919.                 blaster**([0-9]).wav)
  1920.                 if [ "$blastercounter" -lt 10 ]; then
  1921.                     targetfile=$(printf %q "blst0$blastercounter.wav") 
  1922.                 else
  1923.                     targetfile=$(printf %q "blst$blastercounter.wav")
  1924.                 fi
  1925.                 blastercounter=$((blastercounter+1))
  1926.                 target="./${targetpath}/${dir}/blst/${targetfile}"
  1927.                 if [ "$verbosity" = "1" ]; then
  1928.                     echo "Converting ${src} to ${target}"
  1929.                 fi
  1930.                 rsync -ab "${src}" "${target}"
  1931.                 ;;
  1932.                    
  1933.         # boot sounds are currently not supported by Xenopixel and therefore ignored.
  1934.         # Uncomment counter above and code here and adapt targetfile if needed later.
  1935.         #       boot**([0-9]).wav)
  1936.         #       if [ "$bootcounter" -lt 10 ]; then
  1937.         #           targetfile=$(printf %q "boot0$bootcounter.wav")
  1938.         #       else
  1939.         #           targetfile=$(printf %q "boot$bootcounter.wav")
  1940.         #       fi
  1941.         #       bootcounter=$((bootcounter+1))
  1942.         #       target="./$targetpath/${dir}/boot/$targetfile"
  1943.         #       if [ "$verbosity" = "1" ]; then
  1944.         #           echo "Converting ${src} to ${target}"
  1945.         #       fi
  1946.         #       rsync -ab "${src}" "${target}"
  1947.         #       ;;
  1948.                
  1949.                 clash**([0-9]).wav)
  1950.                 if [ "$clashcounter" -lt 10 ]; then
  1951.                     targetfile=$(printf %q "clsh0$clashcounter.wav")   
  1952.                 else
  1953.                     targetfile=$(printf %q "clsh$clashcounter.wav")
  1954.                 fi
  1955.                 clashcounter=$((clashcounter+1))
  1956.                 target="./$targetpath/${dir}/clsh/$targetfile"
  1957.                 if [ "$verbosity" = "1" ]; then
  1958.                     echo "Converting ${src} to ${target}"
  1959.                 fi
  1960.                 rsync -ab "${src}" "${target}"
  1961.                 ;;
  1962.                
  1963.         # color sounds are currently not supported by Xenopixel and therefore ignored.
  1964.         # Uncomment counter above and code here and adapt targetfile if needed later.
  1965.         #       color**([0-9]).wav)
  1966.         #       targetfile=$(printf %q "ccchage$colorcounter.wav")
  1967.         #       colorcounter=$((colorcounter+1))
  1968.         #       target="./$targetpath/${dir}/ccchange/$targetfile"
  1969.         #       if [ "$verbosity" = "1" ]; then
  1970.         #           echo "Converting ${src} to ${target}"
  1971.         #       fi
  1972.         #       rsync -ab "${src}" "${target}"
  1973.         #       ;;
  1974.                
  1975.                 drag**([0-9]).wav)
  1976.                 if [ "$dragcounter" -lt 10 ]; then
  1977.                     targetfile=$(printf %q "drag0$dragcounter.wav")
  1978.                 else
  1979.                     targetfile=$(printf %q "drag$dragcounter.wav")
  1980.                 fi
  1981.                 dragcounter=$((dragcounter+1))
  1982.                 target="./$targetpath/${dir}/drag/$targetfile"
  1983.                 if [ "$verbosity" = "1" ]; then
  1984.                     echo "Converting ${src} to ${target}"
  1985.                 fi
  1986.                 rsync -ab "${src}" "${target}"
  1987.                 ;;
  1988.                
  1989.         # endlock sounds are currently not supported by Xenopixel and therefore ignored.
  1990.         # Uncomment counter above and code here and adapt targetfile if needed later.
  1991.         #       endlock**([0-9]).wav)
  1992.         #       targetfile=$(printf %q "endlock$endlockcounter.wav")
  1993.         #       endlockcounter=$((endlockcounter+1))
  1994.         #       target="./$targetpath/${dir}/endlock/$targetfile"
  1995.         #       if [ "$verbosity" = "1" ]; then
  1996.         #           echo "Converting ${src} to ${target}"
  1997.         #       fi
  1998.         #       rsync -ab "${src}" "${target}"
  1999.         #       ;;
  2000.                
  2001.                 font**([0-9]).wav)
  2002.                 if [ "$fontcounter" -lt 10 ]; then
  2003.                     targetfile=$(printf %q "font0$fontcounter.wav")
  2004.                 else
  2005.                     targetfile=$(printf %q "font$fontcounter.wav")
  2006.                 fi
  2007.                 fontcounter=$((fontcounter+1))
  2008.                 target="./$targetpath/${dir}/font/$targetfile"
  2009.                 if [ "$verbosity" = "1" ]; then
  2010.                     echo "Converting ${src} to ${target}"
  2011.                 fi
  2012.                 rsync -ab "${src}" "${target}"
  2013.                 ;;
  2014.                
  2015.                 force**|combo*([0-9]).wav)
  2016.                 if [ "$forcecounter" -lt 10 ]; then
  2017.                     targetfile=$(printf %q "force0$forcecounter.wav")  
  2018.                 else
  2019.                     targetfile=$(printf %q "force$forcecounter.wav")
  2020.                 fi
  2021.                 forcecounter=$((forcecounter+1))
  2022.                 target="./$targetpath/${dir}/force/$targetfile"
  2023.                 if [ "$verbosity" = "1" ]; then
  2024.                     echo "Converting ${src} to ${target}"
  2025.                 fi
  2026.                 rsync -ab "${src}" "${target}"
  2027.                 ;;
  2028.                
  2029.                 hswing**([0-9]).wav)
  2030.                 if [ "$hswingcounter" -lt 10 ]; then
  2031.                     targetfile=$(printf %q "swingh0$hswingcounter.wav")
  2032.                 else
  2033.                     targetfile=$(printf %q "swingh$hswingcounter.wav")
  2034.                 fi
  2035.                 hswingcounter=$((hswingcounter+1))
  2036.                 target="./$targetpath/${dir}/swingh/$targetfile"
  2037.                 if [ "$verbosity" = "1" ]; then
  2038.                     echo "Converting ${src} to ${target}"
  2039.                 fi
  2040.                 rsync -ab "${src}" "${target}"
  2041.                 ;;
  2042.  
  2043.                 hum**([0-9]).wav)
  2044.                 if [ "$humcounter" -lt 10 ]; then
  2045.                     targetfile=$(printf %q "hum0$humcounter.wav")  
  2046.                 else
  2047.                     targetfile=$(printf %q "hum$humcounter.wav")
  2048.                 fi
  2049.                 humcounter=$((humcounter+1))
  2050.                 target="./$targetpath/${dir}/hum/$targetfile"
  2051.                 if [ "$verbosity" = "1" ]; then
  2052.                     echo "Converting ${src} to ${target}"
  2053.                 fi
  2054.                 rsync -ab "${src}" "${target}"
  2055.                 ;;             
  2056.  
  2057.                 lswing**([0-9]).wav)
  2058.                 if [ "$lswingcounter" -lt 10 ]; then
  2059.                     targetfile=$(printf %q "swingl0$lswingcounter.wav")
  2060.                 else
  2061.                     targetfile=$(printf %q "swingl$lswingcounter.wav")
  2062.                 fi
  2063.                 lswingcounter=$((lswingcounter+1))
  2064.                 target="./$targetpath/${dir}/swingl/$targetfile"
  2065.                 if [ "$verbosity" = "1" ]; then
  2066.                     echo "Converting ${src} to ${target}"
  2067.                 fi
  2068.                 rsync -ab "${src}" "${target}"
  2069.                 ;;
  2070.  
  2071.                 in**([0-9]).wav)
  2072.                 if [ "$incounter" -lt 10 ]; then
  2073.                     targetfile=$(printf %q "in0$incounter.wav")
  2074.                 else
  2075.                     targetfile=$(printf %q "in$incounter.wav")
  2076.                 fi
  2077.                 incounter=$((incounter+1))
  2078.                 target="./$targetpath/${dir}/in/$targetfile"
  2079.                 if [ "$verbosity" = "1" ]; then
  2080.                     echo "Converting ${src} to ${target}"
  2081.                 fi
  2082.                 rsync -ab "${src}" "${target}"
  2083.                 ;;
  2084.  
  2085.                 out**([0-9]).wav)
  2086.                 if [ "$outcounter" -lt 10 ]; then
  2087.                     targetfile=$(printf %q "out0$outcounter.wav")  
  2088.                 else
  2089.                     targetfile=$(printf %q "out$outcounter.wav")
  2090.                 fi
  2091.                 outcounter=$((outcounter+1))
  2092.                 target="./$targetpath/${dir}/out/$targetfile"
  2093.                 if [ "$verbosity" = "1" ]; then
  2094.                     echo "Converting ${src} to ${target}"
  2095.                 fi
  2096.                 rsync -ab "${src}" "${target}"
  2097.                 ;;
  2098.  
  2099.                 lock**([0-9]).wav)
  2100.                 if [ "$lockcounter" -lt 10 ]; then
  2101.                     targetfile=$(printf %q "lock0$lockcounter.wav")
  2102.                 else
  2103.                     targetfile=$(printf %q "lock$lockcounter.wav")
  2104.                 fi
  2105.                 lockcounter=$((lockcounter+1))
  2106.                 target="./$targetpath/${dir}/lock/$targetfile"
  2107.                 if [ "$verbosity" = "1" ]; then
  2108.                     echo "Converting ${src} to ${target}"
  2109.                 fi
  2110.                 rsync -ab "${src}" "${target}"
  2111.                 ;;
  2112.  
  2113.     # preon sounds are currently not supported by Xenopixel and therefore ignored.
  2114.     # Uncomment counter above and code here and adapt targetfile if needed later.
  2115.     #           preon**([0-9]).wav)
  2116.     #           if [ "$preoncounter" -lt 10 ]; then
  2117.     #               targetfile=$(printf %q "preon0$preoncounter.wav")  
  2118.     #           else
  2119.     #               targetfile=$(printf %q "preon$preoncounter.wav")
  2120.     #           fi
  2121.     #           preoncounter=$((preoncounter+1))
  2122.     #           target="./${targetpath}/${dir}/preon/${targetfile}"
  2123.     #           if [ "$verbosity" = "1" ]; then
  2124.     #               echo "Converting ${src} to ${target}"
  2125.     #           fi
  2126.     #           rsync -ab "${src}" "${target}"
  2127.     #           ;;
  2128.  
  2129.     # spin sounds are currently not supported by Xenopixel and therefore ignored.
  2130.     # Uncomment counter above and code here and adapt targetfile if needed later.
  2131.     #           spin**([0-9]).wav)
  2132.     #           if [ "$spincounter" -lt 10 ]; then
  2133.     #               targetfile=$(printf %q "spin0$spincounter.wav")
  2134.     #           else
  2135.     #               targetfile=$(printf %q "spin$spincounter.wav")
  2136.     #           fi
  2137.     #           spincounter=$((spincounter+1))
  2138.     #           target="./$targetpath/${dir}/spin/$targetfile"
  2139.     #           if [ "$verbosity" = "1" ]; then
  2140.     #               echo "Converting ${src} to ${target}"
  2141.     #           fi
  2142.     #           rsync -ab "${src}" "${target}"
  2143.     #           ;;         
  2144.  
  2145.     # stab sounds are currently not supported by Xenopixel and therefore ignored.
  2146.     # Uncomment counter above and code here and adapt targetfile if needed later.
  2147.     #           stab**([0-9]).wav)
  2148.     #           if [ "$stabcounter" -lt 10 ]; then
  2149.     #               targetfile=$(printf %q "stab0$stabcounter.wav")
  2150.     #           else
  2151.     #               targetfile=$(printf %q "stab$stabcounter.wav")
  2152.     #           fi
  2153.     #           stabcounter=$((stabcounter+1))
  2154.     #           target="./$targetpath/${dir}/stab/$targetfile"
  2155.     #           if [ "$verbosity" = "1" ]; then
  2156.     #               echo "Converting ${src} to ${target}"
  2157.     #           fi
  2158.     #           rsync -ab "${src}" "${target}"
  2159.     #           ;;
  2160.  
  2161.     # Accent Swing sounds are currently not supported by Xenopixel and therefore ignored.
  2162.     # Uncomment counter above and code here and adapt targetfile if needed later.
  2163.     #           swing**([0-9]).wav)
  2164.     #           if [ "$swingcounter" -lt 10 ]; then
  2165.     #               targetfile=$(printf %q "swng0$swingcounter.wav")   
  2166.     #           else
  2167.     #               targetfile=$(printf %q "swng$swingcounter.wav")
  2168.     #           fi
  2169.     #           swingcounter=$((swingcounter+1))
  2170.     #           target="./$targetpath/${dir}/swng/$targetfile"
  2171.     #           if [ "$verbosity" = "1" ]; then
  2172.     #               echo "Converting ${src} to ${target}"
  2173.     #           fi
  2174.     #           rsync -ab "${src}" "${target}"
  2175.     #           ;;
  2176.                
  2177.                 track**([0-9]).wav)
  2178.                 if [ "$trackcounter" -lt 10 ]; then
  2179.                     targetfile=$(printf %q "track0$trackcounter.wav")  
  2180.                 else
  2181.                     targetfile=$(printf %q "track$trackcounter.wav")
  2182.                 fi
  2183.                 trackcounter=$((trackcounter+1))
  2184.                 target="./$targetpath/${dir}/tracks/$targetfile"
  2185.                 if [ "$verbosity" = "1" ]; then
  2186.                     echo "Converting ${src} to ${target}"
  2187.                 fi
  2188.                 rsync -ab "${src}" "${target}"
  2189.                 ;;
  2190.                
  2191.                 *)
  2192.                 echo "No match found, ignoring file $src"
  2193.  
  2194.             esac
  2195.         done
  2196.  
  2197.         echo Coverted soundfont saved in "${targetpath}"
  2198.     done
  2199.  
  2200.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  2201.     echo "before the conversion and was renamed to avoid accidental overwriting."
  2202.     echo " "
  2203.  
  2204. #-------------------------------------------------------------------------------------------------------------------------------------
  2205.  
  2206. elif [ "$boardchoice" = "PtoP" ]; then
  2207.     echo "You chose Proffie to Proffie Soundfont renaming."
  2208.     echo "Do you wish to rename a single soundfont (enter '1') or a folder containing several soundfonts in subfolders (enter '2')?"
  2209.     echo "If you choose 2, Make sure each sub-folder only contains one soundfont. Otherwise the soundfonts will get mixed!"
  2210.  
  2211.     read selection
  2212.  
  2213.     if [ "$selection" = "1" ]; then
  2214.         echo "You chose to rename a single soundfont. Please enter the name of the font folder containting the soundfont files."
  2215.         echo "You may need to enter the path if it's a subfolder of where you are (such as 'SoundfontMaker/Font')"
  2216.        
  2217.         read input
  2218.         dirs=$(find "$input" -maxdepth 0 -type d)
  2219.        
  2220.         echo "Found the following soundfont folder:"
  2221.         echo $dirs
  2222.         echo "Does this folder only contain one soundfont? (y/n)"
  2223.        
  2224.         read input2
  2225.  
  2226.         if [ "$input2" = "y" ]; then
  2227.             echo "Continuing renaming"
  2228.         else
  2229.             echo "Aborting program"
  2230.             exit
  2231.         fi
  2232.        
  2233.     elif [ "$selection" = "2" ]; then
  2234.         echo "You chose to rename several soundfonts. Each soundfont must be in a single subfolder."
  2235.         echo "Please enter the name of the folder containing the soundfont folders."
  2236.        
  2237.         read input
  2238.         dirs=$(find "$input" -mindepth 1 -maxdepth 1 -type d)
  2239.        
  2240.         echo "Found the following directories for soundfonts:"
  2241.         echo $dirs
  2242.         echo "Does each of these folders only contain one soundfont? (y/n)"
  2243.  
  2244.         read input2
  2245.  
  2246.         if [ "$input2" = "y" ]; then
  2247.             echo "Continuing renaming"
  2248.         else
  2249.             echo "Aborting program"
  2250.             exit
  2251.         fi
  2252.        
  2253.     else
  2254.         echo "Your selection is invalid. Aborting program"
  2255.         exit
  2256.     fi
  2257.  
  2258.     echo "Do you wish a detailed renaming progess report ('1') or only the imporant steps ('2')?"
  2259.     echo "Warning, the detailed report may produce a lot of console output!"
  2260.  
  2261.     read verbosity
  2262.  
  2263.     if [ "$verbosity" = "1" ]; then
  2264.         echo "Logging progress to console"
  2265.     else
  2266.         echo "Logging only important steps"
  2267.     fi
  2268.  
  2269.     for dir in ${dirs[@]}; do
  2270.            
  2271.         sounds=$(find "$dir" -type f -name '*.wav')
  2272.  
  2273.         echo Converting soundfont in "${dir}".
  2274.  
  2275.         targetpath="Converted_to_Proffie"
  2276.         mkdir -p "${targetpath}/${dir}"
  2277.  
  2278.         counter=1
  2279.         oldeffect="old"
  2280.  
  2281.         for src in ${sounds[@]}; do
  2282.             effectfile="${src//[0-9]/}"
  2283.             effect="${effectfile##*/}"
  2284.             effect="${effect%.*}"
  2285.             if [[ "$effect" != "$oldeffect" ]]; then
  2286.                 counter=1
  2287.             fi         
  2288.             if [ $counter = 2 ]; then
  2289.                 mkdir -p "${targetpath}/${dir}/${effect}"
  2290.                 mv "${target}" "./${targetpath}/${dir}/${effect}/${targetfile}"
  2291.                 echo "Moving ${targetfile} into ${dir}/${effect} subfolder"
  2292.             fi
  2293.             if [ "${#effect}" -gt 6 ] || [ "$counter" -gt 9 ]; then
  2294.                 targetfile=$(printf %q "${effect}$counter.wav")
  2295.             else
  2296.                 targetfile=$(printf %q "${effect}0$counter.wav")
  2297.             fi
  2298.             if [ $counter -ge 2 ]; then
  2299.                 target="./${targetpath}/${dir}/${effect}/${targetfile}"
  2300.             else
  2301.                 target="./${targetpath}/${dir}/${targetfile}"
  2302.             fi
  2303.             if [ "$verbosity" = "1" ]; then
  2304.                 echo "Converting ${src} to ${target}"
  2305.             fi
  2306.             rsync -ab  "${src}" "${target}"
  2307.             counter=$((counter+1))
  2308.             oldeffect="${effect}"
  2309.         done
  2310.  
  2311.         echo Coverted soundfont saved in "${targetpath}"
  2312.     done
  2313.  
  2314.     echo "Soundfont conversion complete. If you see files with a '~' at the end, this file already existed in the output folder"
  2315.     echo "before the conversion and was renamed to avoid accidental overwriting."
  2316.     echo " "
  2317. else
  2318.     echo "Invalid conversion choice, please run the tool again."
  2319. fi
Add Comment
Please, Sign In to add comment