Coder Social home page Coder Social logo

mdabbagh88 / php-waveform-png Goto Github PK

View Code? Open in Web Editor NEW

This project forked from afreiday/php-waveform-png

0.0 1.0 0.0 139 KB

PHP MP3 PNG waveform generator

Home Page: http://www.andrewfreiday.com

License: BSD 2-Clause "Simplified" License

PHP 100.00%

php-waveform-png's Introduction

PHP MP3 PNG Waveform Generator

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.

This code was adapted by Andrew Freiday.

Requirements

Usage/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 -
  • Launch the script in your browser (e.g. http://localhost/php-waveform-png.php) and upload your MP3 file along with a selection of output settings (dimensions, colours, etc)

Image generation options

The initial form, when the script is loaded in your browser, allows you to specify some basic parameters for how the image is generated and displayed. Other than the obvious dimensions and colours, there are two advanced options:

  • "Draw flat-line" indicates whether or not to draw waveform point details that have a value of 0. Enabling this will allow you to see a flat, zero-level line where there is no audio playing. Otherwise it will be left blank
  • The "stereo waveform" option allows you to generate a single image with both left and right audio channels separately

Other notes

The detail of the waveform can be adjusted by modifying the DETAIL constant at the top of the script. The lower the number, the less data points are skipped, thus resulting in higher detail waveform.

The most time-consuming factor of the script is the LAME encoder, which first converts the uploaded MP3 into a 16 bit, mono, 8 KHz MP3 and finally to a WAV audio file. Unfortunately this doesn't seem to be possible to perform this in one step with the LAME encoder. If this script is to be modified to generate waveforms on the fly for the same MP3 multiple times, I recommend either storing a copy of the final WAV file or modifying the script to keep a dataset of the amplitude points so that the waveform can be redrawn much more quickly.

License

Please see the LICENSE file.

php-waveform-png's People

Contributors

afreiday avatar

Watchers

James Cloos avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.