Download the PHP package remithefox/wave without Composer

On this page you can find all versions of the php package remithefox/wave. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.

FAQ

After the download, you have to make one include require_once('vendor/autoload.php');. After that you have to import the classes with use statements.

Example:
If you use only one package a project is not needed. But if you use more then one package, without a project it is not possible to import the classes with use statements.

In general, it is recommended to use always a project to download your libraries. In an application normally there is more than one library needed.
Some PHP packages are not free to download and because of that hosted in private repositories. In this case some credentials are needed to access such packages. Please use the auth.json textarea to insert credentials, if a package is coming from a private repository. You can look here for more information.

  • Some hosting areas are not accessible by a terminal or SSH. Then it is not possible to use Composer.
  • To use Composer is sometimes complicated. Especially for beginners.
  • Composer needs much resources. Sometimes they are not available on a simple webspace.
  • If you are using private repositories you don't need to share your credentials. You can set up everything on our site and then you provide a simple download link to your team member.
  • Simplify your Composer build process. Use our own command line tool to download the vendor folder as binary. This makes your build process faster and you don't need to expose your credentials for private repositories.
Please rate this library. Is it a good library?

Informations about the package wave

remithefox/wave

A PHP library that helps you create WAVE files

Installation

Composer

Usage

Creating new wave file

You can create wave file by static method Wave::createNew(). e.g.:

More comfortable way to create new wave file is using builder. e.g.:

builder setters:

setters default significance
setNumberOfChannels() 2 number of channels
setSampleRate() 44100 number of samples per seconds1
setBitsPerSample() 16 bits per sample (highly recommend to use 8 or 16)
setFloatDecorator() false use float decorator (wave object will be packed in decorator that calculate sample values to float in range -1..1)
  1. Sample rate must be at least 2 times grater than the highest frequency to avoid aliasing (Nyquist frequency). Most often sampling frequency is 44.1kHz (44 100Hz) and this sample rate is recommended for music. For human speech sampling frequency must be at least 8kHz (8 000Hz).

Opening existing files

To open exiting file use method Wave::createFromFile()

Float decorator

Whether you use the float decorator or not, you will get an object that implements the interface RemiTheFox\Wave\WaveInterface. If you use decorator you can read and write float values from -1 to 1, otherwise you can read and write integer values from 0 to 255 for 8-bit files or from 0 to 65535 for 16-bit files.

Getters

getter type significance
isWritable() bool returns true if file is writable
getNumberOfChannels() int returns number of channels
getSampleRate() int returns number of sample per second
getBytesPerSecond() int returns number of data bytes per second
getBytesPerSampleAllChannels() int returns number of bytes per sample for all channels
getBitsPerSample() int returns number of bits of sample value for single channel
getBytesPerSample() int returns number of bytes per sample for single channel
getNumberOfSamples() int returns number of samples
getPosition() int returns number of current sample

Navigation in file

Seeking

To seek use method WaveInterface::seek()

NOTICE: first sample has number 0.

Getting current position

to get current position use method WaveInterface::getPosition()

NOTICE: first sample has number 0.

Human friendly time

Position of some specified time depends on file sample rate, so if you want to go to sample on 1:30 you need to go to sample number Fs*90. It isn't comfortable, so you can use method WaveInterface::time() e.g.:

method takes 2 or 3 arguments:

argument type required significance
minutes float YES number of minutes
seconds float YES number of seconds
samples int NO offset in samples

Reading

To read use method WaveInterface::read() e.g.:

Method returns array of values of all channels in single sample and goes one sample forward.

Writing

To write use method WaveInterface::write() e.g.:

Method write values of all channels in single sample and goes one sample forward. Values should be supplied as array.

Array access and iterating

\RemiTheFox\Wave\WaveInterface extends \ArrayAccess and \Iterator so you can use it as array.

Array access

Iterating

Generators

You can use method WaveInterface::toGenerator() to create generator which yields samples. Method can be called with start sample number in argument or without arguments (starts from file begin). e.g.:

You can also use some other generator (or any other iterable type) to write samples using method WaveInterface::toGenerator(). e.g.:

Exceptions

All exceptions are in namespace \RemiTheFox\Wave\Exception implements \RemiTheFox\Wave\Exception\WaveExceptionInterface.

exception significance
CannotCreateFileException Cannot create file. It can be caused for example by permissions or lack of disk space.
CannotOpenFileException Error during opening file.
FileIsNotReadableException Cannot open file. File is not readable.
FileIsNotWritableException Cannot write to file. File is not writable.
FileNotFoundException File not exists.
FloatDecoratorNotFound Cannot decorate file other than 8-bit and 16-bit.
FormatNotSupportedException Wave file format is other than PCM.
HeaderCorruptedException Wave file header is corrupted. Header markers not found.
HeaderDataInconsistentException Wave file header data is inconsistent.
NotApplicableBitPerSampleException Tried to decorate Wave object using wrong decorator.

long text? ASCII-fox:


All versions of wave with dependencies

PHP Build Version
Package Version
Requires php Version >=8.0
Composer command for our command line client (download client) This client runs in each environment. You don't need a specific PHP version etc. The first 20 API calls are free. Standard composer command

The package remithefox/wave contains the following files

Loading the files please wait ....