Download the PHP package maximal/audio-waveform without Composer
On this page you can find all versions of the php package maximal/audio-waveform. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package audio-waveform
Audio waveform generator on PHP with SoX
Install
Install SoX and some of its handlers for different audio formats.
Also you need a GD
module or other extension providing imagecreatetruecolor()
functionality.
For example, on Ubuntu:
Install this package using the Composer require
command:
or add the package name to the require
section in your composer.json
file:
and then run:
Use
In your PHP source:
One Phase
To get positive waveform only (i.e. one phase) pass onePhase
parameter set to true
:
Stereo source:
Mono source:
Settings
All settings are public static members of Waveform
class:
$linesPerPixel
is the count of lines per each pixel in horizontal axis. Default is8
.$samplesPerLine
is the count of samples per each line. Default is512
.$color
is the color of each line. Default is[95, 95, 95, 0.5]
meaning the dark grey color with 50% opacity.$backgroundColor
is the background color of the waveform file. Default is[245, 245, 245, 1]
meaning the light grey opaque background with 100% opacity.$axisColor
is the color of each axis. Default is[0, 0, 0, 0.15]
meaning the black color with 15% opacity.
Examples
Red waveform with half-transparent peaks:
Red waveform and fully transparent background:
Ubuntu Linux thumbnailer for Nautilus file explorer
-
Install the package to some directory. For example:
/opt/maximal/audio-waveform-php
-
Place the following code in the file
/usr/share/thumbnailers/waveform.thumbnailer
This repository contains an example thumbnailer file. See:
usr/share/thumbnailers/waveform.thumbnailer
.Also you can add other MIME types to the
MimeType
section of your thumbnaler file as long as they are supportable by SoX utility. -
Clear thumbnail cache and restart Nautilus:
- Since then all your audio files with specified MIME types will be shown in Nautilus using its small waveforms. By default they are WAV, MP3 and OGG files.
Integration with other libraries (e.g. wavesurfer.js)
Waveform
class has getWaveformData()
method for retrieving the waveform data without generating the image.
You can use it to integrate with different libraries, for instance, with the great
wavesurfer.js.
To get positive values only (i.e. one phase) pass onePhase
parameter set to true
:
Contact the author
- Website: https://maximals.ru (Russian)
- Sijeko Company: https://sijeko.ru (web, mobile, desktop applications development and graphic design)
- Personal GitHub: https://github.com/maximal
- Company’s GitHub: https://github.com/sijeko
All versions of audio-waveform with dependencies
ext-gd Version *