annotate base/AudioPlaySource.h @ 1867:2654bf447a84

CSV reader tests and fixes - avoid creating null events for lines in which the timings could not be read
author Chris Cannam
date Thu, 11 Jun 2020 14:09:59 +0100
parents 618326c4ce4b
children
rev   line source
Chris@49 1 /* -*- c-basic-offset: 4 indent-tabs-mode: nil -*- vi:set ts=8 sts=4 sw=4: */
Chris@0 2
Chris@0 3 /*
Chris@52 4 Sonic Visualiser
Chris@52 5 An audio file viewer and annotation editor.
Chris@52 6 Centre for Digital Music, Queen Mary, University of London.
Chris@52 7 This file copyright 2006 Chris Cannam.
Chris@0 8
Chris@52 9 This program is free software; you can redistribute it and/or
Chris@52 10 modify it under the terms of the GNU General Public License as
Chris@52 11 published by the Free Software Foundation; either version 2 of the
Chris@52 12 License, or (at your option) any later version. See the file
Chris@52 13 COPYING included with this distribution for more information.
Chris@0 14 */
Chris@0 15
Chris@1338 16 #ifndef SV_AUDIO_PLAY_SOURCE_H
Chris@1338 17 #define SV_AUDIO_PLAY_SOURCE_H
Chris@0 18
Chris@1040 19 #include "BaseTypes.h"
Chris@1040 20
Chris@1828 21 #include <memory>
Chris@1828 22
Chris@389 23 struct Auditionable {
Chris@389 24 virtual ~Auditionable() { }
Chris@389 25 };
Chris@389 26
Chris@0 27 /**
Chris@0 28 * Simple interface for audio playback. This should be all that the
Chris@0 29 * ViewManager needs to know about to synchronise with playback by
Chris@0 30 * sample frame, but it doesn't provide enough to determine what is
Chris@0 31 * actually being played or how. See the audioio directory for a
Chris@0 32 * concrete subclass.
Chris@0 33 */
Chris@0 34
Chris@0 35 class AudioPlaySource
Chris@0 36 {
Chris@0 37 public:
Chris@27 38 virtual ~AudioPlaySource() { }
Chris@27 39
Chris@0 40 /**
Chris@0 41 * Start playing from the given frame. If playback is already
Chris@0 42 * under way, reseek to the given frame and continue.
Chris@0 43 */
Chris@1040 44 virtual void play(sv_frame_t startFrame) = 0;
Chris@0 45
Chris@0 46 /**
Chris@0 47 * Stop playback.
Chris@0 48 */
Chris@0 49 virtual void stop() = 0;
Chris@0 50
Chris@0 51 /**
Chris@0 52 * Return whether playback is currently supposed to be happening.
Chris@0 53 */
Chris@0 54 virtual bool isPlaying() const = 0;
Chris@0 55
Chris@0 56 /**
Chris@0 57 * Return the frame number that is currently expected to be coming
Chris@0 58 * out of the speakers. (i.e. compensating for playback latency.)
Chris@0 59 */
Chris@1040 60 virtual sv_frame_t getCurrentPlayingFrame() = 0;
Chris@0 61
Chris@0 62 /**
Chris@0 63 * Return the current (or thereabouts) output levels in the range
Chris@1338 64 * 0.0 -> 1.0, for metering purposes. The values returned are
Chris@1338 65 * peak values since the last call to this function was made
Chris@1338 66 * (i.e. calling this function also resets them).
Chris@0 67 */
Chris@0 68 virtual bool getOutputLevels(float &left, float &right) = 0;
Chris@40 69
Chris@40 70 /**
Chris@249 71 * Return the sample rate of the source material -- any material
Chris@249 72 * that wants to play at a different rate will sound wrong.
Chris@249 73 */
Chris@1040 74 virtual sv_samplerate_t getSourceSampleRate() const = 0;
Chris@249 75
Chris@249 76 /**
Chris@1321 77 * Return the sample rate set by the target audio device (or 0 if
Chris@1321 78 * the target hasn't told us yet). If the source and target
Chris@1321 79 * sample rates differ, resampling will occur.
Chris@1321 80 *
Chris@1321 81 * Note that we don't actually do any processing at the device
Chris@1321 82 * sample rate. All processing happens at the source sample rate,
Chris@1321 83 * and then a resampler is applied if necessary at the interface
Chris@1321 84 * between application and driver layer.
Chris@40 85 */
Chris@1321 86 virtual sv_samplerate_t getDeviceSampleRate() const = 0;
Chris@389 87
Chris@389 88 /**
Chris@389 89 * Get the block size of the target audio device. This may be an
Chris@389 90 * estimate or upper bound, if the target has a variable block
Chris@389 91 * size; the source should behave itself even if this value turns
Chris@389 92 * out to be inaccurate.
Chris@389 93 */
Chris@928 94 virtual int getTargetBlockSize() const = 0;
Chris@389 95
Chris@389 96 /**
Chris@389 97 * Get the number of channels of audio that will be provided
Chris@389 98 * to the play target. This may be more than the source channel
Chris@389 99 * count: for example, a mono source will provide 2 channels
Chris@389 100 * after pan.
Chris@389 101 */
Chris@928 102 virtual int getTargetChannelCount() const = 0;
Chris@389 103
Chris@389 104 /**
Chris@389 105 * Set a plugin or other subclass of Auditionable as an
Chris@1828 106 * auditioning effect. The Auditionable is shared with the caller:
Chris@1828 107 * the expectation is that the caller may continue to modify its
Chris@1828 108 * parameters etc during auditioning.
Chris@389 109 */
Chris@1828 110 virtual void setAuditioningEffect(std::shared_ptr<Auditionable>) = 0;
Chris@389 111
Chris@0 112 };
Chris@0 113
Chris@0 114 #endif