mi sono dilettato in questo scrippettino bash e devo dire funge bene
il nome è Fual (Fuoco Ubuntu audio looper)vabbe prima era fal cmq insomma l ho un po modificato con qualche miglioria il progetto l ho registrato anche su http://www.cli-apps.org/content/show.ph ... tent=88071
le dipendenze sono queste
Codice: Seleziona tutto
sudo apt-get install mplayer ffmpeg sox libsox-fmt-all
Codice: Seleziona tutto
#!/bin/bash
######################################################################
#2008 Creative2 a kubuntu user
#
#thanks a lot to :
#ximba for the great help
#samuele bordignon for stuff about multimedia and some
#part of code(base idea )
#irc bash script channel for suggestion fix and more thank u guys !!
#irc ubutuntu-it for a lots of stuff i can't say so much stuff here
######################################################################
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
#the Free Software Foundation, either version 3 of the License, or
#(at your option) any later version.
#This program is distributed in the hope that it will be useful,
#but WITHOUT ANY WARRANTY; without even the implied warranty of
#MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
#GNU General Public License for more details.
#You should have received a copy of the GNU General Public License
#along with this program. If not, see <http://www.gnu.org/licenses/>
#
#what is ?
#
#Sound loop with bash
#Nice parameters can be 1 3 , fade in and fade out
#error function
Error() {
clear
echo
echo "Fuoco Ubuntu Converter Module Audio Looper 0.0.5"
echo
echo "###################################################################"
echo "USAGE : "inputfile" fadein fadeout timeparameter "outputname.wav" "
echo "###################################################################"
echo
echo "fadein fade out and timeparameter must be in seconds!"
echo
echo "Error:you should write some parameters first!"
exit 1 ;
}
#
#
Nofile() {
clear
echo "[Fuoco Kubuntu Converter Module Audio looper] no track found------> does your track exist? Are you dummy?"
echo "No file found :'("
}
#################################################CHECK DEPENDECES###################################
for input in "$@" "$1" "$2" "$3" "$4" "$5" ;
do
echo $input
if [[ ! $input ]] ;then
Error
fi;done
#
##check if programs are installed or not
#########################################
for prog in mplayer ffmpeg sox;
do if ! type -p "$prog" >/dev/null;
then echo "$prog not found" >&2; exit 1;
fi; done
###################################################################################################
#
#
#
#
##########################################creating some variable ####################################
if [[ -d /tmp/blt ]]
then
echo "Temp Folder already exists for "$u" Skipping"
echo "Deleting..."
rm -Rf /tmp/blt
mkdir /tmp/blt
else
mkdir /tmp/blt
fi
echo "converting audio track to wav.....with this command line ....mplayer "$1" -ao pcm:file="/tmp/blt/temp1.wav""
mplayer "$1" -ao pcm:file="/tmp/blt/temp1.wav"
hours=$(ffmpeg -i "$1" 2>&1 | grep Duration | awk -F':' '{print $2}')
minutes=$(ffmpeg -i "$1" 2>&1 | grep Duration | awk -F':' '{print $3}')
seconds=$(ffmpeg -i "$1" 2>&1 | grep Duration | awk -F':' '{print $4}'| awk -F'.' '{print $1}')
totalsoundtrack=$(($seconds+$minutes*60+$hours*3600))
##
##
echo "###############################################"
echo $totalsoundtrack "s" audio track duration
echo "###############################################"
##
##
############################################end global variable######################################
#
#
#
#
###########################################START MAIN SCRIPT############################################
echo "###############################################"
echo "calculation...."
echo "###############################################"
if [[ $(bc <<< "$4 - $totalsoundtrack") = -* ]]; then
echo "Duration Audio track is > time parameter"
echo "i am doing a simple cut with fade in and fade out"
echo "###############################################"
echo "0%"
echo "###############################################"
echo "calculatipn.... no fadein\out "
middleduration=$(($4-$3))
echo "$middleduration"
if [[ ! -e "/tmp/blt/temp1.wav" ]]; then
Nofile
elif [[ -e "/tmp/blt/temp1.wav" ]]; then
echo "checking for sound track....found "
echo "###############################################"
echo "sox manipulation...fade in fade out..."
sox "/tmp/blt/temp1.wav" "$5" fade t $2 $middleduration $3
echo "###############################################"
echo "100%"
echo "###############################################"
fi
###########################################END FIRS INSTANCE###############################################
#
#
#
#
else
echo "----------------->Audio track is < time parameter"
echo "i am doing a simple cut with fade in and fade out"
echo "###############################################"
echo "0%"
echo "###############################################"
timetocopy=$(echo "scale=3; $4 / $totalsoundtrack " | bc )
echo "global time for looping $timecopy "
numberofloop="${timetocopy%.*}"
echo "number of loop" $numberofloop
noloops=0."${timetocopy#*.}"
echo "duration of no loop track" $noloops
echo $totalsoundtrack"s" "audio track duration"
###########################################START THE LOOP AND MERGING#######################################
#
#
#
###################################################LOOP FILES###############################################
middleduration=$(($totalsoundtrack-$3))
a=1
if [[ ! -e "/tmp/blt/temp1.wav" ]]; then
Nofile
echo "#####################Abort!##########################"
elif [[ -e "/tmp/blt/temp1.wav" ]]; then
echo "checking for sound track....found "
sox "/tmp/blt/temp1.wav" "/tmp/blt/1.wav" fade t $2 $middleduration $3
echo "Loop instance ....100%"
fi
for (( a=1; i<$numberofloop; i++ ))
do
echo "Looping for $numberofloop times"
cp "/tmp/blt/1.wav" /tmp/blt/$((a+1)).wav
a=$((a+1))
if [[ $a == 32 ]]; then
echo "sorry but your audio track is too small and sox can manage only 31 track soo please try with a longer audio track"
echo "#####################Abort!##########################"
exit 1
else
echo "checking for audio limit...ok < 31"
fi
done
echo "Looping for $numberofloop...done"
######################################################END LOOP FILES############################################
#
#
#####################################################CREATE NO LOOP FILES#######################################
calculate=$(echo "scale=3; $totalsoundtrack * $noloops" | bc)
echo "creating no loop......"
echo "brief"
echo "sound track duration" $totalsoundtrack
echo "time in seconds for no loops piece" $noloops
echo "calculate" $calculate
calculatenofloat=${calculate%.*}
echo $calculatenofloat
middleduration=$(echo "scale=3; $calculate-$3" | bc)
echo $middleduration
if [[ ! -e "/tmp/blt/temp1.wav" ]]; then
Nofile
echo "#####################Abort##########################"
elif [[ $calculatenofloat == 0 ]]; then
echo "No noloops needed...nice..continue"
echo "Last step: Merging files....wait please!"
cd "/tmp/blt"
files=( * )
sox * $5
echo "100%...done! :) "
echo "#####################Success!##########################"
elif [[ -e "/tmp/blt/temp1.wav" ]]; then
echo "checking for sound track....found "
sox "/tmp/blt/temp1.wav" "/tmp/blt/$a.wav" fade t $2 $middleduration $3 ; rm "/tmp/blt/temp1.wav"
echo "noloop.....100%"
#############################################START MERGING FILE WITH SOX#######################################################
echo "Last step: Merging files....wait please!"
cd "/tmp/blt"
files=( * )
sox * $5
##################################################END MERGING FILE WITH sox#######################################################
echo "100%....done! :) "
echo "#####################Success!##########################"
fi
###########################################################END###############################################################
#
#
#
######################################################END SCRIPT
fi