public function setWavData(&$data, $free = true)
    {
        // check preconditions
        if (is_resource($this->_fp)) $this->closeWav();


        // open temporary stream in memory
        $this->_fp = @fopen('php://memory', 'w+b');
        if (!is_resource($this->_fp)) {
            throw new WavFileException('Failed to open memory stream to write wav data. Use openWav() instead.');
        }

        // prepare stream
        fwrite($this->_fp, $data);
        rewind($this->_fp);

        // free the passed data
        if ($free) $data = null;

        // read the stream like a file
        return $this->readWav(true);
    }
public function setWavData(&$data, $free = true)
    {
        // check preconditions
        if (is_resource($this->_fp)) $this->closeWav();


        // open temporary stream in memory
        $this->_fp = @fopen('php://memory', 'w+b');
        if (!is_resource($this->_fp)) {
            throw new WavFileException('Failed to open memory stream to write wav data. Use openWav() instead.');
        }

        // prepare stream
        fwrite($this->_fp, $data);
        rewind($this->_fp);

        // free the passed data
        if ($free) $data = null;

        // read the stream like a file
        return $this->readWav(true);
    }
public function setWavData ( & $ data , $ free = true ) { // check preconditions if ( is_resource ( $ this -> _fp ) ) $ this -> closeWav ( ) ; // open temporary stream in memory $ this -> _fp = @ fopen ( 'php://memory' , 'w+b' ) ; if ( ! is_resource ( $ this -> _fp ) ) { throw new WavFileException ( 'Failed to open memory stream to write wav data. Use openWav() instead.' ) ; } // prepare stream fwrite ( $ this -> _fp , $ data ) ; rewind ( $ this -> _fp ) ; // free the passed data if ( $ free ) $ data = null ; // read the stream like a file return $ this -> readWav ( true ) ; }
Set the wav file data and properties from a wav file in a string.

@param string $data  (Required) The wav file data. Passed by reference.
@param bool $free  (Optional) True to free the passed $data after copying.
@throws WavFormatException
@throws WavFileException
Set the wav file data and properties from a wav file in a string .