Chris@148: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@148: Chris@148: /* Chris@148: Sonic Visualiser Chris@148: An audio file viewer and annotation editor. Chris@148: Centre for Digital Music, Queen Mary, University of London. Chris@148: This file copyright 2006 Chris Cannam. Chris@148: Chris@148: This program is free software; you can redistribute it and/or Chris@148: modify it under the terms of the GNU General Public License as Chris@148: published by the Free Software Foundation; either version 2 of the Chris@148: License, or (at your option) any later version. See the file Chris@148: COPYING included with this distribution for more information. Chris@148: */ Chris@148: Chris@148: #ifndef _WAV_FILE_WRITER_H_ Chris@148: #define _WAV_FILE_WRITER_H_ Chris@148: Chris@148: #include Chris@148: Chris@174: #include Chris@174: Chris@148: class DenseTimeValueModel; Chris@148: class MultiSelection; Chris@674: class TempWriteFile; Chris@148: Chris@148: class WavFileWriter Chris@148: { Chris@148: public: Chris@684: /** Chris@684: * Specify the method used to open the destination file. Chris@684: * Chris@684: * If WriteToTemporary, the destination will be opened as a Chris@684: * temporary file which is moved to the target location when the Chris@684: * WavFileWriter is closed or deleted (to avoid clobbering an Chris@684: * existing file with a partially written replacement). Chris@684: * Chris@684: * If WriteToTarget, the target file will be opened directly Chris@684: * (necessary when e.g. doing a series of incremental writes to a Chris@684: * file while keeping it open for reading). Chris@684: */ Chris@684: enum FileWriteMode { Chris@684: WriteToTemporary, Chris@684: WriteToTarget Chris@684: }; Chris@684: Chris@684: WavFileWriter(QString path, size_t sampleRate, size_t channels, Chris@684: FileWriteMode mode); Chris@148: virtual ~WavFileWriter(); Chris@148: Chris@148: bool isOK() const; Chris@148: Chris@148: virtual QString getError() const; Chris@148: Chris@175: QString getPath() const { return m_path; } Chris@175: Chris@174: bool writeModel(DenseTimeValueModel *source, Chris@174: MultiSelection *selection = 0); Chris@174: Chris@174: bool writeSamples(float **samples, size_t count); // count per channel Chris@174: Chris@174: bool close(); Chris@148: Chris@148: protected: Chris@148: QString m_path; Chris@148: size_t m_sampleRate; Chris@174: size_t m_channels; Chris@674: TempWriteFile *m_temp; Chris@174: SNDFILE *m_file; Chris@148: QString m_error; Chris@684: Chris@684: QString getWriteFilename() const; Chris@148: }; Chris@148: Chris@148: Chris@148: #endif