Repeating a small mp3 overlay after each 10 seconds on a MP3 using SOX

Friday, May 2, 2014

Is there any way to repeat a overlay after each 10 seconds with mp3 file, using sox without trimming the original file. My code adds using trimming original file then adds overlay. Any help will be appreciated.

if(isset($_POST['submit']) && $_POST['submit']!="")
require_once 'class.mp3.php';

$mp3 = new mp3;



/*Split MP3*/

$mp3->cut_mp3($_FILES["file"]["name"], 'check1.mp3', 0, 700, 'frame', true);

$mp3->cut_mp3($_FILES["file"]["name"], 'check2.mp3', 700, -1, 'frame', true);

/*Part 1*/
$path1= $_SERVER['DOCUMENT_ROOT']."/ffmpeg/check1.mp3";

/*Part 2*/
$path2= $_SERVER['DOCUMENT_ROOT']."/ffmpeg/check2.mp3";

/*Overlay Sound*/
$overlay= $_SERVER['DOCUMENT_ROOT']."/ffmpeg/overlay.mp3";

/*Mix overlay with Part1 Sound*/
$new_path1= $_SERVER['DOCUMENT_ROOT']."/ffmpeg/check4.mp3";

/*Mix overlay with Part2 Sound*/
$new_path2= $_SERVER['DOCUMENT_ROOT']."/ffmpeg/check5.mp3";

/* Merge Both*/
$new_path3= $_SERVER['DOCUMENT_ROOT']."/ffmpeg/check6.mp3";

/*Mix overlay with Part1 Sound*/
echo exec('/usr/bin/sox --combine mix '.$path1. ' ' .$overlay . ' '.$new_path1 );

/*Mix overlay with Part2 Sound*/
echo exec('/usr/bin/sox --combine mix '.$path2. ' ' .$overlay . ' '.$new_path2 );

/* Merge Both*/
echo exec('/usr/bin/sox --combine sequence '.$new_path1. ' ' .$new_path2 . ' '.$new_path3 );