public function openWav($filename, $readData = true)
    {
        // check preconditions
        if (!file_exists($filename)) {
            throw new WavFileException('Failed to open "' . $filename . '". File not found.');
        } elseif (!is_readable($filename)) {
            throw new WavFileException('Failed to open "' . $filename . '". File is not readable.');
        } elseif (is_resource($this->_fp)) {
            $this->closeWav();
        }


        // open the file
        $this->_fp = @fopen($filename, 'rb');
        if (!is_resource($this->_fp)) {
            throw new WavFileException('Failed to open "' . $filename . '".');
        }

        // read the file
        return $this->readWav($readData);
    }