Merge pull request #79 from radarsat1/dsound-mmsystem
authorStephen Sinclair <radarsat1@users.noreply.github.com>
Wed, 23 Aug 2017 02:01:38 +0000 (23:01 -0300)
committerGitHub <noreply@github.com>
Wed, 23 Aug 2017 02:01:38 +0000 (23:01 -0300)
Add mmsystem.h and mmreg.h for dsound.

CMakeLists.txt
RtAudio.cpp
RtAudio.h
contrib/python/pyrtaudio/rtaudiomodule.cpp
contrib/python/pyrtaudio/setup.py
doc/doxygen/compiling.txt
tests/testall.cpp
tests/teststops.cpp

index 9de6a85dada99036a3020fd3ac742359a2af4370..812d4d307666e7fa9ab37ccc6de609f19d36e6d5 100644 (file)
@@ -44,7 +44,8 @@ elseif (UNIX AND NOT APPLE)
     if (AUDIO_LINUX_PULSE)
         find_library(PULSE_LIB pulse)
         find_library(PULSESIMPLE_LIB pulse-simple)
-        list(APPEND LINKLIBS ${PULSE_LIB} ${PULSESIMPLE_LIB})
+        find_package(Threads REQUIRED CMAKE_THREAD_PREFER_PTHREAD)
+        list(APPEND LINKLIBS ${PULSE_LIB} ${PULSESIMPLE_LIB} ${CMAKE_THREAD_LIBS_INIT})
         add_definitions(-D__LINUX_PULSE__)
         message(STATUS "Using Linux PulseAudio")
     endif (AUDIO_LINUX_PULSE)
@@ -124,3 +125,15 @@ if (BUILD_TESTING)
     add_subdirectory(tests)
 endif (BUILD_TESTING)
 
+install(TARGETS rtaudio
+      LIBRARY DESTINATION lib
+      ARCHIVE DESTINATION lib
+      RUNTIME DESTINATION bin)
+
+install(
+    FILES RtAudio.h
+    DESTINATION include)
+
+install(
+    FILES rtaudio.pc
+    DESTINATION lib/pkgconfig)
index a6b4a4727d8103ab9a2619f3369c3d2013c49823..61b4708ea5b530b7dcb082bde5f23556c0399a51 100644 (file)
@@ -1,4 +1,4 @@
-/************************************************************************/\r
+/************************************************************************/\r
 /*! \class RtAudio\r
     \brief Realtime audio i/o C++ classes.\r
 \r
@@ -45,6 +45,7 @@
 #include <cstdlib>\r
 #include <cstring>\r
 #include <climits>\r
+#include <cmath>\r
 #include <algorithm>\r
 \r
 // Static variable definitions.\r
@@ -92,12 +93,12 @@ const unsigned int RtApi::SAMPLE_RATES[] = {
 //\r
 // *************************************************** //\r
 \r
-std::string RtAudio :: getVersion( void ) throw()\r
+std::string RtAudio :: getVersion( void )\r
 {\r
   return RTAUDIO_VERSION;\r
 }\r
 \r
-void RtAudio :: getCompiledApi( std::vector<RtAudio::Api> &apis ) throw()\r
+void RtAudio :: getCompiledApi( std::vector<RtAudio::Api> &apis )\r
 {\r
   apis.clear();\r
 \r
@@ -209,7 +210,7 @@ RtAudio :: RtAudio( RtAudio::Api api )
   throw( RtAudioError( errorText, RtAudioError::UNSPECIFIED ) );\r
 }\r
 \r
-RtAudio :: ~RtAudio() throw()\r
+RtAudio :: ~RtAudio()\r
 {\r
   if ( rtapi_ )\r
     delete rtapi_;\r
@@ -427,6 +428,9 @@ void RtApi :: setStreamTime( double time )
 \r
   if ( time >= 0.0 )\r
     stream_.streamTime = time;\r
+#if defined( HAVE_GETTIMEOFDAY )\r
+  gettimeofday( &stream_.lastTickTimestamp, NULL );\r
+#endif\r
 }\r
 \r
 unsigned int RtApi :: getStreamSampleRate( void )\r
@@ -3859,8 +3863,7 @@ private:
 // In order to satisfy WASAPI's buffer requirements, we need a means of converting sample rate\r
 // between HW and the user. The convertBufferWasapi function is used to perform this conversion\r
 // between HwIn->UserIn and UserOut->HwOut during the stream callback loop.\r
-// This sample rate converter favors speed over quality, and works best with conversions between\r
-// one rate and its multiple.\r
+// This sample rate converter works best with conversions between one rate and its multiple.\r
 void convertBufferWasapi( char* outBuffer,\r
                           const char* inBuffer,\r
                           const unsigned int& channelCount,\r
@@ -3872,40 +3875,129 @@ void convertBufferWasapi( char* outBuffer,
 {\r
   // calculate the new outSampleCount and relative sampleStep\r
   float sampleRatio = ( float ) outSampleRate / inSampleRate;\r
+  float sampleRatioInv = ( float ) 1 / sampleRatio;\r
   float sampleStep = 1.0f / sampleRatio;\r
   float inSampleFraction = 0.0f;\r
 \r
-  outSampleCount = ( unsigned int ) roundf( inSampleCount * sampleRatio );\r
+  outSampleCount = ( unsigned int ) std::roundf( inSampleCount * sampleRatio );\r
 \r
-  // frame-by-frame, copy each relative input sample into it's corresponding output sample\r
-  for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ )\r
+  // if inSampleRate is a multiple of outSampleRate (or vice versa) there's no need to interpolate\r
+  if ( floor( sampleRatio ) == sampleRatio || floor( sampleRatioInv ) == sampleRatioInv )\r
   {\r
-    unsigned int inSample = ( unsigned int ) inSampleFraction;\r
-\r
-    switch ( format )\r
+    // frame-by-frame, copy each relative input sample into it's corresponding output sample\r
+    for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ )\r
     {\r
-      case RTAUDIO_SINT8:\r
-        memcpy( &( ( char* ) outBuffer )[ outSample * channelCount ], &( ( char* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( char ) );\r
-        break;\r
-      case RTAUDIO_SINT16:\r
-        memcpy( &( ( short* ) outBuffer )[ outSample * channelCount ], &( ( short* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( short ) );\r
-        break;\r
-      case RTAUDIO_SINT24:\r
-        memcpy( &( ( S24* ) outBuffer )[ outSample * channelCount ], &( ( S24* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( S24 ) );\r
-        break;\r
-      case RTAUDIO_SINT32:\r
-        memcpy( &( ( int* ) outBuffer )[ outSample * channelCount ], &( ( int* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( int ) );\r
-        break;\r
-      case RTAUDIO_FLOAT32:\r
-        memcpy( &( ( float* ) outBuffer )[ outSample * channelCount ], &( ( float* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( float ) );\r
-        break;\r
-      case RTAUDIO_FLOAT64:\r
-        memcpy( &( ( double* ) outBuffer )[ outSample * channelCount ], &( ( double* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( double ) );\r
-        break;\r
+      unsigned int inSample = ( unsigned int ) inSampleFraction;\r
+\r
+      switch ( format )\r
+      {\r
+        case RTAUDIO_SINT8:\r
+          memcpy( &( ( char* ) outBuffer )[ outSample * channelCount ], &( ( char* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( char ) );\r
+          break;\r
+        case RTAUDIO_SINT16:\r
+          memcpy( &( ( short* ) outBuffer )[ outSample * channelCount ], &( ( short* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( short ) );\r
+          break;\r
+        case RTAUDIO_SINT24:\r
+          memcpy( &( ( S24* ) outBuffer )[ outSample * channelCount ], &( ( S24* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( S24 ) );\r
+          break;\r
+        case RTAUDIO_SINT32:\r
+          memcpy( &( ( int* ) outBuffer )[ outSample * channelCount ], &( ( int* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( int ) );\r
+          break;\r
+        case RTAUDIO_FLOAT32:\r
+          memcpy( &( ( float* ) outBuffer )[ outSample * channelCount ], &( ( float* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( float ) );\r
+          break;\r
+        case RTAUDIO_FLOAT64:\r
+          memcpy( &( ( double* ) outBuffer )[ outSample * channelCount ], &( ( double* ) inBuffer )[ inSample * channelCount ], channelCount * sizeof( double ) );\r
+          break;\r
+      }\r
+\r
+      // jump to next in sample\r
+      inSampleFraction += sampleStep;\r
     }\r
+  }\r
+  else // else interpolate\r
+  {\r
+    // frame-by-frame, copy each relative input sample into it's corresponding output sample\r
+    for ( unsigned int outSample = 0; outSample < outSampleCount; outSample++ )\r
+    {\r
+      unsigned int inSample = ( unsigned int ) inSampleFraction;\r
+      float inSampleDec = inSampleFraction - inSample;\r
+      unsigned int frameInSample = inSample * channelCount;\r
+      unsigned int frameOutSample = outSample * channelCount;\r
 \r
-    // jump to next in sample\r
-    inSampleFraction += sampleStep;\r
+      switch ( format )\r
+      {\r
+        case RTAUDIO_SINT8:\r
+        {\r
+          for ( unsigned int channel = 0; channel < channelCount; channel++ )\r
+          {\r
+            char fromSample = ( ( char* ) inBuffer )[ frameInSample + channel ];\r
+            char toSample = ( ( char* ) inBuffer )[ frameInSample + channelCount + channel ];\r
+            char sampleDiff = ( char ) ( ( toSample - fromSample ) * inSampleDec );\r
+            ( ( char* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;\r
+          }\r
+          break;\r
+        }\r
+        case RTAUDIO_SINT16:\r
+        {\r
+          for ( unsigned int channel = 0; channel < channelCount; channel++ )\r
+          {\r
+            short fromSample = ( ( short* ) inBuffer )[ frameInSample + channel ];\r
+            short toSample = ( ( short* ) inBuffer )[ frameInSample + channelCount + channel ];\r
+            short sampleDiff = ( short ) ( ( toSample - fromSample ) * inSampleDec );\r
+            ( ( short* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;\r
+          }\r
+          break;\r
+        }\r
+        case RTAUDIO_SINT24:\r
+        {\r
+          for ( unsigned int channel = 0; channel < channelCount; channel++ )\r
+          {\r
+            int fromSample = ( ( S24* ) inBuffer )[ frameInSample + channel ].asInt();\r
+            int toSample = ( ( S24* ) inBuffer )[ frameInSample + channelCount + channel ].asInt();\r
+            int sampleDiff = ( int ) ( ( toSample - fromSample ) * inSampleDec );\r
+            ( ( S24* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;\r
+          }\r
+          break;\r
+        }\r
+        case RTAUDIO_SINT32:\r
+        {\r
+          for ( unsigned int channel = 0; channel < channelCount; channel++ )\r
+          {\r
+            int fromSample = ( ( int* ) inBuffer )[ frameInSample + channel ];\r
+            int toSample = ( ( int* ) inBuffer )[ frameInSample + channelCount + channel ];\r
+            int sampleDiff = ( int ) ( ( toSample - fromSample ) * inSampleDec );\r
+            ( ( int* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;\r
+          }\r
+          break;\r
+        }\r
+        case RTAUDIO_FLOAT32:\r
+        {\r
+          for ( unsigned int channel = 0; channel < channelCount; channel++ )\r
+          {\r
+            float fromSample = ( ( float* ) inBuffer )[ frameInSample + channel ];\r
+            float toSample = ( ( float* ) inBuffer )[ frameInSample + channelCount + channel ];\r
+            float sampleDiff = ( toSample - fromSample ) * inSampleDec;\r
+            ( ( float* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;\r
+          }\r
+          break;\r
+        }\r
+        case RTAUDIO_FLOAT64:\r
+        {\r
+          for ( unsigned int channel = 0; channel < channelCount; channel++ )\r
+          {\r
+            double fromSample = ( ( double* ) inBuffer )[ frameInSample + channel ];\r
+            double toSample = ( ( double* ) inBuffer )[ frameInSample + channelCount + channel ];\r
+            double sampleDiff = ( toSample - fromSample ) * inSampleDec;\r
+            ( ( double* ) outBuffer )[ frameOutSample + channel ] = fromSample + sampleDiff;\r
+          }\r
+          break;\r
+        }\r
+      }\r
+\r
+      // jump to next in sample\r
+      inSampleFraction += sampleStep;\r
+    }\r
   }\r
 }\r
 \r
@@ -5277,8 +5369,8 @@ RtApiDs :: RtApiDs()
 \r
 RtApiDs :: ~RtApiDs()\r
 {\r
-  if ( coInitialized_ ) CoUninitialize(); // balanced call.\r
   if ( stream_.state != STREAM_CLOSED ) closeStream();\r
+  if ( coInitialized_ ) CoUninitialize(); // balanced call.\r
 }\r
 \r
 // The DirectSound default output is always the first device.\r
@@ -8697,8 +8789,10 @@ RtAudio::DeviceInfo RtApiOss :: getDeviceInfo( unsigned int device )
     info.nativeFormats |= RTAUDIO_SINT8;\r
   if ( mask & AFMT_S32_LE || mask & AFMT_S32_BE )\r
     info.nativeFormats |= RTAUDIO_SINT32;\r
+#ifdef AFMT_FLOAT\r
   if ( mask & AFMT_FLOAT )\r
     info.nativeFormats |= RTAUDIO_FLOAT32;\r
+#endif\r
   if ( mask & AFMT_S24_LE || mask & AFMT_S24_BE )\r
     info.nativeFormats |= RTAUDIO_SINT24;\r
 \r
@@ -9025,7 +9119,7 @@ bool RtApiOss :: probeDeviceOpen( unsigned int device, StreamMode mode, unsigned
   }\r
 \r
   // Verify the sample rate setup worked.\r
-  if ( abs( srate - sampleRate ) > 100 ) {\r
+  if ( abs( srate - (int)sampleRate ) > 100 ) {\r
     close( fd );\r
     errorStream_ << "RtApiOss::probeDeviceOpen: device (" << ainfo.name << ") does not support sample rate (" << sampleRate << ").";\r
     errorText_ = errorStream_.str();\r
index 11345cc6d8a72f2ea35f6d5abf44c02e266d150a..207de8cdf8957e1b02f10b827db2e71dd1b0dc08 100644 (file)
--- a/RtAudio.h
+++ b/RtAudio.h
@@ -49,7 +49,7 @@
 
 #include <string>
 #include <vector>
-#include <exception>
+#include <stdexcept>
 #include <iostream>
 
 /*! \typedef typedef unsigned long RtAudioFormat;
@@ -195,7 +195,7 @@ typedef int (*RtAudioCallback)( void *outputBuffer, void *inputBuffer,
 */
 /************************************************************************/
 
-class RtAudioError : public std::exception
+class RtAudioError : public std::runtime_error
 {
  public:
   //! Defined RtAudioError types.
@@ -214,25 +214,22 @@ class RtAudioError : public std::exception
   };
 
   //! The constructor.
-  RtAudioError( const std::string& message, Type type = RtAudioError::UNSPECIFIED ) throw() : message_(message), type_(type) {}
-  //! The destructor.
-  virtual ~RtAudioError( void ) throw() {}
+  RtAudioError( const std::string& message,
+                Type type = RtAudioError::UNSPECIFIED )
+    : std::runtime_error(message), type_(type) {}
 
   //! Prints thrown error message to stderr.
-  virtual void printMessage( void ) const throw() { std::cerr << '\n' << message_ << "\n\n"; }
+  virtual void printMessage( void ) const
+    { std::cerr << '\n' << what() << "\n\n"; }
 
   //! Returns the thrown error message type.
-  virtual const Type& getType(void) const throw() { return type_; }
+  virtual const Type& getType(void) const { return type_; }
 
   //! Returns the thrown error message string.
-  virtual const std::string& getMessage(void) const throw() { return message_; }
-
-  //! Returns the thrown error message as a c-style string.
-  virtual const char* what( void ) const throw() { return message_.c_str(); }
+  virtual const std::string getMessage(void) const
+    { return std::string(what()); }
 
  protected:
-  std::string message_;
   Type type_;
 };
 
@@ -375,7 +372,7 @@ class RtAudio
   };
 
   //! A static function to determine the current RtAudio version.
-  static std::string getVersion( void ) throw();
+  static std::string getVersion( void );
 
   //! A static function to determine the available compiled audio APIs.
   /*!
@@ -383,7 +380,7 @@ class RtAudio
     the enumerated list values.  Note that there can be more than one
     API compiled for certain operating systems.
   */
-  static void getCompiledApi( std::vector<RtAudio::Api> &apis ) throw();
+  static void getCompiledApi( std::vector<RtAudio::Api> &apis );
 
   //! The class constructor.
   /*!
@@ -401,10 +398,10 @@ class RtAudio
     If a stream is running or open, it will be stopped and closed
     automatically.
   */
-  ~RtAudio() throw();
+  ~RtAudio();
 
   //! Returns the audio API specifier for the current instance of RtAudio.
-  RtAudio::Api getCurrentApi( void ) throw();
+  RtAudio::Api getCurrentApi( void );
 
   //! A public function that queries for the number of audio devices available.
   /*!
@@ -412,7 +409,7 @@ class RtAudio
     is called, thus supporting devices connected \e after instantiation. If
     a system error occurs during processing, a warning will be issued. 
   */
-  unsigned int getDeviceCount( void ) throw();
+  unsigned int getDeviceCount( void );
 
   //! Return an RtAudio::DeviceInfo structure for a specified device number.
   /*!
@@ -435,7 +432,7 @@ class RtAudio
     client's responsibility to verify that a device is available
     before attempting to open a stream.
   */
-  unsigned int getDefaultOutputDevice( void ) throw();
+  unsigned int getDefaultOutputDevice( void );
 
   //! A function that returns the index of the default input device.
   /*!
@@ -445,7 +442,7 @@ class RtAudio
     client's responsibility to verify that a device is available
     before attempting to open a stream.
   */
-  unsigned int getDefaultInputDevice( void ) throw();
+  unsigned int getDefaultInputDevice( void );
 
   //! A public function for opening a stream with the specified parameters.
   /*!
@@ -498,7 +495,7 @@ class RtAudio
     If a stream is not open, this function issues a warning and
     returns (no exception is thrown).
   */
-  void closeStream( void ) throw();
+  void closeStream( void );
 
   //! A function that starts a stream.
   /*!
@@ -528,10 +525,10 @@ class RtAudio
   void abortStream( void );
 
   //! Returns true if a stream is open and false if not.
-  bool isStreamOpen( void ) const throw();
+  bool isStreamOpen( void ) const;
 
   //! Returns true if the stream is running and false if it is stopped or not open.
-  bool isStreamRunning( void ) const throw();
+  bool isStreamRunning( void ) const;
 
   //! Returns the number of elapsed seconds since the stream was started.
   /*!
@@ -565,7 +562,7 @@ class RtAudio
   unsigned int getStreamSampleRate( void );
 
   //! Specify whether warning messages should be printed to stderr.
-  void showWarnings( bool value = true ) throw();
+  void showWarnings( bool value = true );
 
  protected:
 
@@ -616,7 +613,7 @@ struct CallbackInfo {
 
   // Default constructor.
   CallbackInfo()
-  :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false) {}
+  :object(0), callback(0), userData(0), errorCallback(0), apiInfo(0), isRunning(false), doRealtime(false), priority(0) {}
 };
 
 // **************************************************************** //
@@ -824,22 +821,22 @@ protected:
 //
 // **************************************************************** //
 
-inline RtAudio::Api RtAudio :: getCurrentApi( void ) throw() { return rtapi_->getCurrentApi(); }
-inline unsigned int RtAudio :: getDeviceCount( void ) throw() { return rtapi_->getDeviceCount(); }
+inline RtAudio::Api RtAudio :: getCurrentApi( void ) { return rtapi_->getCurrentApi(); }
+inline unsigned int RtAudio :: getDeviceCount( void ) { return rtapi_->getDeviceCount(); }
 inline RtAudio::DeviceInfo RtAudio :: getDeviceInfo( unsigned int device ) { return rtapi_->getDeviceInfo( device ); }
-inline unsigned int RtAudio :: getDefaultInputDevice( void ) throw() { return rtapi_->getDefaultInputDevice(); }
-inline unsigned int RtAudio :: getDefaultOutputDevice( void ) throw() { return rtapi_->getDefaultOutputDevice(); }
-inline void RtAudio :: closeStream( void ) throw() { return rtapi_->closeStream(); }
+inline unsigned int RtAudio :: getDefaultInputDevice( void ) { return rtapi_->getDefaultInputDevice(); }
+inline unsigned int RtAudio :: getDefaultOutputDevice( void ) { return rtapi_->getDefaultOutputDevice(); }
+inline void RtAudio :: closeStream( void ) { return rtapi_->closeStream(); }
 inline void RtAudio :: startStream( void ) { return rtapi_->startStream(); }
 inline void RtAudio :: stopStream( void )  { return rtapi_->stopStream(); }
 inline void RtAudio :: abortStream( void ) { return rtapi_->abortStream(); }
-inline bool RtAudio :: isStreamOpen( void ) const throw() { return rtapi_->isStreamOpen(); }
-inline bool RtAudio :: isStreamRunning( void ) const throw() { return rtapi_->isStreamRunning(); }
+inline bool RtAudio :: isStreamOpen( void ) const { return rtapi_->isStreamOpen(); }
+inline bool RtAudio :: isStreamRunning( void ) const { return rtapi_->isStreamRunning(); }
 inline long RtAudio :: getStreamLatency( void ) { return rtapi_->getStreamLatency(); }
 inline unsigned int RtAudio :: getStreamSampleRate( void ) { return rtapi_->getStreamSampleRate(); }
 inline double RtAudio :: getStreamTime( void ) { return rtapi_->getStreamTime(); }
 inline void RtAudio :: setStreamTime( double time ) { return rtapi_->setStreamTime( time ); }
-inline void RtAudio :: showWarnings( bool value ) throw() { rtapi_->showWarnings( value ); }
+inline void RtAudio :: showWarnings( bool value ) { rtapi_->showWarnings( value ); }
 
 // RtApi Subclass prototypes.
 
index 40a87e5961a38fb9a8353d6aca04438f45f931bc..93d3c73121c5ff98fcf5f999b276a98a42fc7bd1 100644 (file)
@@ -48,7 +48,7 @@ extern "C" {
         PyObject *callback_func;
     } PyRtAudio;
 
-    static PyObject *RtAudioError;
+    static PyObject *RtAudioErrorException;
 
     static int callback(void *outputBuffer, void *inputBuffer, unsigned int nBufferFrames,
         double streamTime, RtAudioStreamStatus status, void *data )
@@ -151,9 +151,9 @@ extern "C" {
             else if(!strcmp(api, "directsound"))
                 self->dac = new RtAudio(RtAudio::WINDOWS_DS);
         }
-        catch (RtError &error) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch (RtAudioError &error) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
 
@@ -261,9 +261,9 @@ extern "C" {
                 self->dac->closeStream();
             self->dac->openStream(&oParams, &iParams, self->_format, fs, &bf, &callback, self, &options);
         }
-        catch ( RtError& error ) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch ( RtAudioError& error ) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
 
@@ -281,9 +281,9 @@ extern "C" {
             self->dac->closeStream();
             Py_CLEAR(self->callback_func);
         }
-        catch(RtError &error) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch(RtAudioError &error) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
 
@@ -297,9 +297,9 @@ extern "C" {
         try {
             self->dac->startStream();
         }
-        catch(RtError &error) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch(RtAudioError &error) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
 
@@ -315,9 +315,9 @@ extern "C" {
         try {
             self->dac->stopStream();
         }
-        catch(RtError &error) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch(RtAudioError &error) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
 
@@ -332,9 +332,9 @@ extern "C" {
         try {
             self->dac->abortStream();
         }
-        catch(RtError &error) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch(RtAudioError &error) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
         Py_RETURN_NONE;
@@ -430,9 +430,9 @@ extern "C" {
             return info_dict;
 
         }
-        catch(RtError &error) {
-            PyErr_SetString(RtAudioError, error.getMessage().c_str());
-            Py_INCREF(RtAudioError);
+        catch(RtAudioError &error) {
+            PyErr_SetString(RtAudioErrorException, error.getMessage().c_str());
+            Py_INCREF(RtAudioErrorException);
             return NULL;
         }
     }
@@ -598,8 +598,8 @@ extern "C" {
         Py_INCREF(&RtAudio_type);
         PyModule_AddObject(module, "RtAudio", (PyObject *)&RtAudio_type);
 
-        RtAudioError = PyErr_NewException("rtaudio.RtError", NULL, NULL);
-        Py_INCREF(RtAudioError);
-        PyModule_AddObject(module, "RtError", RtAudioError);
+        RtAudioErrorException = PyErr_NewException("rtaudio.RtError", NULL, NULL);
+        Py_INCREF(RtAudioErrorException);
+        PyModule_AddObject(module, "RtError", RtAudioErrorException);
     }
 }
index 6ad0d4a6889c5833dbc579b3f5f22b4fa002d414..a942f3b75aa2236e508115a5338e44f175329e4b 100644 (file)
@@ -18,8 +18,7 @@ sources = ['rtaudiomodule.cpp', '../../../RtAudio.cpp']
 
 if OSNAME == 'Linux':
     define_macros=[("__LINUX_ALSA__", ''),
-                   ('__LINUX_JACK__', ''),
-                   ('__LINUX_OSS__', '')]
+                   ('__LINUX_JACK__', '')]
     libraries = ['asound', 'jack', 'pthread']
 
 elif OSNAME == 'Darwin':
index 15f45b0a2b5efd9999d2acfb20729fac34d15685..29dcbd471afbf460e5d442521f0a818f166df6af 100644 (file)
@@ -57,7 +57,7 @@ In order to compile RtAudio for a specific OS and audio API, it is necessary to
   <TD>RtApiCore</TD>
   <TD>__MACOSX_CORE__</TD>
   <TD><TT>pthread, CoreAudio</TT></TD>
-  <TD><TT>g++ -Wall -D__MACOSX_CORE__ -o audioprobe audioprobe.cpp RtAudio.cpp -framework CoreAudio -lpthread</TT></TD>
+  <TD><TT>g++ -Wall -D__MACOSX_CORE__ -o audioprobe audioprobe.cpp RtAudio.cpp -framework CoreAudio -framework CoreFoundation -lpthread</TT></TD>
 </TR>
 <TR>
   <TD>Windows</TD>
index 419f27b630729bfb9c6d5a3d99e6fdbc8832ccab..b94ce696d194114e1f36db55fe8a46e37134af13 100644 (file)
@@ -66,7 +66,7 @@ int sawni( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrame
   if ( status )
     std::cout << "Stream underflow detected!" << std::endl;
 
-  float increment;
+  double increment;
   for ( j=0; j<channels; j++ ) {
     increment = BASE_RATE * (j+1+(j*0.1));
     for ( i=0; i<nBufferFrames; i++ ) {
index e24c06490ab0877b8ebfcf7500c00ba0404459a5..6159b88b00fb065c259cc58d948cb77b721d0a9f 100644 (file)
@@ -63,7 +63,7 @@ int pulse( void *outputBuffer, void * /*inputBuffer*/, unsigned int nBufferFrame
   if ( status ) std::cout << "Stream over/underflow detected!" << std::endl;\r
 \r
   for ( i=0; i<nBufferFrames; i++ ) {\r
-    if ( data->frameCounter % data->pulseCount == 0 ) sample = 0.9;\r
+    if ( data->frameCounter % data->pulseCount == 0 ) sample = 0.9f;\r
     else sample = 0.0;\r
     for ( j=0; j<data->channels; j++ )\r
       *buffer++ = sample;\r
@@ -107,8 +107,8 @@ int main( int argc, char *argv[] )
   // Let RtAudio print messages to stderr.\r
   adc->showWarnings( true );\r
 \r
-  runtime = RUNTIME * 1000;\r
-  pausetime = PAUSETIME * 1000;\r
+  runtime = static_cast<unsigned int>(RUNTIME * 1000);\r
+  pausetime = static_cast<unsigned int>(PAUSETIME * 1000);\r
 \r
   // Set our stream parameters for a duplex stream.\r
   bufferFrames = 512;\r
@@ -127,7 +127,7 @@ int main( int argc, char *argv[] )
     oParams.deviceId = adc->getDefaultOutputDevice();\r
 \r
   // First, test external stopStream() calls.\r
-  mydata.pulseCount = PULSE_RATE * fs;\r
+  mydata.pulseCount = static_cast<unsigned int>(PULSE_RATE * fs);\r
   mydata.nFrames = 50 * fs;\r
   mydata.returnValue = 0;\r
   try {\r