11592Srgrimes/* 21592Srgrimes * Copyright (c) 1999-2000, Eric Moon. 31592Srgrimes * All rights reserved. 41592Srgrimes * 51592Srgrimes * Redistribution and use in source and binary forms, with or without 61592Srgrimes * modification, are permitted provided that the following conditions 71592Srgrimes * are met: 81592Srgrimes * 91592Srgrimes * 1. Redistributions of source code must retain the above copyright 101592Srgrimes * notice, this list of conditions, and the following disclaimer. 111592Srgrimes * 121592Srgrimes * 2. Redistributions in binary form must reproduce the above copyright 131592Srgrimes * notice, this list of conditions, and the following disclaimer in the 141592Srgrimes * documentation and/or other materials provided with the distribution. 151592Srgrimes * 161592Srgrimes * 3. The name of the author may not be used to endorse or promote products 171592Srgrimes * derived from this software without specific prior written permission. 181592Srgrimes * 191592Srgrimes * THIS SOFTWARE IS PROVIDED BY THE AUTHOR "AS IS" AND ANY EXPRESS OR 201592Srgrimes * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES 21262435Sbrueffer * OF TITLE, NON-INFRINGEMENT, MERCHANTABILITY AND FITNESS FOR A PARTICULAR 221592Srgrimes * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY 231592Srgrimes * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 241592Srgrimes * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 251592Srgrimes * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED 261592Srgrimes * AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR 271592Srgrimes * TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 281592Srgrimes * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 291592Srgrimes */ 301592Srgrimes 311592Srgrimes 321592Srgrimes// IAudioOp.h 331592Srgrimes// * PURPOSE 341592Srgrimes// Abstract audio-operation interface. Each implementation 351592Srgrimes// of IAudioOp represents an algorithm for processing 361592Srgrimes// streaming media. 3727074Ssteve// 381592Srgrimes// IAudioOp instances are returned by implementations of 3927074Ssteve// IAudioOpFactory, responsible for finding the 401592Srgrimes// appropriate algorithm for a given format combination. 41262434Sbrueffer// 42262434Sbrueffer// * NOTES 431592Srgrimes// 7sep99: 441592Srgrimes// +++++ moving back towards a raw interface approach; the host node 451592Srgrimes// can provide the state/parameter/event-queue access. 461592Srgrimes// See IAudioOpHost for the operations that the host node needs 471592Srgrimes// to provide. 481592Srgrimes// 491592Srgrimes// * HISTORY 501592Srgrimes// e.moon 26aug99 Begun 511592Srgrimes 521592Srgrimes#ifndef __IAudioOp_H__ 531592Srgrimes#define __IAudioOp_H__ 541592Srgrimes 551592Srgrimes#include "AudioBuffer.h" 561592Srgrimes 571592Srgrimesclass IAudioOpHost; 581592Srgrimesclass ParameterSet; 591592Srgrimes 601592Srgrimesclass IAudioOp { 611592Srgrimes 621592Srgrimespublic: // *** HOST (NODE) 631592Srgrimes IAudioOpHost* const host; 641592Srgrimes 651592Srgrimespublic: // *** ctor/dtor 661592Srgrimes IAudioOp( 671592Srgrimes IAudioOpHost* _host) : host(_host) {} 681592Srgrimes 691592Srgrimes virtual ~IAudioOp() {} 701592Srgrimes 711592Srgrimespublic: // *** REQUIRED INTERFACE 721592Srgrimes 731592Srgrimes // Process a given source buffer to produce framesRequired 741592Srgrimes // frames of output (this may differ from the number of frames 751592Srgrimes // read from input if this is a resampling operation, 761592Srgrimes // or if the operation requires some amount of 'lookahead'.) 771592Srgrimes // The time at which the first destination frame should reach 781592Srgrimes // its destination is given by performanceTime (this should help 791592Srgrimes // wrt/ accurate parameter-change response.) 801592Srgrimes // 811592Srgrimes // Return the number of frames produced (if insufficient source 821592Srgrimes // frames were available, this may be less than framesRequired; 831592Srgrimes // it must never be greater.) 841592Srgrimes // NOTE 851592Srgrimes // If the formats are identical, source and destination 861592Srgrimes // may reference the same buffer. 871592Srgrimes // 881592Srgrimes // ANOTHER NOTE 891592Srgrimes // This method may well be called multiple times in response to 901592Srgrimes // a single call to the functor method (operator()) if one or 911592Srgrimes // more events occur midway through the buffer. 921592Srgrimes // 931592Srgrimes virtual uint32 process( 941592Srgrimes const AudioBuffer& source, 951592Srgrimes AudioBuffer& destination, 961592Srgrimes double& sourceFrame, 971592Srgrimes uint32& destinationFrame, 981592Srgrimes uint32 framesRequired, 991592Srgrimes bigtime_t performanceTime) =0; 1001592Srgrimes 10127074Ssteve // Replace the given filter operation (responsibility for deleting 1021592Srgrimes // it is yours, in case you want to keep it around for a while.) 1031592Srgrimes // 1041592Srgrimes virtual void replace( 1051592Srgrimes IAudioOp* oldOp) =0; 10627074Ssteve 1071592Srgrimespublic: // *** OPTIONAL INTERFACE 1081592Srgrimes 1091592Srgrimes // Called when the host node is started, before any calls to 1101592Srgrimes // process(). 1111592Srgrimes 1121592Srgrimes virtual void init() {} 1131592Srgrimes 1141592Srgrimes // Return the number of input frames required before an output 1151592Srgrimes // frame can be produced. 1161592Srgrimes 1171592Srgrimes virtual uint32 bufferLatency() const { return 0; } 11827074Ssteve 11927074Ssteve}; 12027074Ssteve 1211592Srgrimes#endif /*__IAudioOp_H__*/ 1221592Srgrimes