annotate data/fileio/WavFileWriter.h @ 1220:a68d407f9752 msvc2015_64

Further MSVC build stuff. Committing this as-is because it's building and running now, but there's a lot to tidy up.
author Chris Cannam
date Wed, 19 Oct 2016 17:33:32 +0100
parents a1cd5abcb38b
children 3aea4f7617bb
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@1038 23 #include "base/BaseTypes.h"
Chris@1038 24
Chris@148 25 class DenseTimeValueModel;
Chris@148 26 class MultiSelection;
Chris@674 27 class TempWriteFile;
Chris@148 28
Chris@148 29 class WavFileWriter
Chris@148 30 {
Chris@148 31 public:
Chris@684 32 /**
Chris@684 33 * Specify the method used to open the destination file.
Chris@684 34 *
Chris@684 35 * If WriteToTemporary, the destination will be opened as a
Chris@684 36 * temporary file which is moved to the target location when the
Chris@684 37 * WavFileWriter is closed or deleted (to avoid clobbering an
Chris@684 38 * existing file with a partially written replacement).
Chris@684 39 *
Chris@684 40 * If WriteToTarget, the target file will be opened directly
Chris@684 41 * (necessary when e.g. doing a series of incremental writes to a
Chris@684 42 * file while keeping it open for reading).
Chris@684 43 */
Chris@684 44 enum FileWriteMode {
Chris@684 45 WriteToTemporary,
Chris@684 46 WriteToTarget
Chris@684 47 };
Chris@684 48
Chris@1040 49 WavFileWriter(QString path, sv_samplerate_t sampleRate, int channels,
Chris@684 50 FileWriteMode mode);
Chris@148 51 virtual ~WavFileWriter();
Chris@148 52
Chris@148 53 bool isOK() const;
Chris@148 54
Chris@148 55 virtual QString getError() const;
Chris@148 56
Chris@175 57 QString getPath() const { return m_path; }
Chris@175 58
Chris@174 59 bool writeModel(DenseTimeValueModel *source,
Chris@174 60 MultiSelection *selection = 0);
Chris@174 61
Chris@1038 62 bool writeSamples(float **samples, sv_frame_t count); // count per channel
Chris@174 63
Chris@174 64 bool close();
Chris@148 65
Chris@148 66 protected:
Chris@148 67 QString m_path;
Chris@1040 68 sv_samplerate_t m_sampleRate;
Chris@929 69 int m_channels;
Chris@674 70 TempWriteFile *m_temp;
Chris@174 71 SNDFILE *m_file;
Chris@148 72 QString m_error;
Chris@684 73
Chris@684 74 QString getWriteFilename() const;
Chris@148 75 };
Chris@148 76
Chris@148 77
Chris@148 78 #endif