diff options
author | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
---|---|---|
committer | Robert Jonsson <spamatica@gmail.com> | 2011-03-07 19:01:11 +0000 |
commit | e40fc849149dd97c248866a4a1d026dda5e57b62 (patch) | |
tree | b12b358f3b3a0608001d30403358f8443118ec5f /attic/muse2-oom/muse2/muse/audioconvert.h | |
parent | 1bd4f2e8d9745cabb667b043171cad22c8577768 (diff) |
clean3
Diffstat (limited to 'attic/muse2-oom/muse2/muse/audioconvert.h')
-rw-r--r-- | attic/muse2-oom/muse2/muse/audioconvert.h | 129 |
1 files changed, 129 insertions, 0 deletions
diff --git a/attic/muse2-oom/muse2/muse/audioconvert.h b/attic/muse2-oom/muse2/muse/audioconvert.h new file mode 100644 index 00000000..039af912 --- /dev/null +++ b/attic/muse2-oom/muse2/muse/audioconvert.h @@ -0,0 +1,129 @@ +//========================================================= +// MusE +// Linux Music Editor +// $Id: audioconvert.h,v 1.1.1.1 2009/12/28 16:07:33 terminator356 Exp $ +// +// (C) Copyright 1999-2009 Werner Schweer (ws@seh.de) +// +// Audio converter module created by Tim terminator356 +//========================================================= + +#ifndef __AUDIOCONVERT_H__ +#define __AUDIOCONVERT_H__ + +#include <map> + +#ifdef RUBBERBAND_SUPPORT +#include <RubberBandStretcher.h> +#endif + +#include <samplerate.h> +#include <sys/types.h> + +//#include "eventbase.h" +class EventBase; +class EventList; + +class SndFileR; + +//--------------------------------------------------------- +// AudioConverter +//--------------------------------------------------------- + +class AudioConverter +{ + protected: + int _refCount; + off_t _sfCurFrame; + + public: + AudioConverter(); + ~AudioConverter(); + + AudioConverter* reference(); + static AudioConverter* release(AudioConverter* cv); + + //off_t readAudio(SndFileR& /*sf*/, off_t /*sfCurFrame*/, unsigned /*offset*/, float** /*buffer*/, + // int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/); + off_t readAudio(SndFileR& /*sf*/, unsigned /*offset*/, float** /*buffer*/, + int /*channels*/, int /*frames*/, bool /*doSeek*/, bool /*overwrite*/); + + virtual bool isValid() = 0; + virtual void reset() = 0; + virtual void setChannels(int ch) = 0; + //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/, + // int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo. + virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/, + int /*channels*/, int /*frames*/, bool /*overwrite*/) = 0; // Interleaved buffer if stereo. +}; + +//--------------------------------------------------------- +// SRCAudioConverter +//--------------------------------------------------------- + +class SRCAudioConverter : public AudioConverter +{ + int _type; + int _channels; + SRC_STATE* _src_state; + + public: + SRCAudioConverter(int channels, int type); + ~SRCAudioConverter(); + + virtual bool isValid() { return _src_state != 0; } + virtual void reset(); + virtual void setChannels(int ch); + //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/, + // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo. + virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/, + int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo. +}; + +#ifdef RUBBERBAND_SUPPORT + +//--------------------------------------------------------- +// RubberBandAudioConverter +//--------------------------------------------------------- + +class RubberBandAudioConverter : public AudioConverter +{ + int _options; + int _channels; + RubberBandStretcher* _rbs; + + public: + RubberBandAudioConverter(int channels, int options); + ~RubberBandAudioConverter(); + + virtual bool isValid() { return _rbs != 0; } + virtual void reset(); + virtual void setChannels(int ch); + //virtual off_t process(SndFileR& /*sf*/, off_t /*sfCurFrame*/, float** /*buffer*/, + // int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo. + virtual off_t process(SndFileR& /*sf*/, float** /*buffer*/, + int /*channels*/, int /*frames*/, bool /*overwrite*/); // Interleaved buffer if stereo. +}; + +#endif // RUBBERBAND_SUPPORT + +//--------------------------------------------------------- +// AudioConvertMap +//--------------------------------------------------------- + +typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::iterator iAudioConvertMap; +typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> >::const_iterator ciAudioConvertMap; + +//typedef std::map<EventBase*, AudioConverter*, std::less<EventBase*> > AudioConvertMap; +class AudioConvertMap : public std::map<EventBase*, AudioConverter*, std::less<EventBase*> > +{ + public: + void remapEvents(const EventList*); + iAudioConvertMap addEvent(EventBase*); + void removeEvent(EventBase*); + //AudioConverter* getConverter(const EventBase*); + iAudioConvertMap getConverter(EventBase*); +}; + +#endif + |