annotate data/fileio/WavFileWriter.h @ 998:e25dc8d57565

Add descriptions for writers; add housekeeping options to Sonic Annotator to list writers and formats
author Chris Cannam
date Mon, 13 Oct 2014 14:44:51 +0100
parents 59e7fe1b1003
children cc27f35aa75c
rev   line source
Chris@148 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@148 2
Chris@148 3 /*
Chris@148 4 Sonic Visualiser
Chris@148 5 An audio file viewer and annotation editor.
Chris@148 6 Centre for Digital Music, Queen Mary, University of London.
Chris@148 7 This file copyright 2006 Chris Cannam.
Chris@148 8
Chris@148 9 This program is free software; you can redistribute it and/or
Chris@148 10 modify it under the terms of the GNU General Public License as
Chris@148 11 published by the Free Software Foundation; either version 2 of the
Chris@148 12 License, or (at your option) any later version. See the file
Chris@148 13 COPYING included with this distribution for more information.
Chris@148 14 */
Chris@148 15
Chris@148 16 #ifndef _WAV_FILE_WRITER_H_
Chris@148 17 #define _WAV_FILE_WRITER_H_
Chris@148 18
Chris@148 19 #include <QString>
Chris@148 20
Chris@174 21 #include <sndfile.h>
Chris@174 22
Chris@148 23 class DenseTimeValueModel;
Chris@148 24 class MultiSelection;
Chris@674 25 class TempWriteFile;
Chris@148 26
Chris@148 27 class WavFileWriter
Chris@148 28 {
Chris@148 29 public:
Chris@684 30 /**
Chris@684 31 * Specify the method used to open the destination file.
Chris@684 32 *
Chris@684 33 * If WriteToTemporary, the destination will be opened as a
Chris@684 34 * temporary file which is moved to the target location when the
Chris@684 35 * WavFileWriter is closed or deleted (to avoid clobbering an
Chris@684 36 * existing file with a partially written replacement).
Chris@684 37 *
Chris@684 38 * If WriteToTarget, the target file will be opened directly
Chris@684 39 * (necessary when e.g. doing a series of incremental writes to a
Chris@684 40 * file while keeping it open for reading).
Chris@684 41 */
Chris@684 42 enum FileWriteMode {
Chris@684 43 WriteToTemporary,
Chris@684 44 WriteToTarget
Chris@684 45 };
Chris@684 46
Chris@929 47 WavFileWriter(QString path, int sampleRate, int channels,
Chris@684 48 FileWriteMode mode);
Chris@148 49 virtual ~WavFileWriter();
Chris@148 50
Chris@148 51 bool isOK() const;
Chris@148 52
Chris@148 53 virtual QString getError() const;
Chris@148 54
Chris@175 55 QString getPath() const { return m_path; }
Chris@175 56
Chris@174 57 bool writeModel(DenseTimeValueModel *source,
Chris@174 58 MultiSelection *selection = 0);
Chris@174 59
Chris@929 60 bool writeSamples(float **samples, int count); // count per channel
Chris@174 61
Chris@174 62 bool close();
Chris@148 63
Chris@148 64 protected:
Chris@148 65 QString m_path;
Chris@929 66 int m_sampleRate;
Chris@929 67 int m_channels;
Chris@674 68 TempWriteFile *m_temp;
Chris@174 69 SNDFILE *m_file;
Chris@148 70 QString m_error;
Chris@684 71
Chris@684 72 QString getWriteFilename() const;
Chris@148 73 };
Chris@148 74
Chris@148 75
Chris@148 76 #endif