Login   Register  
PHP Classes
elePHPant
Icontem

File: test_wavedit.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of Thi Dinh  >  WavEdit  >  test_wavedit.php  >  Download  
File: test_wavedit.php
Role: Example script
Content type: text/plain
Description: sample test script
Class: WavEdit
Manipulate audio files in the WAV format
Author: By
Last change: add instruction
Date: 2005-09-30 08:24
Size: 1,746 bytes
 

Contents

Class file image Download
<?
//== Sample WavEdit - Echo ==//
//== Demo url: http://www.pviet.com/wavedit/ ==//

$start get_microtime();            //start counting time

//load class
include("wavedit.class.php");
$wav = new wavEdit();

//load wav files
$wFiles = array("welcometo.wav","pviet.wav","dotcom.wav");
$wData $wav->getFiles($wFiles);

//view wav images
$wav->drawImgWave();
$wav->viewImage();


//join all wav files
$wav->joinFiles();

//write join file to before.wav
$wav->writeWavFile("before");
$wav->drawImgWave("before");
$wav->viewImage("before");

//set crop array
$arrCropHead = array(
                              array(
'pos'=>'head','val'=>10),
                              array(
'pos'=>'head','val'=>130),
                              array(
'pos'=>'head','val'=>50),
                        );
                        
$arrCropTail = array(
                             array(
'pos'=>'tail','val'=>20),
                             array(
'pos'=>'tail','val'=>20),
                             array(
'pos'=>'tail','val'=>20),
                        );

//load wav files again
$wData $wav->getFiles($wFiles);

//crop wav file
$wav->cropFiles($arrCropHead);
$wav->cropFiles($arrCropTail);
$wav->writeWavFile("crop");
$wav->drawImgWave("crop");
$wav->viewImage("crop");

//join again
$wav->joinFiles();
$wav->writeWavFile("after");
$wav->drawImgWave("after");
$wav->viewImage("after");

//adjust volume of join file
// option: 1 = nochange
//         >1 = louder
//         <1 = lower

$wav->setVolume(1.5);
$wav->writeWavFile("vol2");
$wav->drawImgWave("vol2");

//view image - include of wav header
$wav->viewImage("vol2","viewheader");


//== check process time ==//
$end get_microtime();
echo 
"time process: " round($end-$start,4);
function 
get_microtime(){
    list(
$usec$sec) = explode(" ",microtime()); 
    return ((float)
$usec + (float)$sec); 
}

?>