This class maps the current analyzed wav file.

It has the methods to extract the chunk and the data from the file.

LICENSE: "Audero Wav Extractor" (from now on "The software") is released under the CC BY-NC 3.0 ("Creative Commons Attribution NonCommercial 3.0") license. More details can be found here: http://creativecommons.org/licenses/by-nc/3.0/

WARRANTY: The software is provided "as is", without warranty of any kind, express or implied, including but not limited to the warranties of merchantability, fitness for a particular purpose and noninfringement. In no event shall the authors or copyright holders be liable for any claim, damages or other liability, whether in an action of contract, tort or otherwise, arising from, out of or in connection with the software or the use or other dealings in the software.

package Audero\Audero\Wav
author Aurelio De Rosa
license CC BY-NC 3.0
link https://bitbucket.org/AurelioDeRosa/audero-wav-extractor

 Methods

The constructor of the object.

__construct(string $filePath) 

It initialized the object and set the filename of the wav file.

Parameters

$filePath

string

The filename, including the path, of the managed file wav

Retrieves the number of channels of the current file.

getChannelsNumber() : int | null

Returns

intnull

Retrieves the number of sample slices per second.

getDataRate() : int | null

Returns

intnull

This method get the current file duration

getDuration() : int

Returns

intThe duration of the file in milliseconds

Retrieves the path to the current file

getFilePath() : string

Returns

string

Get the headers of the current wav file.

getHeaders(int $headerSize) : array

If the headers contains not recognize chunks, these will be drop.

Parameters

$headerSize

int

&$headerSize The amount of bytes of the current wav headers (including dropped chunks)

Exceptions

\Exception If the wav file is not available or cannot be open.

Returns

arrayThe array that contains the headers (excluding dropped chunks)

Get the headers size in byte

getHeadersSize(bool $onlyRecognizedChunks) : int

Parameters

$onlyRecognizedChunks

bool

If the value is FALSE (default), the method will calculate the size of the actual headers. This means that, if there were any dropped chunks, these will be counted. Otherwise, the method returns just the bytes of the recognized chunks.

Returns

intThe number of bytes

Extract the portion from the original audio

getWavChunk(int $start, int $end) : string

Parameters

$start

int

The time in milliseconds from which to start

$end

int

The time in milliseconds from which to end

Exceptions

\Exception If the file wav is not available or cannot be open.

Returns

string

Convert the array that contain the headers in a string

headersToString() : string

Returns

string

Set the size of the data chunk.

setDataChunkSize(int $size) : void

Parameters

$size

int

The size of the data chunk

Set the path to the wav file that has to be managed

setFilePath(string $filePath) : void

Parameters

$filePath

string

The filename, including the path, of the managed file wav

Exceptions

\InvalidArgumentException If the file does not exist or if the file does not appear to be a wav.

 Properties

 

$filePath : string
 

$headers : array
 

$headersSize : int