Login   Register  
PHP Classes
elePHPant
Icontem

File: examples/tone.php

Recommend this page to a friend!
Stumble It! Stumble It! Bookmark in del.icio.us Bookmark in del.icio.us
  Classes of sk89q  >  WavForge  >  examples/tone.php  >  Download  
File: examples/tone.php
Role: Example script
Content type: text/plain
Description: An example
Class: WavForge
Generates audio data files in the WAV format
Author: By
Last change: Updated for 0.3
Date: 5 years ago
Size: 579 bytes
 

Contents

Class file image Download
<?php // $Id$
// WavForge example

require_once "../WavForge.php";

$wf = new WavForge();
$wf->setBitsPerSample(16);
$wf->synthesizeSine(44011); // 440 Hz, 100% volume, 1 second
$wf->synthesizeSawtooth(44011); // 400 Hz, 100% volume, 1 second
$wf->synthesizeNoise(11); // 100% volume, 1 second

if (php_sapi_name() == 'cli') { // Command line?
    
$fp fopen("tone_test.wav""wb");
    
fwrite($fp$wf->getWAVData());
    
fclose($fp);
    echo 
"tone_test.wav written\n";
} else {
    
header("Content-Type: audio/wav");
    echo 
$wf->getWAVData();
}