-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit 4739cb9
Showing
11 changed files
with
672 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
.idea/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
Copyright (c) 2015, Ruslan Slinkov | ||
Copyright (c) 2011, Andrew Freiday | ||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: | ||
|
||
- Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer. | ||
- Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,85 @@ | ||
PHP Waveform2PNG Library | ||
=== | ||
|
||
### About | ||
|
||
Generates PNG waveform images for a given MP3 file by converting it to WAV and processing amplitude points and plotting them on a GD canvas. | ||
|
||
New functional, fixes, OOP by [Ruslan Slinkov](http://github.com/slruslan). | ||
Original code by [Andrew Freiday](http://andrewfreiday.com). | ||
|
||
|
||
### Requirements | ||
|
||
- PHP 5.4+ | ||
- LAME MP3 Encoder bundle | ||
- Web server (Apache, etc -- unless modified to run as a command line script) | ||
|
||
### Installation | ||
|
||
- Copy to a location on your web server | ||
- Ensure that the 'lame' command is accessible and executable from that directory (for Windows systems, place the downloaded .exe and .dll as linked above into that same directory, or modify the script) | ||
- Ensure the directory support write persmissions, or specify an alternate temporary output directory that does - | ||
- Include library.php in your script. | ||
|
||
### Library usage | ||
|
||
- Include library in your script: | ||
> include "library.php"; | ||
- Initialize new instance of Waveform2Png class: | ||
> $graph = new Waveform2Png(); | ||
- Change the settings (or leave them default): | ||
> $graph->setHeight(200); | ||
> $graph->setWidth(1200); | ||
> $graph->setBackground(''); | ||
> $graph->setForeground('#35cc32'); | ||
> $graph->setDetail(20); | ||
> $graph->setType('waveform'); | ||
- Load your file and process it: | ||
> $graph->loadFile("test.mp3"); | ||
> $graph->process(); | ||
- Output image to browser or save it to file: | ||
> $graph->saveImage('waveform_example.png'); // Saves image to file | ||
> $graph->outputImage(); // Outputs image to browser | ||
### Image generation options | ||
|
||
Main settings are specified with methods | ||
|
||
- setHeight($height) - Sets output graph height to $height; | ||
- setWidth($width) - Sets output graph width to $width; | ||
- setBackground($hex) - Sets output background color to $hex (or transparent if $hex empty); | ||
- setForeground($hex) - Sets output foreground color to $hex; | ||
- setDefail($amount) - Sets detalization level to $amount. (The lower the number, the less data points are skipped, thus resulting in higher detail waveform); | ||
- setType($type) - Sets graph type to $type; | ||
|
||
There is also a method to create graph with different color regions: | ||
|
||
- addColor($timeMin, $timeMax, $color) - Sets color of graph to $color on region from $timeMin to $timeMax secs. Example: | ||
|
||
 | ||
|
||
|
||
### Available graph types | ||
|
||
##### Waveform: | ||
|
||
 | ||
|
||
##### Bars: | ||
|
||
 | ||
|
||
### Other notes | ||
|
||
Library is currently under development. | ||
|
||
Feel free to submit your suggestions and use issue tracker if you've found a bug. | ||
|
||
### License | ||
|
||
Please see the LICENSE file. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
include "../library.php"; | ||
|
||
// Create new instance of library | ||
$graph = new Waveform2Png(); | ||
|
||
// Set all required settings | ||
$graph->setHeight(200); | ||
$graph->setWidth(1200); | ||
$graph->setBackground(''); | ||
$graph->setForeground('#009cff'); | ||
// Defines level of detalization. | ||
// The bigger value means smaller detalization. | ||
$graph->setDetail(100); | ||
// Sets type of graph (available values: waveform, bars) | ||
$graph->setType('bars'); | ||
|
||
// Load file and process | ||
$graph->loadFile("test.mp3"); | ||
$graph->process(); | ||
|
||
// Save and output image | ||
$graph->saveImage('bars_example.png'); | ||
$graph->outputImage(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
<?php | ||
include "../library.php"; | ||
|
||
// Create new instance of library | ||
$graph = new Waveform2Png(); | ||
|
||
// Set all required settings | ||
$graph->setHeight(200); | ||
$graph->setWidth(1200); | ||
$graph->setBackground(''); | ||
$graph->setForeground('#d6d6d6'); | ||
// Defines level of detalization. | ||
// The bigger value means smaller detalization. | ||
$graph->setDetail(100); | ||
// Sets type of graph (available values: waveform, bars) | ||
$graph->setType('bars'); | ||
|
||
// Set different colors for different parts of graph | ||
$graph->addColor(5, 10, '#ff0303'); | ||
$graph->addColor(20, 30, '#a9ff03'); | ||
$graph->addColor(40, 50, '#03fcff'); | ||
$graph->addColor(60, 70, '#de03ff'); | ||
$graph->addColor(80, 100, '#ff0374'); | ||
$graph->addColor(120, 130, '#fffc03'); | ||
|
||
// Load file and process | ||
$graph->loadFile("test.mp3"); | ||
$graph->process(); | ||
|
||
// Save and output image | ||
$graph->saveImage('multicolor_example.png'); | ||
$graph->outputImage(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file not shown.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,24 @@ | ||
<?php | ||
include "../library.php"; | ||
|
||
// Create new instance of library | ||
$graph = new Waveform2Png(); | ||
|
||
// Set all required settings | ||
$graph->setHeight(200); | ||
$graph->setWidth(1200); | ||
$graph->setBackground(''); | ||
$graph->setForeground('#35cc32'); | ||
// Defines level of detalization. | ||
// The bigger value means smaller detalization. | ||
$graph->setDetail(20); | ||
// Sets type of graph (available values: waveform, bars) | ||
$graph->setType('waveform'); | ||
|
||
// Load file and process | ||
$graph->loadFile("test.mp3"); | ||
$graph->process(); | ||
|
||
// Save and output image | ||
$graph->saveImage('waveform_example.png'); | ||
$graph->outputImage(); |
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Oops, something went wrong.