";
print "".$thisfile."";
$delURL = $_SERVER['SCRIPT_NAME']."?display=".(isset($display)?$display:'')."&del=".urlencode($thisfile)."&category=".$category;
$tlabel = _("Delete");
$label = '';
echo "".$label." ";
}
}
}
function process_mohfile($mohfile,$onlywav=false,$volume=false) {
global $path_to_dir;
global $amp_conf;
$output = 0;
$returncode = 0;
$mohfile = escapeshellcmd($mohfile);
$origmohfile=$path_to_dir."/orig_".$mohfile;
if ($amp_conf['AMPMPG123']) {
if($onlywav) {
$newname = substr($mohfile,0,strrpos($mohfile,"."));
// If we are dealing with an MP3, we need to decode it to a wav file. mpg123 -w writes the converted output to $origmohfile.wav
if (strtoupper(substr($origmohfile,-4)) == '.MP3') {
$mpg123cmd = "mpg123 -w \"".substr($origmohfile,0,strrpos($origmohfile,".")).".wav\" \"".$origmohfile."\" 2>&1 ";
exec($mpg123cmd, $output, $returncode);
}
$newmohfile = $path_to_dir."/wav_".$newname.".wav";
//We need to take the output of mpg123 to use in the sox conversion. If we used $origmohfile directly then we would be bypassing mpg123. The mpg123 might not be needed on some systems if we had the sox version with mp3 compiled in. The standard rpmforge sox rpm does not have mp3 included.
//$soxcmd = "sox \"".$origmohfile."\"";
$soxcmd = "sox \"".substr($origmohfile,0,strrpos($origmohfile,".")).".wav\"";
$soxcmd .= " -r 8000 -c 1 \"".$newmohfile."\"";
if($volume){
$soxcmd .= " vol ".$volume;
}
$soxresample = " resample -ql ";
exec($soxcmd.$soxresample."2>&1", $output, $returncode);
if ($returncode != 0) {
// try it again without the resample in case the input sample rate was the same
//
exec("rm -rf \"".$newmohfile."\"");
exec($soxcmd."2>&1", $output, $returncode);
}
}
} else { // AMPMPG123
$newname = strtr($mohfile,"&", "_");
if(strstr($newname,".mp3")) {
$onlywav = false;
}
if(!$onlywav) {
$newmohfile=$path_to_dir."/". ((strpos($newname,'.mp3') === false) ? $newname.".mp3" : $newname);
$lamecmd="lame --cbr -m m -t -F \"".$origmohfile."\" \"".$newmohfile."\" 2>&1 ";
if (strpos($newmohfile,'.mp3') !== false) {
exec($lamecmd, $output, $returncode);
}
} else {
$newmohfile = $path_to_dir."/wav_".$newname;
$soxcmd = "sox \"".$origmohfile."\" -r 8000 -c 1 \"".$newmohfile."\" ";
$soxresample = "resample -ql ";
exec($soxcmd.$soxresample."2>&1", $output, $returncode);
if ($returncode != 0) {
// try it again without the resample in case the input sample rate was the same
//
exec("rm -rf \"".$newmohfile."\"");
exec($soxcmd."2>&1", $output, $returncode);
}
}
} // AMPMPG123
if ($returncode != 0) {
return join(" \n", $output);
}
$rmcmd="rm -f \"". $origmohfile."\"";
exec($rmcmd);
if ($amp_conf['AMPMPG123']) {
// If this started as an mp3, we converted it to a wav and then transcoded it from there,
// so we have two "original" files to delete
//
if (strpos($origmohfile,'.mp3') | strpos($origmohfile,'.MP3') !== false) {
$rmcmd="rm -f \"". substr($origmohfile,0,strrpos($origmohfile,".")).".wav\"";
exec($rmcmd);
}
} // AMPMPG123
return null;
}
?>