Main Page   Modules   Namespace List   Class Hierarchy   Alphabetical List   Compound List   File List   Namespace Members   Compound Members   File Members   Related Pages  

/root/src/subsynth/syn/Module/OpenALOutputModule.h

Go to the documentation of this file.
00001 
00002 /****************** <SYN heading BEGIN do not edit this line> *****************
00003  *
00004  * subsynth - modular audio synthesizer
00005  * subsynth is (C) Copyright 2001-2002 by Kevin Meinert
00006  *
00007  * Original Author: Kevin Meinert
00008  *
00009  * This library is free software; you can redistribute it and/or
00010  * modify it under the terms of the GNU Library General Public
00011  * License as published by the Free Software Foundation; either
00012  * version 2 of the License, or (at your option) any later version.
00013  *
00014  * This library is distributed in the hope that it will be useful,
00015  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00016  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00017  * Library General Public License for more details.
00018  *
00019  * You should have received a copy of the GNU Library General Public
00020  * License along with this library; if not, write to the
00021  * Free Software Foundation, Inc., 59 Temple Place - Suite 330,
00022  * Boston, MA 02111-1307, USA.
00023  *
00024  * -----------------------------------------------------------------
00025  * File:          $RCSfile: OpenALOutputModule.h,v $
00026  * Date modified: $Date: 2002/04/15 07:28:46 $
00027  * Version:       $Revision: 1.38 $
00028  * -----------------------------------------------------------------
00029  *
00030  ****************** <SYN heading END do not edit this line> ******************/
00031 /* Generated by Together */
00032 
00033 #ifndef OPENALOUTPUTMODULE_H
00034 #define OPENALOUTPUTMODULE_H
00035 
00036 #include "syn/Stream/OpenALAudioContext.h"
00037 #include "syn/Stream/OpenALAudioOStream.h"
00038 #include "syn/Core/SampleBufferQueue.h"
00039 #include "syn/Core/SampleBufferQueuePtr.h"
00040 #include "syn/Core/Module.h"
00041 
00042 namespace syn
00043 {
00049    class OpenALOutputModule : public Module
00050    {
00051    public:
00052       OpenALOutputModule();
00053       virtual ~OpenALOutputModule() {};
00054       virtual void update();
00055       
00056       virtual bool open();
00057       virtual bool isOpen() { return mWavStream.isOpen(); }
00058       void close();
00059       
00060       // set the amount of data to send to the sound api at one time
00061       // bigger increases audio quality, while increasing latency
00062       // smaller decreases audio quality, while decreasing latency
00063       void setOutputBufferSize( unsigned int size )
00064       {
00065          mBufSize = size;
00066          mTempBuf.resize( mBufSize );
00067          mTempBufIt = 0;
00068       }       
00069 
00071       virtual Module* clone() const
00072       {
00073          OpenALOutputModule* mod = new OpenALOutputModule;
00074          mod->setOutputBufferSize( mBufSize );
00075          return mod;
00076       }
00077       
00081       virtual void getParam( const std::string& key, MultivariateType& value )
00082       {
00083          if (key == "bufsize")
00084             value.setValue<unsigned int>( mBufSize );
00085       }
00086 
00088       virtual void setParam( const std::string& key, const MultivariateType& value )
00089       {
00090          if (key == "bufsize")
00091             this->setOutputBufferSize( value.getValue<unsigned int>() );
00092       }
00094    private:
00095       void writeSomeSilence();
00096 
00097       TerminalPtr mAmplitudeControlInput;
00098       TerminalPtr mMonoAudioInput;
00099 
00100       OpenALAudioOStream mWavStream;
00101       
00102       static OpenALAudioContext ctx;
00103       static bool mCtxInit;
00104       
00105       SampleBuffer1ss mTempBuf;
00106       unsigned int mTempBufIt;
00107       
00108 
00109       SampleBuffer1f* mReadBuf;
00110       unsigned int mReadBufIt;
00111       
00112       
00113       
00114       AudioFormat mOutputFmt;
00115       unsigned int mBufSize;
00116 
00117       
00121       /*#  Terminal lnkTerminal; */
00122 
00124       /*#  Terminal lnkTerminal; */
00125    };
00126 }
00127 
00128 #endif //OPENALOUTPUTMODULE_H

Generated at Mon Apr 15 09:26:07 2002 for subsynth by doxygen1.2.8.1 written by Dimitri van Heesch, © 1997-2001