$output = array(); # Execute SoX to convert our audio # Trim silence from beginning and end (1% volume threshold) # Convert to 44.1kHz 16-bit stereo for consistency # Normalise to -0.1dB # Save as flac in inbox exec("sox \"" . $tempfile . "\" -b 16 \"" . $path . "/inbox/" . $md5 . ".flac\" silence 1 0.1 -72d reverse silence 1 0.1 -72d reverse channels 2 rate 44100 gain -n -0.1 2>&1", $output); if (strpos(implode($output), "FAIL")) { unlink($tempfile); die(json_encode(array("error" => "SoX could not convert file", "debug" => $output))); } switch ($_REQUEST["type"]) { case "music": $audio = new Track(); if (isset($_REQUEST["album"]) && $_REQUEST["album"] != "") { $audio->set_album($_REQUEST["album"]); } else { $audio->set_album("(none)"); } break; case "jingle": $audio = new Jingle(); break; case "advert": $audio = new Advert(); break; case "prerec": $audio = new Prerec(); break; } if (isset($_REQUEST["origin"])) {