diff options
Diffstat (limited to 'libs/ardour/ardour')
-rw-r--r-- | libs/ardour/ardour/audiofilesource.h | 9 | ||||
-rw-r--r-- | libs/ardour/ardour/silentfilesource.h | 66 | ||||
-rw-r--r-- | libs/ardour/ardour/source_factory.h | 1 |
3 files changed, 75 insertions, 1 deletions
diff --git a/libs/ardour/ardour/audiofilesource.h b/libs/ardour/ardour/audiofilesource.h index f91f78f6d9..4daa8c24f4 100644 --- a/libs/ardour/ardour/audiofilesource.h +++ b/libs/ardour/ardour/audiofilesource.h @@ -20,12 +20,19 @@ #ifndef __ardour_audiofilesource_h__ #define __ardour_audiofilesource_h__ +#include <exception> + #include <time.h> #include <ardour/audiosource.h> namespace ARDOUR { +class non_existent_source : public std::exception { + public: + virtual const char *what() const throw() { return "audio file does not exist"; } +}; + struct SoundFileInfo { float samplerate; uint16_t channels; @@ -125,7 +132,7 @@ class AudioFileSource : public AudioSource { /* constructor to be called for existing in-session files */ - AudioFileSource (Session&, const XMLNode&); + AudioFileSource (Session&, const XMLNode&, bool must_exit = true); int init (string idstr, bool must_exist); diff --git a/libs/ardour/ardour/silentfilesource.h b/libs/ardour/ardour/silentfilesource.h new file mode 100644 index 0000000000..92ef076a9b --- /dev/null +++ b/libs/ardour/ardour/silentfilesource.h @@ -0,0 +1,66 @@ +/* + Copyright (C) 2007 Paul Davis + + This program is free software; you can redistribute it and/or modify + it under the terms of the GNU General Public License as published by + the Free Software Foundation; either version 2 of the License, or + (at your option) any later version. + + This program is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the + GNU General Public License for more details. + + You should have received a copy of the GNU General Public License + along with this program; if not, write to the Free Software + Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA. + +*/ + +#ifndef __ardour_silentfilesource_h__ +#define __ardour_silentfilesource_h__ + +#include <ardour/audiofilesource.h> + +namespace ARDOUR { + +class SilentFileSource : public AudioFileSource { + public: + virtual ~SilentFileSource (); + + int update_header (nframes_t when, struct tm&, time_t) { return 0; } + int flush_header () { return 0; } + float sample_rate () const { return _sample_rate; } + + void set_length (nframes_t len); + + int read_peaks (PeakData *peaks, nframes_t npeaks, nframes_t start, nframes_t cnt, double samples_per_unit) const { + memset (peaks, 0, sizeof (PeakData) * npeaks); + return 0; + } + + bool destructive() const { return false; } + + protected: + + float _sample_rate; + + SilentFileSource (Session&, const XMLNode&, nframes_t nframes, float sample_rate); + + friend class SourceFactory; + + nframes_t read_unlocked (Sample *dst, nframes_t start, nframes_t cnt) const { + memset (dst, 0, sizeof (Sample) * cnt); + return cnt; + } + + nframes_t write_unlocked (Sample *dst, nframes_t cnt) { return 0; } + + void set_header_timeline_position () {} + +}; + +} // namespace ARDOUR + +#endif /* __ardour_audiofilesource_h__ */ + diff --git a/libs/ardour/ardour/source_factory.h b/libs/ardour/ardour/source_factory.h index 207015a253..cc3863904a 100644 --- a/libs/ardour/ardour/source_factory.h +++ b/libs/ardour/ardour/source_factory.h @@ -20,6 +20,7 @@ class SourceFactory { static sigc::signal<void,boost::shared_ptr<Source> > SourceCreated; static boost::shared_ptr<Source> create (Session&, const XMLNode& node); + static boost::shared_ptr<Source> createSilent (Session&, const XMLNode& node, nframes_t nframes, float sample_rate); // MIDI sources will have to be hacked in here somehow static boost::shared_ptr<Source> createReadable (Session&, std::string path, int chn, AudioFileSource::Flag flags, bool announce = true); |