WavFileWriter.h
Go to the documentation of this file.
1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
2 
3 /*
4  Sonic Visualiser
5  An audio file viewer and annotation editor.
6  Centre for Digital Music, Queen Mary, University of London.
7  This file copyright 2006 Chris Cannam.
8 
9  This program is free software; you can redistribute it and/or
10  modify it under the terms of the GNU General Public License as
11  published by the Free Software Foundation; either version 2 of the
12  License, or (at your option) any later version. See the file
13  COPYING included with this distribution for more information.
14 */
15 
16 #ifndef SV_WAV_FILE_WRITER_H
17 #define SV_WAV_FILE_WRITER_H
18 
19 #include <QString>
20 
21 #ifdef Q_OS_WIN
22 #include <windows.h>
23 #define ENABLE_SNDFILE_WINDOWS_PROTOTYPES 1
24 #endif
25 
26 #include <sndfile.h>
27 
28 #include "base/BaseTypes.h"
29 
31 class MultiSelection;
32 class TempWriteFile;
33 
35 {
36 public:
52  };
53 
54  WavFileWriter(QString path, sv_samplerate_t sampleRate, int channels,
55  FileWriteMode mode);
56  virtual ~WavFileWriter();
57 
58  bool isOK() const;
59 
60  virtual QString getError() const;
61 
62  QString getPath() const { return m_path; }
63 
64  bool writeModel(DenseTimeValueModel *source,
65  MultiSelection *selection = 0);
66 
68  bool writeSamples(const float *const *samples, sv_frame_t count);
69 
71  bool putInterleavedFrames(const floatvec_t &frames);
72 
73  bool close();
74 
75 protected:
76  QString m_path;
80  SNDFILE *m_file;
81  QString m_error;
82 
83  QString getWriteFilename() const;
84 };
85 
86 
87 #endif
bool isOK() const
double sv_samplerate_t
Sample rate.
Definition: BaseTypes.h:51
sv_samplerate_t m_sampleRate
Definition: WavFileWriter.h:77
QString m_error
Definition: WavFileWriter.h:81
int64_t sv_frame_t
Frame index, the unit of our time axis.
Definition: BaseTypes.h:31
virtual ~WavFileWriter()
virtual QString getError() const
QString m_path
Definition: WavFileWriter.h:76
std::vector< float, breakfastquay::StlAllocator< float > > floatvec_t
Definition: BaseTypes.h:53
WavFileWriter(QString path, sv_samplerate_t sampleRate, int channels, FileWriteMode mode)
bool writeModel(DenseTimeValueModel *source, MultiSelection *selection=0)
A class that manages the creation of a temporary file with a given prefix and the renaming of that fi...
Definition: TempWriteFile.h:26
QString getPath() const
Definition: WavFileWriter.h:62
FileWriteMode
Specify the method used to open the destination file.
Definition: WavFileWriter.h:49
TempWriteFile * m_temp
Definition: WavFileWriter.h:79
Base class for models containing dense two-dimensional data (value against time). ...
QString getWriteFilename() const
SNDFILE * m_file
Definition: WavFileWriter.h:80
bool putInterleavedFrames(const floatvec_t &frames)
As writeSamples, but compatible with WavFileReader api. More expensive.
bool writeSamples(const float *const *samples, sv_frame_t count)
Write samples from raw arrays; count is per-channel.