/** * @return AudioFile */ public function build() { $raw = ''; foreach ($this->samples as $sample) { $raw .= $sample->getData(); } $data = DataSection::createFromRaw($raw); $format = FormatSection::createFromParameters(['audioFormat' => $this->audioFormat, 'numberOfChannels' => $this->numberOfChannels, 'sampleRate' => $this->sampleRate, 'byteRate' => $this->byteRate, 'blockAlign' => $this->blockAlign, 'bitsPerSample' => $this->bitsPerSample]); $header = Header::createFromDataSection($data); return new AudioFile($header, $format, $data); }