pl-nk v0.4.5
Plonk|Plink|Plank are a set of cross-platform C/C++ frameworks for audio software development
plonk_RTAudioAudioHostInline.h
00001 /*
00002  -------------------------------------------------------------------------------
00003  This file is part of the Plink, Plonk, Plank libraries
00004  by Martin Robinson
00005  
00006  http://code.google.com/p/pl-nk/
00007  
00008  Copyright University of the West of England, Bristol 2011-14
00009  All rights reserved.
00010  
00011  Redistribution and use in source and binary forms, with or without
00012  modification, are permitted provided that the following conditions are met:
00013  
00014  * Redistributions of source code must retain the above copyright
00015    notice, this list of conditions and the following disclaimer.
00016  * Redistributions in binary form must reproduce the above copyright
00017    notice, this list of conditions and the following disclaimer in the
00018    documentation and/or other materials provided with the distribution.
00019  * Neither the name of University of the West of England, Bristol nor 
00020    the names of its contributors may be used to endorse or promote products
00021    derived from this software without specific prior written permission.
00022  
00023  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
00024  ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
00025  WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 
00026  DISCLAIMED. IN NO EVENT SHALL UNIVERSITY OF THE WEST OF ENGLAND, BRISTOL BE 
00027  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR 
00028  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE 
00029  GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 
00030  HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 
00031  LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT 
00032  OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 
00033  
00034  This software makes use of third party libraries. For more information see:
00035  doc/license.txt included in the distribution.
00036  -------------------------------------------------------------------------------
00037  */
00038 
00039 #if PLANK_INLINING_FUNCTIONS
00040 
00041 template<class SampleType>
00042 static inline int rtAudioCallback(void *outputBuffer, void *inputBuffer,
00043                                   unsigned int nBufferFrames,
00044                                   double streamTime,
00045                                   RtAudioStreamStatus status,
00046                                   void *userData)
00047 {
00048     RTAudioAudioHostBase<SampleType>* host = static_cast<RTAudioAudioHostBase<SampleType>*> (userData);
00049     return host->callback ((SampleType*)outputBuffer, (const SampleType*)inputBuffer,
00050                            nBufferFrames, streamTime, status);
00051 }
00052 
00053 
00054 static void rtAudioErrorCallback (RtError::Type type, const std::string &errorText)
00055 {
00056     //
00057 }
00058 
00059 
00060 //------------------------------------------------------------------------------
00061 
00062 template<class SampleType>
00063 RTAudioAudioHostBase<SampleType>::RTAudioAudioHostBase() throw() 
00064 {
00065     inputParams.deviceId = dac.getDefaultInputDevice();
00066     outputParams.deviceId = dac.getDefaultOutputDevice();
00067 
00068     this->setPreferredHostBlockSize (512);
00069     this->setPreferredGraphBlockSize (128);
00070     this->setPreferredHostSampleRate (44100.0);
00071     this->setNumInputs (1);
00072     this->setNumOutputs (2);
00073 }
00074 
00075 template<class SampleType>
00076 RTAudioAudioHostBase<SampleType>::~RTAudioAudioHostBase()
00077 {
00078     stopHost();
00079 }
00080 
00081 template<class SampleType>
00082 Text RTAudioAudioHostBase<SampleType>::getHostName() const throw()
00083 {
00084     return "RTAudio (" + TypeUtility<SampleType>::getTypeName() + ")";
00085 }
00086 
00087 template<class SampleType>
00088 Text RTAudioAudioHostBase<SampleType>::getNativeHostName() const throw()
00089 {
00090     switch (const_cast<RtAudio&> (dac).getCurrentApi())
00091     {
00092         case RtAudio::UNSPECIFIED:      return "UNSPECIFIED";
00093         case RtAudio::LINUX_ALSA:       return "LINUX_ALSA";
00094         case RtAudio::LINUX_PULSE:      return "LINUX_PULSE";
00095         case RtAudio::LINUX_OSS:        return "LINUX_OSS";
00096         case RtAudio::UNIX_JACK:        return "UNIX_JACK";
00097         case RtAudio::MACOSX_CORE:      return "MACOSX_CORE";
00098         case RtAudio::WINDOWS_ASIO:     return "WINDOWS_ASIO";
00099         case RtAudio::WINDOWS_DS:       return "WINDOWS_DS";
00100         case RtAudio::RTAUDIO_DUMMY:    return "RTAUDIO_DUMMY";
00101         default:                        return "INVALID";
00102     }
00103 }
00104 
00105 template<class SampleType>
00106 Text RTAudioAudioHostBase<SampleType>::getInputName() const throw()
00107 {
00108     const RtAudio::DeviceInfo deviceInfo = const_cast<RtAudio&> (dac).getDeviceInfo (inputParams.deviceId);
00109     return deviceInfo.name.c_str();
00110 }
00111 
00112 template<class SampleType>
00113 Text RTAudioAudioHostBase<SampleType>::getOutputName() const throw()
00114 {
00115     const RtAudio::DeviceInfo deviceInfo = const_cast<RtAudio&> (dac).getDeviceInfo (outputParams.deviceId);
00116     return deviceInfo.name.c_str();
00117 }
00118 
00119 template<class SampleType>
00120 double RTAudioAudioHostBase<SampleType>::getCpuUsage() const throw()
00121 {
00122     plonk_assertfalse;
00123     return 0.0;
00124 }
00125 
00126 template<class SampleType>
00127 void RTAudioAudioHostBase<SampleType>::stopHost() throw()
00128 {
00129     dac.stopStream();
00130     this->setIsRunning (false);
00131 }
00132 
00133 template<class SampleType>
00134 void RTAudioAudioHostBase<SampleType>::startHost() throw()
00135 {
00136     RtAudioFormat sampleFormat;
00137     
00138     switch (TypeUtility<SampleType>::getTypeCode())
00139     {
00140         case TypeCode::Double: sampleFormat = RTAUDIO_FLOAT64;  break;
00141         case TypeCode::Float:  sampleFormat = RTAUDIO_FLOAT32;  break;
00142         case TypeCode::Short:  sampleFormat = RTAUDIO_SINT16;   break;
00143         case TypeCode::Int:    sampleFormat = RTAUDIO_SINT32;   break;
00144         case TypeCode::Int24:  sampleFormat = RTAUDIO_SINT24;   break;
00145         case TypeCode::Char:   sampleFormat = RTAUDIO_SINT8;    break;
00146         default: sampleFormat = 0; break;
00147     }
00148     
00149     int err;
00150     outputParams.nChannels = this->getNumOutputs();    
00151     inputParams.nChannels = this->getNumInputs();
00152 
00153     if (sampleFormat != 0)
00154     {
00155         unsigned int bufferFrames = (unsigned int)this->getPreferredHostBlockSize();
00156         
00157         RtAudio::StreamOptions streamOptions;
00158         streamOptions.flags |= RTAUDIO_NONINTERLEAVED;
00159         
00160         dac.openStream (outputParams.nChannels > 0 ? &outputParams : NULL,
00161                         inputParams.nChannels > 0 ? &inputParams : NULL,
00162                         sampleFormat,
00163                         this->getPreferredHostSampleRate(),
00164                         &bufferFrames,
00165                         rtAudioCallback<SampleType>,
00166                         this,
00167                         &streamOptions,
00168                         rtAudioErrorCallback);
00169                 
00170         this->startHostInternal();
00171         dac.startStream();
00172     }
00173     else plonk_assertfalse;
00174 }
00175 
00176 template<class SampleType>
00177 int RTAudioAudioHostBase<SampleType>::callback (SampleType* outputData, const SampleType* inputData,
00178                                                 unsigned int nBufferFrames,
00179                                                 double streamTime, RtAudioStreamStatus status) throw()
00180 {
00181     (void)streamTime;
00182     (void)status;
00183     
00184     this->setPreferredHostBlockSize ((int)nBufferFrames);
00185     
00186     ConstBufferArray& inputs = this->getInputs();
00187     BufferArray& outputs = this->getOutputs();
00188 
00189     const int numInputs = inputs.length();
00190     const int numOutputs = outputs.length();
00191     
00192     int i;
00193     
00194     for (i = 0; i < numInputs; ++i)
00195     {
00196         inputs.atUnchecked (i) = inputData;
00197         inputData += nBufferFrames;
00198     }
00199     
00200     for (i = 0; i < numOutputs; ++i)
00201     {
00202         outputs.atUnchecked (i) = outputData;
00203         outputData += nBufferFrames;
00204     }
00205     
00206     this->process();
00207     
00208     return 0;
00209 }
00210 
00211 
00212 //#if (defined(__OBJC__) && !PLONK_IOS)|| DOXYGEN
00213 //END_PLONK_NAMESPACE
00214 //
00215 //@class PLAudioHost;
00216 //
00217 //using namespace plonk;
00218 //
00220 // This class should contain a constructGraph method that returns a Unit
00221 // conatining the audio graph to render at runtime.
00222 // @see PLAudioHost */
00223 //@protocol PLAudioHostDelegate <NSObject>
00224 //@optional
00225 //- (FloatUnit)constructGraphFloat:(PLAudioHost*)host;
00226 //- (ShortUnit)constructGraphShort:(PLAudioHost*)host;
00227 //- (IntUnit)constructGraphInt:(PLAudioHost*)host;
00228 //- (DoubleUnit)constructGraphDouble:(PLAudioHost*)host;
00229 //- (void)hostStarting:(PLAudioHost*)host;
00230 //- (void)hostStopped:(PLAudioHost*)host;
00231 //@end
00232 //
00233 //
00235 // This is simply an adapter for the C++ IOSAudioHost. You need to set an object
00236 // that implements the PLAudioGraph protocol in the init method of your derived
00237 // class.
00238 // 
00239 // When running in the simulator the preferred sample rate and block size
00240 // properties may be ignored and default to the hardware settings of the Mac
00241 // hosting the simulator.
00242 // 
00243 // @see PLAudioGraph */
00244 //@interface PLAudioHost : NSObject
00245 //{
00246 //    void* peer;
00247 //    id<PLAudioHostDelegate> delegate;
00248 //    int type;
00249 //}
00250 //
00251 //@property (nonatomic, assign) id delegate;                  ///< The delegate that contains the constructGraph method.
00252 //@property (nonatomic, readonly) NSString* hostName;         ///< The host name - always "iOS".
00253 //@property (nonatomic, readonly) NSString* nativeHostName;   ///< The native host name - currently always "RemoteIO".
00254 //@property (nonatomic, readonly) NSString* inputName;        ///< The name of the input device. May be "Default Input" on the simulator.
00255 //@property (nonatomic, readonly) NSString* outputName;       ///< The name of the output device. May be "Default Output" on the simulator.
00256 //@property (nonatomic, readonly) double cpuUsage;            ///< The current CPU usage of the DSP loop.
00257 //@property (nonatomic, readonly) BOOL isRunning;             ///< Is the host running?
00258 //@property (nonatomic, readonly) Dynamic outputUnit;         ///< The output unit of the host.
00259 //@property (nonatomic) int numInputs;                        ///< The number of audio inputs, only set this BEFORE sending the startHost message.
00260 //@property (nonatomic) int numOutputs;                       ///< The number of audio outputs, only set this BEFORE sending the startHost message.
00261 //@property (nonatomic) int preferredHostBlockSize;           ///< The preferred host block size, only set this BEFORE sending the startHost message.
00262 //@property (nonatomic) int preferredGraphBlockSize;          ///< The preferred graph block size, only set this BEFORE sending the startHost message.
00263 //@property (nonatomic) double preferredHostSampleRate;       ///< The preferred sample rate, only set this BEFORE sending the startHost message.
00264 //
00266 //- (void)startHost;
00267 //
00269 //- (void)stopHost;
00270 //
00271 //@end
00272 //
00273 //BEGIN_PLONK_NAMESPACE
00274 //
00275 //template<class SampleType>
00276 //class RTAudioAudioHostPeerBase : public RTAudioAudioHostBase<SampleType>
00277 //{
00278 //public:
00279 //    typedef typename RTAudioAudioHostBase<SampleType>::UnitType UnitType;
00280 //    
00281 //    RTAudioAudioHostPeerBase (PLAudioHost* p)
00282 //    :   peer (p)
00283 //    {
00284 //    }
00285 //    
00286 //    void hostStarting() throw()
00287 //    {
00288 //        if ([peer.delegate respondsToSelector:@selector(hostStarting:)])
00289 //            [peer.delegate hostStarting:peer];
00290 //    }
00291 //    
00292 //    void hostStopped() throw()
00293 //    {
00294 //        if ([peer.delegate respondsToSelector:@selector(hostStopped:)])
00295 //            [peer.delegate hostStopped:peer];
00296 //    }
00297 //        
00298 //    PLAudioHost* getPeer() const throw() { return peer; }
00299 //    
00300 //private:
00301 //    PLAudioHost* peer; // no need to retain as the Obj-C peer owns this object
00302 //    
00303 //    RTAudioAudioHostPeerBase();
00304 //};
00305 //
00307 //template<class SampleType>
00308 //class RTAudioAudioHostPeer : public RTAudioAudioHostPeerBase<SampleType>
00309 //{
00310 //public:
00311 //    // pure virtual constructGraph not implemented to cause a compile-time error
00312 //    // only float, short, int and double sample types are supported
00313 //};
00314 //
00315 //template<>
00316 //class RTAudioAudioHostPeer<float> : public RTAudioAudioHostPeerBase<float>
00317 //{
00318 //public:
00319 //    RTAudioAudioHostPeer (PLAudioHost* peer)
00320 //    :   RTAudioAudioHostPeerBase<float> (peer)
00321 //    {
00322 //    }
00323 //    
00324 //    FloatUnit constructGraph() throw()
00325 //    {
00326 //        PLAudioHost* const peer = this->getPeer();
00327 //        plonk_assert (peer.delegate != nil);
00328 //        return [peer.delegate constructGraphFloat:peer];
00329 //    }
00330 //};
00331 //
00332 //template<>
00333 //class RTAudioAudioHostPeer<short> : public RTAudioAudioHostPeerBase<short>
00334 //{
00335 //public:
00336 //    RTAudioAudioHostPeer (PLAudioHost* peer)
00337 //    :   RTAudioAudioHostPeerBase<short> (peer)
00338 //    {
00339 //    }
00340 //    
00341 //    ShortUnit constructGraph() throw()
00342 //    {
00343 //        PLAudioHost* const peer = this->getPeer();
00344 //        plonk_assert (peer.delegate != nil);
00345 //        return [peer.delegate constructGraphShort:peer];
00346 //    }
00347 //};
00348 //
00349 //template<>
00350 //class RTAudioAudioHostPeer<int> : public RTAudioAudioHostPeerBase<int>
00351 //{
00352 //public:
00353 //    RTAudioAudioHostPeer (PLAudioHost* peer)
00354 //    :   RTAudioAudioHostPeerBase<int> (peer)
00355 //    {
00356 //    }
00357 //    
00358 //    IntUnit constructGraph() throw()
00359 //    {
00360 //        PLAudioHost* const peer = this->getPeer();
00361 //        plonk_assert (peer.delegate != nil);
00362 //        return [peer.delegate constructGraphInt:peer];
00363 //    }
00364 //};
00365 //
00366 //template<>
00367 //class RTAudioAudioHostPeer<double> : public RTAudioAudioHostPeerBase<double>
00368 //{
00369 //public:
00370 //    RTAudioAudioHostPeer (PLAudioHost* peer)
00371 //    :   RTAudioAudioHostPeerBase<double> (peer)
00372 //    {
00373 //    }
00374 //    
00375 //    DoubleUnit constructGraph() throw()
00376 //    {
00377 //        PLAudioHost* const peer = this->getPeer();
00378 //        plonk_assert (peer.delegate != nil);
00379 //        return [peer.delegate constructGraphInt:peer];
00380 //    }
00381 //};
00382 //
00383 //#if PLONK_AUDIOHOST_PORTAUDIO_COMPILEOBJC
00384 //
00385 //END_PLONK_NAMESPACE
00386 //
00387 //using namespace plonk;
00388 //
00389 //@implementation PLAudioHost
00390 //
00391 //- (id)init
00392 //{
00393 //    if (self = [super init])
00394 //    {
00395 //        peer = nil;
00396 //        type = TypeCode::Unknown;
00397 //    }
00398 //    
00399 //    return self;
00400 //}
00401 //
00402 //- (void)dealloc
00403 //{
00404 //    self.delegate = nil;
00405 //    
00406 //#if !__has_feature(objc_arc)
00407 //    [super dealloc];
00408 //#endif
00409 //}
00410 //
00411 //- (NSString*)hostName
00412 //{
00413 //    if (peer == nil) return @"";
00414 //    
00415 //    switch ((const int)type)
00416 //    {
00417 //        case TypeCode::Float:
00418 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<float>* > (peer)->getHostName().getArray()];
00419 //            
00420 //        case TypeCode::Short:
00421 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<short>* > (peer)->getHostName().getArray()];
00422 //            
00423 //        case TypeCode::Int:
00424 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<int>* > (peer)->getNativeHostName().getArray()];
00425 //            
00426 //        case TypeCode::Double:
00427 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<double>* > (peer)->getNativeHostName().getArray()];
00428 //            
00429 //        default:
00430 //            return @"";
00431 //    }
00432 //}
00433 //
00434 //- (NSString*)nativeHostName
00435 //{
00436 //    if (peer == nil) return @"";
00437 //    
00438 //    switch ((const int)type)
00439 //    {
00440 //        case TypeCode::Float:
00441 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<float>* > (peer)->getNativeHostName().getArray()];
00442 //            
00443 //        case TypeCode::Short:
00444 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<short>* > (peer)->getNativeHostName().getArray()];
00445 //            
00446 //        case TypeCode::Int:
00447 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<int>* > (peer)->getNativeHostName().getArray()];
00448 //            
00449 //        case TypeCode::Double:
00450 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<double>* > (peer)->getNativeHostName().getArray()];
00451 //            
00452 //        default:
00453 //            return @"";
00454 //    }
00455 //}
00456 //
00457 //- (NSString*)inputName
00458 //{
00459 //    if (peer == nil) return @"";
00460 //    
00461 //    switch ((const int)type)
00462 //    {
00463 //        case TypeCode::Float:
00464 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<float>* > (peer)->getInputName().getArray()];
00465 //            
00466 //        case TypeCode::Short:
00467 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<short>* > (peer)->getInputName().getArray()];
00468 //            
00469 //        case TypeCode::Int:
00470 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<int>* > (peer)->getInputName().getArray()];
00471 //            
00472 //        case TypeCode::Double:
00473 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<double>* > (peer)->getInputName().getArray()];
00474 //            
00475 //        default:
00476 //            return @"";
00477 //    }
00478 //}
00479 //
00480 //- (NSString*)outputName
00481 //{
00482 //    if (peer == nil) return @"";
00483 //    
00484 //    switch ((const int)type)
00485 //    {
00486 //        case TypeCode::Float:
00487 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<float>* > (peer)->getInputName().getArray()];
00488 //            
00489 //        case TypeCode::Short:
00490 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<short>* > (peer)->getInputName().getArray()];
00491 //            
00492 //        case TypeCode::Int:
00493 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<int>* > (peer)->getInputName().getArray()];
00494 //            
00495 //        case TypeCode::Double:
00496 //            return [NSString stringWithUTF8String: static_cast< RTAudioAudioHostPeer<double>* > (peer)->getInputName().getArray()];
00497 //            
00498 //        default:
00499 //            return @"";
00500 //    }
00501 //}
00502 //
00503 //- (double)cpuUsage
00504 //{
00505 //    if (peer == nil) return 0.0;
00506 //    
00507 //    switch ((const int)type)
00508 //    {
00509 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getCpuUsage();
00510 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getCpuUsage();
00511 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getCpuUsage();
00512 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getCpuUsage();
00513 //        default: return 0.0;
00514 //    }
00515 //}
00516 //
00517 //- (BOOL)isRunning
00518 //{
00519 //    if (peer == nil) return NO;
00520 //    
00521 //    switch ((const int)type)
00522 //    {
00523 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getIsRunning() ? YES : NO;
00524 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getIsRunning() ? YES : NO;
00525 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getIsRunning() ? YES : NO;
00526 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getIsRunning() ? YES : NO;
00527 //        default: return NO;
00528 //    }
00529 //}
00530 //
00531 //- (BOOL)isPaused
00532 //{
00533 //    if (peer == nil) return NO;
00534 //    
00535 //    switch ((const int)type)
00536 //    {
00537 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getIsPaused() ? YES : NO;
00538 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getIsPaused() ? YES : NO;
00539 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getIsPaused() ? YES : NO;
00540 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getIsPaused() ? YES : NO;
00541 //        default: return NO;
00542 //    }
00543 //}
00544 //
00545 //- (Dynamic)outputUnit
00546 //{
00547 //    Dynamic dyn;
00548 //    
00549 //    if (peer != nil)
00550 //    {
00551 //        switch ((const int)type)
00552 //        {
00553 //            case TypeCode::Float:   dyn = static_cast< RTAudioAudioHostPeer<float>* > (peer)->getOutputUnit(); break;
00554 //            case TypeCode::Short:   dyn = static_cast< RTAudioAudioHostPeer<short>* > (peer)->getOutputUnit(); break;
00555 //            case TypeCode::Int:     dyn = static_cast< RTAudioAudioHostPeer<int>* > (peer)->getOutputUnit(); break;
00556 //            case TypeCode::Double:  dyn = static_cast< RTAudioAudioHostPeer<double>* > (peer)->getOutputUnit(); break;
00557 //            default: { }
00558 //        }
00559 //    }
00560 //    
00561 //    return dyn;
00562 //}
00563 //
00564 //- (int)numInputs
00565 //{
00566 //    if (peer == nil) return 0;
00567 //    
00568 //    switch ((const int)type)
00569 //    {
00570 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getNumInputs();
00571 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getNumInputs();
00572 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getNumInputs();
00573 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getNumInputs();
00574 //        default: return 0.0;
00575 //    }
00576 //}
00577 //
00578 //- (void)setNumInputs:(int)numInputs
00579 //{
00580 //    if (peer == nil) return;
00581 //    
00582 //    switch ((const int)type)
00583 //    {
00584 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->setNumInputs (numInputs); break;
00585 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->setNumInputs (numInputs); break;
00586 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->setNumInputs (numInputs); break;
00587 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->setNumInputs (numInputs); break;
00588 //        default: { }
00589 //    }
00590 //}
00591 //
00592 //- (int)numOutputs
00593 //{
00594 //    if (peer == nil) return 0;
00595 //    
00596 //    switch ((const int)type)
00597 //    {
00598 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getNumOutputs();
00599 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getNumOutputs();
00600 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getNumOutputs();
00601 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getNumOutputs();
00602 //        default: return 0.0;
00603 //    }
00604 //}
00605 //
00606 //- (void)setNumOutputs:(int)numOutputs
00607 //{
00608 //    if (peer == nil) return;
00609 //    
00610 //    switch ((const int)type)
00611 //    {
00612 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->setNumOutputs (numOutputs); break;
00613 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->setNumOutputs (numOutputs); break;
00614 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->setNumOutputs (numOutputs); break;
00615 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->setNumOutputs (numOutputs); break;
00616 //        default: { }
00617 //    }
00618 //}
00619 //
00620 //- (int)preferredHostBlockSize
00621 //{
00622 //    if (peer == nil) return 0;
00623 //    
00624 //    switch ((const int)type)
00625 //    {
00626 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getPreferredHostBlockSize();
00627 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getPreferredHostBlockSize();
00628 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getPreferredHostBlockSize();
00629 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getPreferredHostBlockSize();
00630 //        default: return 0;
00631 //    }
00632 //}
00633 //
00634 //- (void)setPreferredHostBlockSize:(int)preferredHostBlockSize
00635 //{
00636 //    if (peer == nil) return;
00637 //    
00638 //    switch ((const int)type)
00639 //    {
00640 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->setPreferredHostBlockSize (preferredHostBlockSize); break;
00641 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->setPreferredHostBlockSize (preferredHostBlockSize); break;
00642 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->setPreferredHostBlockSize (preferredHostBlockSize); break;
00643 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->setPreferredHostBlockSize (preferredHostBlockSize); break;
00644 //        default: { }
00645 //    }
00646 //}
00647 //
00648 //- (int)preferredGraphBlockSize
00649 //{
00650 //    if (peer == nil) return 0;
00651 //    
00652 //    switch ((const int)type)
00653 //    {
00654 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getPreferredGraphBlockSize();
00655 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getPreferredGraphBlockSize();
00656 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getPreferredGraphBlockSize();
00657 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getPreferredGraphBlockSize();
00658 //        default: return 0;
00659 //    }
00660 //}
00661 //
00662 //- (void)setPreferredGraphBlockSize:(int)preferredGraphBlockSize
00663 //{
00664 //    if (peer == nil) return;
00665 //    
00666 //    switch ((const int)type)
00667 //    {
00668 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->setPreferredGraphBlockSize (preferredGraphBlockSize); break;
00669 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->setPreferredGraphBlockSize (preferredGraphBlockSize); break;
00670 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->setPreferredGraphBlockSize (preferredGraphBlockSize); break;
00671 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->setPreferredGraphBlockSize (preferredGraphBlockSize); break;
00672 //        default: { }
00673 //    }
00674 //}
00675 //
00676 //- (double)preferredHostSampleRate
00677 //{
00678 //    if (peer == nil) return 0.0;
00679 //    
00680 //    switch ((const int)type)
00681 //    {
00682 //        case TypeCode::Float:   return static_cast< RTAudioAudioHostPeer<float>* > (peer)->getPreferredHostSampleRate();
00683 //        case TypeCode::Short:   return static_cast< RTAudioAudioHostPeer<short>* > (peer)->getPreferredHostSampleRate();
00684 //        case TypeCode::Int:     return static_cast< RTAudioAudioHostPeer<int>* > (peer)->getPreferredHostSampleRate();
00685 //        case TypeCode::Double:  return static_cast< RTAudioAudioHostPeer<double>* > (peer)->getPreferredHostSampleRate();
00686 //        default: return 0.0;
00687 //    }
00688 //}
00689 //
00690 //- (void)setPreferredHostSampleRate:(double)preferredHostSampleRate
00691 //{
00692 //    if (peer == nil) return;
00693 //    
00694 //    switch ((const int)type)
00695 //    {
00696 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->setPreferredHostSampleRate (preferredHostSampleRate); break;
00697 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->setPreferredHostSampleRate (preferredHostSampleRate); break;
00698 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->setPreferredHostSampleRate (preferredHostSampleRate); break;
00699 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->setPreferredHostSampleRate (preferredHostSampleRate); break;
00700 //        default: { }
00701 //    }
00702 //}
00703 //
00704 //- (void)startHost
00705 //{
00706 //    if (peer == nil) return;
00707 //    
00708 //    switch ((const int)type)
00709 //    {
00710 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->startHost(); break;
00711 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->startHost(); break;
00712 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->startHost(); break;
00713 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->startHost(); break;
00714 //        default: { }
00715 //    }
00716 //}
00717 //
00718 //- (void)stopHost
00719 //{
00720 //    if (peer == nil) return;
00721 //    
00722 //    switch ((const int)type)
00723 //    {
00724 //        case TypeCode::Float:   static_cast< RTAudioAudioHostPeer<float>* > (peer)->stopHost(); break;
00725 //        case TypeCode::Short:   static_cast< RTAudioAudioHostPeer<short>* > (peer)->stopHost(); break;
00726 //        case TypeCode::Int:     static_cast< RTAudioAudioHostPeer<int>* > (peer)->stopHost(); break;
00727 //        case TypeCode::Double:  static_cast< RTAudioAudioHostPeer<double>* > (peer)->stopHost(); break;
00728 //        default: { }
00729 //    }
00730 //}
00731 //
00732 //- (id)delegate
00733 //{
00734 //    return delegate;
00735 //}
00736 //
00737 //- (void)deletePeer
00738 //{
00739 //    switch ((const int)type)
00740 //    {
00741 //        case TypeCode::Float:   delete static_cast< RTAudioAudioHostPeer<float>* > (peer);   break;
00742 //        case TypeCode::Short:   delete static_cast< RTAudioAudioHostPeer<short>* > (peer);   break;
00743 //        case TypeCode::Int:     delete static_cast< RTAudioAudioHostPeer<int>* > (peer);     break;
00744 //        case TypeCode::Double:  delete static_cast< RTAudioAudioHostPeer<double>* > (peer);  break;
00745 //        default: { }
00746 //    }
00747 //    
00748 //    peer = nil;
00749 //    type = TypeCode::Unknown;
00750 //}
00751 //
00752 //- (void)setDelegate:(id)newDelegate
00753 //{
00754 //    plonk_assert (delegate == nil || newDelegate == nil);
00755 //    
00756 //    [self deletePeer];
00757 //    
00758 //    delegate = newDelegate;
00759 //    
00760 //    if (delegate)
00761 //    {
00762 //        const unsigned int isFloat = [delegate respondsToSelector:@selector(constructGraphFloat:)] ? (1 << TypeCode::Float) : 0;
00763 //        const unsigned int isShort = [delegate respondsToSelector:@selector(constructGraphShort:)] ? (1 << TypeCode::Short) : 0;
00764 //        const unsigned int isInt = [delegate respondsToSelector:@selector(constructGraphInt:)] ? (1 << TypeCode::Int) : 0;
00765 //        const unsigned int isDouble = [delegate respondsToSelector:@selector(constructGraphDouble:)] ? (1 << TypeCode::Double) : 0;
00766 //        const unsigned int typeFlags = isFloat | isShort | isInt | isDouble;
00767 //        
00768 //        if (typeFlags != 0 && Bits::isPowerOf2 (typeFlags))
00769 //        {
00770 //            type = Bits::countTrailingZeroes (typeFlags);
00771 //            
00772 //            switch ((const int)type)
00773 //            {
00774 //                case TypeCode::Float:   peer = new RTAudioAudioHostPeer<float> (self);   break;
00775 //                case TypeCode::Short:   peer = new RTAudioAudioHostPeer<short> (self);   break;
00776 //                case TypeCode::Int:     peer = new RTAudioAudioHostPeer<int> (self);     break;
00777 //                case TypeCode::Double:  peer = new RTAudioAudioHostPeer<double> (self);  break;
00778 //                    
00779 //                default:
00780 //                    peer = nil;
00781 //                    type = 0;
00782 //            }
00783 //        }
00784 //        else plonk_assertfalse; // either none or more than one constructGraph.. function was implemented
00785 //    }
00786 //}
00787 //
00788 //@end
00789 //
00790 //BEGIN_PLONK_NAMESPACE
00791 //#endif
00792 //
00793 //#endif
00794 
00795 
00796 #endif // PLANK_INLINING_FUNCTIONS
00797 
 All Classes Functions Typedefs Enumerations Enumerator Properties