Chris@49: /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */ Chris@0: Chris@0: /* Chris@52: Sonic Visualiser Chris@52: An audio file viewer and annotation editor. Chris@52: Centre for Digital Music, Queen Mary, University of London. Chris@52: This file copyright 2006 Chris Cannam. Chris@0: Chris@52: This program is free software; you can redistribute it and/or Chris@52: modify it under the terms of the GNU General Public License as Chris@52: published by the Free Software Foundation; either version 2 of the Chris@52: License, or (at your option) any later version. See the file Chris@52: COPYING included with this distribution for more information. Chris@0: */ Chris@0: Chris@0: #ifndef _AUDIO_PLAY_SOURCE_H_ Chris@0: #define _AUDIO_PLAY_SOURCE_H_ Chris@0: Chris@1040: #include "BaseTypes.h" Chris@1040: Chris@389: struct Auditionable { Chris@389: virtual ~Auditionable() { } Chris@389: }; Chris@389: Chris@0: /** Chris@0: * Simple interface for audio playback. This should be all that the Chris@0: * ViewManager needs to know about to synchronise with playback by Chris@0: * sample frame, but it doesn't provide enough to determine what is Chris@0: * actually being played or how. See the audioio directory for a Chris@0: * concrete subclass. Chris@0: */ Chris@0: Chris@0: class AudioPlaySource Chris@0: { Chris@0: public: Chris@27: virtual ~AudioPlaySource() { } Chris@27: Chris@0: /** Chris@0: * Start playing from the given frame. If playback is already Chris@0: * under way, reseek to the given frame and continue. Chris@0: */ Chris@1040: virtual void play(sv_frame_t startFrame) = 0; Chris@0: Chris@0: /** Chris@0: * Stop playback. Chris@0: */ Chris@0: virtual void stop() = 0; Chris@0: Chris@0: /** Chris@0: * Return whether playback is currently supposed to be happening. Chris@0: */ Chris@0: virtual bool isPlaying() const = 0; Chris@0: Chris@0: /** Chris@0: * Return the frame number that is currently expected to be coming Chris@0: * out of the speakers. (i.e. compensating for playback latency.) Chris@0: */ Chris@1040: virtual sv_frame_t getCurrentPlayingFrame() = 0; Chris@0: Chris@0: /** Chris@0: * Return the current (or thereabouts) output levels in the range Chris@0: * 0.0 -> 1.0, for metering purposes. Chris@0: */ Chris@0: virtual bool getOutputLevels(float &left, float &right) = 0; Chris@40: Chris@40: /** Chris@249: * Return the sample rate of the source material -- any material Chris@249: * that wants to play at a different rate will sound wrong. Chris@249: */ Chris@1040: virtual sv_samplerate_t getSourceSampleRate() const = 0; Chris@249: Chris@249: /** Chris@1321: * Return the sample rate set by the target audio device (or 0 if Chris@1321: * the target hasn't told us yet). If the source and target Chris@1321: * sample rates differ, resampling will occur. Chris@1321: * Chris@1321: * Note that we don't actually do any processing at the device Chris@1321: * sample rate. All processing happens at the source sample rate, Chris@1321: * and then a resampler is applied if necessary at the interface Chris@1321: * between application and driver layer. Chris@40: */ Chris@1321: virtual sv_samplerate_t getDeviceSampleRate() const = 0; Chris@389: Chris@389: /** Chris@389: * Get the block size of the target audio device. This may be an Chris@389: * estimate or upper bound, if the target has a variable block Chris@389: * size; the source should behave itself even if this value turns Chris@389: * out to be inaccurate. Chris@389: */ Chris@928: virtual int getTargetBlockSize() const = 0; Chris@389: Chris@389: /** Chris@389: * Get the number of channels of audio that will be provided Chris@389: * to the play target. This may be more than the source channel Chris@389: * count: for example, a mono source will provide 2 channels Chris@389: * after pan. Chris@389: */ Chris@928: virtual int getTargetChannelCount() const = 0; Chris@389: Chris@389: /** Chris@389: * Set a plugin or other subclass of Auditionable as an Chris@389: * auditioning effect. Chris@389: */ Chris@389: virtual void setAuditioningEffect(Auditionable *) = 0; Chris@389: Chris@0: }; Chris@0: Chris@0: #endif