public function generateNoise($duration = 1.0, $percent = 100)
    {
        $numChannels = $this->getNumChannels();
        $numSamples  = $this->getSampleRate() * $duration;
        $minAmp      = $this->getMinAmplitude();
        $maxAmp      = $this->getMaxAmplitude();
        $bitDepth    = $this->getBitsPerSample();

        for ($s = 0; $s < $numSamples; ++$s) {
            if ($bitDepth == 32) {
                $val = rand(-$percent * 10000, $percent * 10000) / 1000000;
            } else {
                $val = rand($minAmp, $maxAmp);
                $val = (int)($val * $percent / 100);
            }

            $this->_samples .= str_repeat(self::packSample($val, $bitDepth), $numChannels);
        }

        $this->setDataSize();  // implicit setSize(), setActualSize(), setNumBlocks()

        return $this;
    }
public function generateNoise($duration = 1.0, $percent = 100)
    {
        $numChannels = $this->getNumChannels();
        $numSamples  = $this->getSampleRate() * $duration;
        $minAmp      = $this->getMinAmplitude();
        $maxAmp      = $this->getMaxAmplitude();
        $bitDepth    = $this->getBitsPerSample();

        for ($s = 0; $s < $numSamples; ++$s) {
            if ($bitDepth == 32) {
                $val = rand(-$percent * 10000, $percent * 10000) / 1000000;
            } else {
                $val = rand($minAmp, $maxAmp);
                $val = (int)($val * $percent / 100);
            }

            $this->_samples .= str_repeat(self::packSample($val, $bitDepth), $numChannels);
        }

        $this->setDataSize();  // implicit setSize(), setActualSize(), setNumBlocks()

        return $this;
    }
public function generateNoise ( $ duration = 1.0 , $ percent = 100 ) { $ numChannels = $ this -> getNumChannels ( ) ; $ numSamples = $ this -> getSampleRate ( ) * $ duration ; $ minAmp = $ this -> getMinAmplitude ( ) ; $ maxAmp = $ this -> getMaxAmplitude ( ) ; $ bitDepth = $ this -> getBitsPerSample ( ) ; for ( $ s = 0 ; $ s < $ numSamples ; ++ $ s ) { if ( $ bitDepth == 32 ) { $ val = rand ( - $ percent * 10000 , $ percent * 10000 ) / 1000000 ; } else { $ val = rand ( $ minAmp , $ maxAmp ) ; $ val = ( int ) ( $ val * $ percent / 100 ) ; } $ this -> _samples .= str_repeat ( self :: packSample ( $ val , $ bitDepth ) , $ numChannels ) ; } $ this -> setDataSize ( ) ; // implicit setSize(), setActualSize(), setNumBlocks() return $ this ; }
Generate noise at the end of the wav for the specified duration and volume.

@param float $duration  (Optional) Number of seconds of noise to generate.
@param float $percent  (Optional) The percentage of the maximum amplitude to use. 100 = full amplitude.
Generate noise at the end of the wav for the specified duration and volume .