2

i want to use sound library for project in php. neeed functionality like

  • high performance
  • sound optimisation
  • open source
  • mixing sound

is that any best PECL suit ? any github or sourceforge project?

sandeep
  • 2,244
  • 1
  • 23
  • 38
  • 2
    What is a "sound library"? What's it supposed to do besides having generic attributes like "high performance"? – deceze Feb 04 '12 at 10:48
  • Assuming your php-project is web-based I highly recommend not doing the audio-processing within your php-application, as the response to the user is held back for as long as it takes processing the file, thus making your site unresponsive. You could use cron jobs or a job queue instead. – dbrumann Feb 04 '12 at 10:56
  • sound library in sense of audio processing tool usable using php.high performance in sense of high speed with optimised cpu processing – sandeep Feb 04 '12 at 11:20
  • 1
    dbrumann php is not limited to only web many console application made in ReactPHP as fully async non blocking IO. If you care you can see a project CharlotteDunois/Yasmin which is a discord client which is a console application runs in terminal (only) and performs like a user moderate things upon commands collect data process it and send back... It creates realtime active gateway which runs in endless loop until you manually do ctrl-c, everything works asyncronously and hence it doesn't block stream of data coming when it process –  Aug 03 '18 at 03:33

2 Answers2

2

You won't be able to do audio processing correctly with PHP alone, you should take a look at the following:

http://sox.sourceforge.net/

http://ffmpeg.org/

http://lame.sourceforge.net/

You can execute the above apps through PHP using something like shell_exec();

A better bet is to have a cron job running that does batch processing.

ghstcode
  • 2,902
  • 1
  • 20
  • 30
0

You can use this library to fetch idv3 information from music files getID3()

Something like this:

<?
require_once('../getid3/getid3.php');

// Initialize getID3 engine
$getID3 = new getID3;

// Analyze file and store returned data in $ThisFileInfo
$ThisFileInfo = $getID3->analyze($filename);

/*
 Optional: copies data from all subarrays of [tags] into [comments] so
 metadata is all available in one location for all tag formats
 metainformation is always available under [tags] even if this is not called
*/
getid3_lib::CopyTagsToComments($ThisFileInfo);

echo $ThisFileInfo['comments_html']['artist'][0]; // artist from any/all available tag formats
echo $ThisFileInfo['tags']['id3v2']['title'][0];  // title from ID3v2
echo $ThisFileInfo['audio']['bitrate'];           // audio bitrate
echo $ThisFileInfo['playtime_string'];            // playtime in minutes:seconds, formatted string

/*
 if you want to see ALL the output, uncomment this line:
*/
echo '<pre>'.htmlentities(print_r($ThisFileInfo, true)).'</pre>';
?>

If you want to resample/recode your music files, you can do that with LAME.

Fixed bit rate 128kbps encoding:
lame sample.wav sample.mp3

Fixed bit rate jstereo 128kbps encoding, high quality (recommended):
lame -h sample.wav sample.mp3

Average bit rate 112kbps encoding:
lame --abr 112 sample.wav sample.mp3

Fast encode, low quality (no psycho-acoustics):
lame -f sample.wav sample.mp3

Variable bitrate (use -V n to adjust quality/filesize):
lame -h -V 6 sample.wav sample.mp3
Fedya Skitsko
  • 337
  • 1
  • 10