2017 © Pedro Peláez
 

library wav

Simple PHP library for creating and handling WAV audio files

image

nkolosov/wav

Simple PHP library for creating and handling WAV audio files

  • Tuesday, May 3, 2016
  • by anexroid
  • Repository
  • 7 Watchers
  • 18 Stars
  • 6 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 3 Forks
  • 0 Open issues
  • 1 Versions
  • 0 % Grown

The README.md

WAV

Simple PHP Library for working with wav-files, (*1)

Installation

Installation using composer composer require nkolosov/wav, (*2)

Usage

Simple usage:, (*3)

    ...
    $file = Parser::fromFile('/path/to/file.wav');
    echo $file->getSampleRate(); //44100
    ...

You can create music file from code:, (*4)

    ...
    $sampleBuilder = new Piano(); //create piano sound generator

    //generate first notes of Für Elise (Ludwig van Beethoven)
    $samples = [
            $sampleBuilder->note('E', 5, 0.3),
            $sampleBuilder->note('D#', 5, 0.3),
            $sampleBuilder->note('E', 5, 0.3),
            $sampleBuilder->note('D#', 5, 0.3),
            $sampleBuilder->note('E', 5, 0.3),
            $sampleBuilder->note('H', 4, 0.3),
            $sampleBuilder->note('D', 5, 0.3),
            $sampleBuilder->note('C', 5, 0.3),
            $sampleBuilder->note('A', 4, 1),
    ];

    $builder = (new Builder())
         ->setAudioFormat(\Wav\WaveFormat::PCM)
         ->setNumberOfChannels(1)
         ->setSampleRate(\Wav\Builder::DEFAULT_SAMPLE_RATE)
         ->setByteRate(\Wav\Builder::DEFAULT_SAMPLE_RATE * 1 * 16 / 8)
         ->setBlockAlign(1 * 16 / 8)
         ->setBitsPerSample(16)
         ->setSamples($samples);

    $audio = $builder->build();
    $audio->returnContent(); //return wav-file content directly to browser/console
    ...

The Versions

03/05 2016

dev-master

9999999-dev

Simple PHP library for creating and handling WAV audio files

  Sources   Download

MIT License

The Requires

  • php >=5.6.0

 

by Nikita Kolosov