1 /* 2 * Copyright (c) 1999-2000, Eric Moon. 3 * All rights reserved. 4 * 5 * Redistribution and use in source and binary forms, with or without 6 * modification, are permitted provided that the following conditions 7 * are met: 8 * 9 * 1. Redistributions of source code must retain the above copyright 10 * notice, this list of conditions, and the following disclaimer. 11 * 12 * 2. Redistributions in binary form must reproduce the above copyright 13 * notice, this list of conditions, and the following disclaimer in the 14 * documentation and/or other materials provided with the distribution. 15 * 16 * 3. The name of the author may not be used to endorse or promote products 17 * derived from this software without specific prior written permission. 18 * 19 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 20 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21 * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 22 * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 23 * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 24 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 25 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 26 * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 27 * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 */ 30 31 32 // IAudioOp.h 33 // * PURPOSE 34 // Abstract audio-operation interface. Each implementation 35 // of IAudioOp represents an algorithm for processing 36 // streaming media. 37 // 38 // IAudioOp instances are returned by implementations of 39 // IAudioOpFactory, responsible for finding the 40 // appropriate algorithm for a given format combination. 41 // 42 // * NOTES 43 // 7sep99: 44 // +++++ moving back towards a raw interface approach; the host node 45 // can provide the state/parameter/event-queue access. 46 // See IAudioOpHost for the operations that the host node needs 47 // to provide. 48 // 49 // * HISTORY 50 // e.moon 26aug99 Begun 51 52 #ifndef __IAudioOp_H__ 53 #define __IAudioOp_H__ 54 55 #include "AudioBuffer.h" 56 57 class IAudioOpHost; 58 class ParameterSet; 59 60 class IAudioOp { 61 62 public: // *** HOST (NODE) 63 IAudioOpHost* const host; 64 65 public: // *** ctor/dtor 66 IAudioOp( 67 IAudioOpHost* _host) : host(_host) {} 68 69 virtual ~IAudioOp() {} 70 71 public: // *** REQUIRED INTERFACE 72 73 // Process a given source buffer to produce framesRequired 74 // frames of output (this may differ from the number of frames 75 // read from input if this is a resampling operation, 76 // or if the operation requires some amount of 'lookahead'.) 77 // The time at which the first destination frame should reach 78 // its destination is given by performanceTime (this should help 79 // wrt/ accurate parameter-change response.) 80 // 81 // Return the number of frames produced (if insufficient source 82 // frames were available, this may be less than framesRequired; 83 // it must never be greater.) 84 // NOTE 85 // If the formats are identical, source and destination 86 // may reference the same buffer. 87 // 88 // ANOTHER NOTE 89 // This method may well be called multiple times in response to 90 // a single call to the functor method (operator()) if one or 91 // more events occur midway through the buffer. 92 // 93 virtual uint32 process( 94 const AudioBuffer& source, 95 AudioBuffer& destination, 96 double& sourceFrame, 97 uint32& destinationFrame, 98 uint32 framesRequired, 99 bigtime_t performanceTime) =0; 100 101 // Replace the given filter operation (responsibility for deleting 102 // it is yours, in case you want to keep it around for a while.) 103 // 104 virtual void replace( 105 IAudioOp* oldOp) =0; 106 107 public: // *** OPTIONAL INTERFACE 108 109 // Called when the host node is started, before any calls to 110 // process(). 111 112 virtual void init() {} 113 114 // Return the number of input frames required before an output 115 // frame can be produced. 116 117 virtual uint32 bufferLatency() const { return 0; } 118 119 }; 120 121 #endif /*__IAudioOp_H__*/ 122