2 * Copyright (c) 1999-2000, Eric Moon.
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
9 * 1. Redistributions of source code must retain the above copyright
10 * notice, this list of conditions, and the following disclaimer.
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.
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.
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.
34 // Abstract audio-operation interface. Each implementation
35 // of IAudioOp represents an algorithm for processing
38 // IAudioOp instances are returned by implementations of
39 // IAudioOpFactory, responsible for finding the
40 // appropriate algorithm for a given format combination.
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
50 // e.moon 26aug99 Begun
52 #ifndef __IAudioOp_H__
53 #define __IAudioOp_H__
55 #include "AudioBuffer.h"
62 public: // *** HOST (NODE)
63 IAudioOpHost
* const host
;
65 public: // *** ctor/dtor
67 IAudioOpHost
* _host
) : host(_host
) {}
69 virtual ~IAudioOp() {}
71 public: // *** REQUIRED INTERFACE
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.)
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.)
85 // If the formats are identical, source and destination
86 // may reference the same buffer.
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.
93 virtual uint32
process(
94 const AudioBuffer
& source
,
95 AudioBuffer
& destination
,
97 uint32
& destinationFrame
,
98 uint32 framesRequired
,
99 bigtime_t performanceTime
) =0;
101 // Replace the given filter operation (responsibility for deleting
102 // it is yours, in case you want to keep it around for a while.)
104 virtual void replace(
107 public: // *** OPTIONAL INTERFACE
109 // Called when the host node is started, before any calls to
112 virtual void init() {}
114 // Return the number of input frames required before an output
115 // frame can be produced.
117 virtual uint32
bufferLatency() const { return 0; }
121 #endif /*__IAudioOp_H__*/