Esempio n. 1
0
// in order to get one wave image instead of two
foreach ($argv as $val) {
    if (preg_match('/^wave_color=(.*)$/', $val, $m)) {
        $argv[] = 'prog_color=' . $m[1];
    }
}
// always use file mode
$argv[] = 'mode=file';
require_once 'JustWave.class.php';
// make class instance with ARGV parameters
$justwave = new JustWave('ARGV', $argv);
$numOfTotalFiles = $numOfSuccessFiles = 0;
foreach (glob($mask) as $fileName) {
    // create waves' images
    printf('Creating wave for %s', $fileName);
    $justwave->create($fileName);
    // rename image wave from key name to audio name
    if ($justwave->status == 'ok') {
        $name = pathinfo($justwave->audio, PATHINFO_FILENAME);
        $newName = str_replace($justwave->key, $name, $justwave->dataUrlWave);
        if ($newName) {
            rename($justwave->dataUrlWave, $newName);
            $justwave->dataUrlWave = $newName;
        }
        $numOfSuccessFiles++;
    } else {
        $justwave->dataUrlWave = '???';
    }
    printf(' in %s - %s (%s)' . "\n", $justwave->dataUrlWave, $justwave->status, $justwave->message);
    $numOfTotalFiles++;
}
Esempio n. 2
0
<?php

if (!isset($_GET['mode'])) {
    header('Location: script.php?mode=file&wave_color=F00&prog_color=F00&back_color=00AC00');
    die;
}
require_once 'JustWave.class.php';
// we accept parameters as GET data
// e.g.: script.php?mode=file&wave_color=F00&prog_color=F00&back_color=00AC00
$justwave = new JustWave('GET');
// create waveform image(s)
$justwave->create('media/We Wish You.mp3');
if ($justwave->status == 'ok') {
    echo 'Duration of We Wish You.mp3 = ' . $justwave->duration . '<br>';
    echo 'See waveform image under the link: <a href="' . $justwave->dataUrlWave . '">waveform</a>';
} else {
    echo 'Failed! Message = ' . $justwave->message;
}
Esempio n. 3
0
<?php

/* ***************************** */
/*  		JustWave project				 */
/*	(c) beotiger 2014-2015 AD		 */
/*	http://justwave.beotiger.com */
/*	https://github.com/beotiger  */
/*	email: beotiger@gmail.com		 */
/* ***************************** */
require_once 'JustWave.class.php';
if (isset($_POST['audio'])) {
    // make class instance with default to POST parameters
    $justwave = new JustWave();
    // create waveform image(s)
    $justwave->create($_POST['audio']);
    // return as JSON data
    die($justwave->json());
}
die(json_encode(array('status' => 'err', 'message' => 'No source audio parameter')));