--- /dev/null
+#include <stdio.h>
+#include <math.h>
+#include "portaudio.h"
+
+/*
+** Note that many of the older ISA sound cards on PCs do NOT support
+** full duplex audio (simultaneous record and playback).
+** And some only support full duplex at lower sample rates.
+*/
+#define SAMPLE_RATE (44100)
+#define PA_SAMPLE_TYPE paFloat32
+#define FRAMES_PER_BUFFER (64)
+
+typedef float SAMPLE;
+
+float CubicAmplifier(float input);
+
+static int fuzzCallback(const void *inputBuffer,
+ void *outputBuffer,
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData);
+
+/* Non-linear amplifier with soft distortion curve. */
+float CubicAmplifier(float input)
+{
+ float output, temp;
+ if(input < 0.0)
+ {
+ temp = input + 1.0f;
+ output = (temp * temp * temp) - 1.0f;
+ }
+ else
+ {
+ temp = input - 1.0f;
+ output = (temp * temp * temp) + 1.0f;
+ }
+ return output;
+}
+
+#define FUZZ(x) CubicAmplifier(CubicAmplifier(CubicAmplifier(CubicAmplifier(x))))
+
+static int gNumNoInputs = 0;
+
+static int fuzzCallback(const void *inputBuffer,
+ void *outputBuffer,
+ unsigned long framesPerBuffer,
+ const PaStreamCallbackTimeInfo* timeInfo,
+ PaStreamCallbackFlags statusFlags,
+ void *userData)
+{
+ SAMPLE *out = (SAMPLE*)outputBuffer;
+ const SAMPLE *in = (const SAMPLE*)inputBuffer;
+ unsigned int i;
+ (void) timeInfo; /* Prevent unused variable warnings. */
+ (void) statusFlags;
+ (void) userData;
+
+ if(inputBuffer == NULL)
+ {
+ for(i = 0; i < framesPerBuffer; i++)
+ {
+ *out++ = 0; /* left - silent */
+ *out++ = 0; /* right - silent */
+ }
+ gNumNoInputs += 1;
+ }
+ else
+ {
+ for(i = 0; i < framesPerBuffer; i++)
+ {
+ *out++ = FUZZ(*in++); /* left - distorted */
+ *out++ = *in++; /* right - clean */
+ }
+ }
+ return paContinue;
+}
+
+
+#define BUILD_MAIN
+
+#ifdef BUILD_MAIN
+
+int main(void)
+{
+ PaStreamParameters inputParameters, outputParameters;
+ PaStream *stream;
+ PaError err;
+
+ err = Pa_Initialize();
+ if( err != paNoError ) goto error;
+
+ inputParameters.device = Pa_GetDefaultInputDevice(); /* default input device */
+ if (inputParameters.device == paNoDevice) {
+ fprintf(stderr,"Error: No default input device.\n");
+ goto error;
+ }
+ inputParameters.channelCount = 2; /* stereo input */
+ inputParameters.sampleFormat = PA_SAMPLE_TYPE;
+ inputParameters.suggestedLatency = Pa_GetDeviceInfo( inputParameters.device )->defaultLowInputLatency;
+ inputParameters.hostApiSpecificStreamInfo = NULL;
+
+ outputParameters.device = Pa_GetDefaultOutputDevice(); /* default output device */
+ if (outputParameters.device == paNoDevice) {
+ fprintf(stderr,"Error: No default output device.\n");
+ goto error;
+ }
+ outputParameters.channelCount = 2; /* stereo output */
+ outputParameters.sampleFormat = PA_SAMPLE_TYPE;
+ outputParameters.suggestedLatency = Pa_GetDeviceInfo( outputParameters.device )->defaultLowOutputLatency;
+ outputParameters.hostApiSpecificStreamInfo = NULL;
+
+ err = Pa_OpenStream(
+ &stream,
+ &inputParameters,
+ &outputParameters,
+ SAMPLE_RATE,
+ FRAMES_PER_BUFFER,
+ 0, /* paClipOff, */ /* we won't output out of range samples so don't bother clipping them */
+ fuzzCallback,
+ NULL );
+ if( err != paNoError ) goto error;
+
+ err = Pa_StartStream( stream );
+ if( err != paNoError ) goto error;
+
+ printf("Hit ENTER to stop program.\n");
+ getchar();
+ err = Pa_CloseStream( stream );
+ if( err != paNoError ) goto error;
+
+ printf("Finished. gNumNoInputs = %d\n", gNumNoInputs );
+ Pa_Terminate();
+ return 0;
+
+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 -1;
+ return 0;
+}
+
+#endif
--- /dev/null
+##\r
+## Auto Generated makefile by CodeLite IDE\r
+## any manual changes will be erased \r
+##\r
+## Debug\r
+ProjectName :=pa_test\r
+ConfigurationName :=Debug\r
+IntermediateDirectory :=./Debug\r
+OutDir := $(IntermediateDirectory)\r
+WorkspacePath := "C:\Users\wittend\Projects\audio\portaudio_test\paEcho"\r
+ProjectPath := "C:\Users\wittend\Projects\audio\portaudio_test\paEcho\pa_test"\r
+CurrentFileName :=\r
+CurrentFilePath :=\r
+CurrentFileFullPath :=\r
+User :=wittend\r
+Date :=5/14/2012\r
+CodeLitePath :="C:\Program Files\CodeLite"\r
+LinkerName :=g++\r
+ArchiveTool :=ar rcus\r
+SharedObjectLinkerName :=g++ -shared -fPIC\r
+ObjectSuffix :=.o\r
+DependSuffix :=.o.d\r
+PreprocessSuffix :=.o.i\r
+DebugSwitch :=-gstab\r
+IncludeSwitch :=-I\r
+LibrarySwitch :=-l\r
+OutputSwitch :=-o \r
+LibraryPathSwitch :=-L\r
+PreprocessorSwitch :=-D\r
+SourceSwitch :=-c \r
+CompilerName :=g++\r
+C_CompilerName :=gcc\r
+OutputFile :=$(IntermediateDirectory)/$(ProjectName)\r
+Preprocessors :=\r
+ObjectSwitch :=-o \r
+ArchiveOutputSwitch := \r
+PreprocessOnlySwitch :=-E \r
+ObjectsFileList :="C:\Users\wittend\Projects\audio\portaudio_test\paEcho\pa_test\pa_test.txt"\r
+PCHCompileFlags :=\r
+MakeDirCommand :=makedir\r
+CmpOptions := -g -O0 -Wall $(Preprocessors)\r
+C_CmpOptions := -g -O0 -Wall $(Preprocessors)\r
+LinkOptions := \r
+IncludePath := $(IncludeSwitch). $(IncludeSwitch). $(IncludeSwitch)../../../portaudio/include \r
+IncludePCH := \r
+RcIncludePath := \r
+Libs := $(LibrarySwitch)portaudio \r
+LibPath := $(LibraryPathSwitch). \r
+\r
+\r
+##\r
+## User defined environment variables\r
+##\r
+CodeLiteDir:=C:\Program Files\CodeLite\r
+WXWIN:=C:\bin\wxWidgets-2.9.2\r
+PATH:=$(WXWIN)\lib\gcc_dll;$(PATH)\r
+WXCFG:=gcc_dll\mswu\r
+UNIT_TEST_PP_SRC_DIR:=C:\bin\UnitTest++-1.3\r
+Objects=$(IntermediateDirectory)/pa_class$(ObjectSuffix) \r
+\r
+##\r
+## Main Build Targets \r
+##\r
+.PHONY: all clean PreBuild PrePreBuild PostBuild\r
+all: $(OutputFile)\r
+\r
+$(OutputFile): $(IntermediateDirectory)/.d $(Objects) \r
+ @$(MakeDirCommand) $(@D)\r
+ @echo "" > $(IntermediateDirectory)/.d\r
+ @echo $(Objects) > $(ObjectsFileList)\r
+ $(LinkerName) $(OutputSwitch)$(OutputFile) @$(ObjectsFileList) $(LibPath) $(Libs) $(LinkOptions)\r
+\r
+$(IntermediateDirectory)/.d:\r
+ @$(MakeDirCommand) "./Debug"\r
+\r
+PreBuild:\r
+\r
+\r
+##\r
+## Objects\r
+##\r
+$(IntermediateDirectory)/pa_class$(ObjectSuffix): pa_class.cpp $(IntermediateDirectory)/pa_class$(DependSuffix)\r
+ $(CompilerName) $(IncludePCH) $(SourceSwitch) "C:/Users/wittend/Projects/audio/portaudio_test/paEcho/pa_test/pa_class.cpp" $(CmpOptions) $(ObjectSwitch)$(IntermediateDirectory)/pa_class$(ObjectSuffix) $(IncludePath)\r
+$(IntermediateDirectory)/pa_class$(DependSuffix): pa_class.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) -MG -MP -MT$(IntermediateDirectory)/pa_class$(ObjectSuffix) -MF$(IntermediateDirectory)/pa_class$(DependSuffix) -MM "C:/Users/wittend/Projects/audio/portaudio_test/paEcho/pa_test/pa_class.cpp"\r
+\r
+$(IntermediateDirectory)/pa_class$(PreprocessSuffix): pa_class.cpp\r
+ @$(CompilerName) $(CmpOptions) $(IncludePCH) $(IncludePath) $(PreprocessOnlySwitch) $(OutputSwitch) $(IntermediateDirectory)/pa_class$(PreprocessSuffix) "C:/Users/wittend/Projects/audio/portaudio_test/paEcho/pa_test/pa_class.cpp"\r
+\r
+\r
+-include $(IntermediateDirectory)/*$(DependSuffix)\r
+##\r
+## Clean\r
+##\r
+clean:\r
+ $(RM) $(IntermediateDirectory)/pa_class$(ObjectSuffix)\r
+ $(RM) $(IntermediateDirectory)/pa_class$(DependSuffix)\r
+ $(RM) $(IntermediateDirectory)/pa_class$(PreprocessSuffix)\r
+ $(RM) $(OutputFile)\r
+ $(RM) $(OutputFile).exe\r
+ $(RM) "C:\Users\wittend\Projects\audio\portaudio_test\paEcho\.build-debug\pa_test"\r
+\r
+\r
--- /dev/null
+<?xml version="1.0" encoding="UTF-8"?>
+<CodeLite_Project Name="pa_test" InternalType="Console">
+ <Plugins>
+ <Plugin Name="qmake">
+ <![CDATA[00020001N0005Debug0000000000000001N0007Release000000000000]]>
+ </Plugin>
+ </Plugins>
+ <Description/>
+ <Dependencies/>
+ <VirtualDirectory Name="src">
+ <File Name="pa_class.cpp"/>
+ </VirtualDirectory>
+ <Settings Type="Executable">
+ <GlobalSettings>
+ <Compiler Options="" C_Options="">
+ <IncludePath Value="."/>
+ </Compiler>
+ <Linker Options="">
+ <LibraryPath Value="."/>
+ </Linker>
+ <ResourceCompiler Options=""/>
+ </GlobalSettings>
+ <Configuration Name="Debug" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
+ <Compiler Options="-g;-O0;-Wall" C_Options="-g;-O0;-Wall" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
+ <IncludePath Value="."/>
+ <IncludePath Value="../../../portaudio/include"/>
+ </Compiler>
+ <Linker Options="" Required="yes">
+ <Library Value="portaudio"/>
+ </Linker>
+ <ResourceCompiler Options="" Required="no"/>
+ <General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Debug" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
+ <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
+ <![CDATA[]]>
+ </Environment>
+ <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
+ <PostConnectCommands/>
+ <StartupCommands/>
+ </Debugger>
+ <PreBuild/>
+ <PostBuild/>
+ <CustomBuild Enabled="no">
+ <RebuildCommand/>
+ <CleanCommand/>
+ <BuildCommand/>
+ <PreprocessFileCommand/>
+ <SingleFileCommand/>
+ <MakefileGenerationCommand/>
+ <ThirdPartyToolName>None</ThirdPartyToolName>
+ <WorkingDirectory/>
+ </CustomBuild>
+ <AdditionalRules>
+ <CustomPostBuild/>
+ <CustomPreBuild/>
+ </AdditionalRules>
+ <Completion>
+ <ClangCmpFlags/>
+ <ClangPP/>
+ <SearchPaths/>
+ </Completion>
+ </Configuration>
+ <Configuration Name="Release" CompilerType="gnu g++" DebuggerType="GNU gdb debugger" Type="Executable" BuildCmpWithGlobalSettings="append" BuildLnkWithGlobalSettings="append" BuildResWithGlobalSettings="append">
+ <Compiler Options="-O2;-Wall" C_Options="-O2;-Wall" Required="yes" PreCompiledHeader="" PCHInCommandLine="no" UseDifferentPCHFlags="no" PCHFlags="">
+ <IncludePath Value="."/>
+ <IncludePath Value="../../../portaudio/include"/>
+ </Compiler>
+ <Linker Options="" Required="yes">
+ <Library Value="portaudio"/>
+ </Linker>
+ <ResourceCompiler Options="" Required="no"/>
+ <General OutputFile="$(IntermediateDirectory)/$(ProjectName)" IntermediateDirectory="./Release" Command="./$(ProjectName)" CommandArguments="" UseSeparateDebugArgs="no" DebugArguments="" WorkingDirectory="$(IntermediateDirectory)" PauseExecWhenProcTerminates="yes"/>
+ <Environment EnvVarSetName="<Use Defaults>" DbgSetName="<Use Defaults>">
+ <![CDATA[]]>
+ </Environment>
+ <Debugger IsRemote="no" RemoteHostName="" RemoteHostPort="" DebuggerPath="">
+ <PostConnectCommands/>
+ <StartupCommands/>
+ </Debugger>
+ <PreBuild/>
+ <PostBuild/>
+ <CustomBuild Enabled="no">
+ <RebuildCommand/>
+ <CleanCommand/>
+ <BuildCommand/>
+ <PreprocessFileCommand/>
+ <SingleFileCommand/>
+ <MakefileGenerationCommand/>
+ <ThirdPartyToolName>None</ThirdPartyToolName>
+ <WorkingDirectory/>
+ </CustomBuild>
+ <AdditionalRules>
+ <CustomPostBuild/>
+ <CustomPreBuild/>
+ </AdditionalRules>
+ <Completion>
+ <ClangCmpFlags/>
+ <ClangPP/>
+ <SearchPaths/>
+ </Completion>
+ </Configuration>
+ </Settings>
+</CodeLite_Project>
--- /dev/null
+./Debug/pa_class.o \r