summaryrefslogtreecommitdiff
path: root/portaudio_test
diff options
context:
space:
mode:
Diffstat (limited to 'portaudio_test')
-rw-r--r--portaudio_test/portaudio_test.dsp181
-rw-r--r--portaudio_test/syncwrite.c128
2 files changed, 309 insertions, 0 deletions
diff --git a/portaudio_test/portaudio_test.dsp b/portaudio_test/portaudio_test.dsp
new file mode 100644
index 0000000..3e90055
--- /dev/null
+++ b/portaudio_test/portaudio_test.dsp
@@ -0,0 +1,181 @@
+# Microsoft Developer Studio Project File - Name="portaudio_test" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=portaudio_test - Win32 Debug
+!MESSAGE This is not a valid makefile. To build this project using NMAKE,
+!MESSAGE use the Export Makefile command and run
+!MESSAGE
+!MESSAGE NMAKE /f "portaudio_test.mak".
+!MESSAGE
+!MESSAGE You can specify a configuration when running NMAKE
+!MESSAGE by defining the macro CFG on the command line. For example:
+!MESSAGE
+!MESSAGE NMAKE /f "portaudio_test.mak" CFG="portaudio_test - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "portaudio_test - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "portaudio_test - Win32 Debug" (based on "Win32 (x86) Console Application")
+!MESSAGE
+
+# Begin Project
+# PROP AllowPerConfigDependencies 0
+# PROP Scc_ProjName ""
+# PROP Scc_LocalPath ""
+CPP=cl.exe
+RSC=rc.exe
+
+!IF "$(CFG)" == "portaudio_test - Win32 Release"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 0
+# PROP BASE Output_Dir "Release"
+# PROP BASE Intermediate_Dir "Release"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 0
+# PROP Output_Dir "Release"
+# PROP Intermediate_Dir "Release"
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /W3 /GX /O2 /I "../portaudio/pa_common" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD BASE RSC /l 0x409 /d "NDEBUG"
+# ADD RSC /l 0x409 /d "NDEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /machine:I386
+
+!ELSEIF "$(CFG)" == "portaudio_test - Win32 Debug"
+
+# PROP BASE Use_MFC 0
+# PROP BASE Use_Debug_Libraries 1
+# PROP BASE Output_Dir "Debug"
+# PROP BASE Intermediate_Dir "Debug"
+# PROP BASE Target_Dir ""
+# PROP Use_MFC 0
+# PROP Use_Debug_Libraries 1
+# PROP Output_Dir "Debug"
+# PROP Intermediate_Dir "Debug"
+# PROP Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /GZ /c
+# ADD CPP /nologo /W3 /Gm /GX /ZI /Od /I "../portaudio/pa_common" /D "_CONSOLE" /D "_MBCS" /D "PA_NO_ASIO" /D "PA_NO_DS" /D "WIN32" /D "_DEBUG" /D "DEBUG_INPUT" /YX /FD /GZ /c
+# ADD BASE RSC /l 0x409 /d "_DEBUG"
+# ADD RSC /l 0x409 /d "_DEBUG"
+BSC32=bscmake.exe
+# ADD BASE BSC32 /nologo
+# ADD BSC32 /nologo
+LINK32=link.exe
+# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+# ADD LINK32 ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib kernel32.lib user32.lib winmm.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "portaudio_test - Win32 Release"
+# Name "portaudio_test - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_allocation.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_converters.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_cpuload.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_dither.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_front.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_process.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_skeleton.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_stream.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_win\pa_win_hostapis.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_win\pa_win_util.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_win_wmme\pa_win_wmme.c
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_tests\patest_read_record.c
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_allocation.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_converters.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_cpuload.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_dither.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_process.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_stream.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\pa_util.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_win_wmme\pa_win_wmme.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\portaudio\pa_common\portaudio.h
+# End Source File
+# End Group
+# Begin Group "Resource Files"
+
+# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
+# End Group
+# End Target
+# End Project
diff --git a/portaudio_test/syncwrite.c b/portaudio_test/syncwrite.c
new file mode 100644
index 0000000..5e2523b
--- /dev/null
+++ b/portaudio_test/syncwrite.c
@@ -0,0 +1,128 @@
+/** @file syncwrite.c
+ @brief Play a sine wave for several seconds with synchronous writes.
+ @author Ross Bencina <rossb@audiomulch.com>
+ @author Phil Burk <philburk@softsynth.com>
+ @author Roger B. Dannenberg <dannenberg@cs.cmu.edu>
+*/
+/*
+ * This program uses the PortAudio Portable Audio Library.
+ * For more information see: http://www.portaudio.com/
+ * Copyright (c) 1999-2000 Ross Bencina and Phil Burk
+ *
+ * Permission is hereby granted, free of charge, to any person obtaining
+ * a copy of this software and associated documentation files
+ * (the "Software"), to deal in the Software without restriction,
+ * including without limitation the rights to use, copy, modify, merge,
+ * publish, distribute, sublicense, and/or sell copies of the Software,
+ * and to permit persons to whom the Software is furnished to do so,
+ * subject to the following conditions:
+ *
+ * The above copyright notice and this permission notice shall be
+ * included in all copies or substantial portions of the Software.
+ *
+ * Any person wishing to distribute modifications to the Software is
+ * requested to send the modifications to the original developer so that
+ * they can be incorporated into the canonical version.
+ *
+ * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
+ * EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
+ * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
+ * IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR
+ * ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF
+ * CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
+ * WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
+ *
+ */
+#include <stdio.h>
+#include <math.h>
+#include "portaudio.h"
+
+#define NUM_SECONDS (5)
+#define SAMPLE_RATE (44100)
+#define FRAMES_PER_BUFFER (64)
+
+#ifndef M_PI
+#define M_PI (3.14159265)
+#endif
+
+#define TABLE_SIZE (200)
+typedef struct
+{
+ float sine[TABLE_SIZE];
+ int left_phase;
+ int right_phase;
+}
+paTestData;
+
+/*******************************************************************/
+int main(void);
+int main(void)
+{
+ PaStreamParameters outputParameters;
+ PaStream *stream;
+ PaError err;
+ paTestData data;
+ int i, count;
+ float samples[FRAMES_PER_BUFFER * 2];
+
+ printf("PortAudio Test: output sine wave. SR = %d, BufSize = %d\n", SAMPLE_RATE, FRAMES_PER_BUFFER);
+
+ /* initialise sinusoidal wavetable */
+ for( i=0; i<TABLE_SIZE; i++ )
+ {
+ data.sine[i] = (float) sin( ((double)i/(double)TABLE_SIZE) * M_PI * 2. );
+ }
+ data.left_phase = data.right_phase = 0;
+
+ err = Pa_Initialize();
+ if( err != paNoError ) goto error;
+
+ outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
+ outputParameters.channelCount = 2; /* stereo output */
+ outputParameters.sampleFormat = paFloat32; /* 32 bit floating point output */
+ outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
+ outputParameters.hostApiSpecificStreamInfo = NULL;
+
+ err = Pa_OpenStream(
+ &stream,
+ NULL, /* no input */
+ &outputParameters,
+ SAMPLE_RATE,
+ FRAMES_PER_BUFFER,
+ paClipOff, /* we won't output out of range samples so don't bother clipping them */
+ NULL, /* no callback */
+ &data );
+ if( err != paNoError ) goto error;
+
+ err = Pa_StartStream( stream );
+ if( err != paNoError ) goto error;
+
+ printf("Play for %d seconds.\n", NUM_SECONDS );
+
+ for (count = 0; count < SAMPLE_RATE * NUM_SECONDS / FRAMES_PER_BUFFER; count++) {
+ float *out = samples;
+ for (i = 0; i < FRAMES_PER_BUFFER; i++) {
+ *out++ = data.sine[data.left_phase];
+ *out++ = data.sine[data.right_phase]; /* right */
+ data.left_phase += 1;
+ if( data.left_phase >= TABLE_SIZE ) data.left_phase -= TABLE_SIZE;
+ data.right_phase += 3; /* higher pitch so we can distinguish left and right. */
+ if( data.right_phase >= TABLE_SIZE ) data.right_phase -= TABLE_SIZE;
+ }
+ Pa_WriteStream( stream, samples, FRAMES_PER_BUFFER);
+ }
+
+ err = Pa_CloseStream( stream );
+ if( err != paNoError ) goto error;
+
+ Pa_Terminate();
+ printf("Test finished.\n");
+
+ return err;
+error:
+ Pa_Terminate();
+ fprintf( stderr, "An error occured while using the portaudio stream\n" );
+ fprintf( stderr, "Error number: %d\n", err );
+ fprintf( stderr, "Error message: %s\n", Pa_GetErrorText( err ) );
+ return err;
+}