diff options
| author | Gary Scavone <gary@music.mcgill.ca> | 2013-10-09 23:49:32 +0200 |
|---|---|---|
| committer | Stephen Sinclair <sinclair@music.mcgill.ca> | 2013-10-10 01:15:42 +0200 |
| commit | fdc3f15bec57b30fae67f65270392ba7a86680b8 (patch) | |
| tree | c40a558b21ec18df4a4fd2613ead8f54dd3c4156 /tests | |
| parent | 2b55be781872498a3b4c6cde60be4c2f69ec7eb4 (diff) | |
Version 3.0.2
Diffstat (limited to 'tests')
| -rw-r--r-- | tests/Windows/rtaudiotest/Release/.placeholder | 0 | ||||
| -rw-r--r-- | tests/Windows/rtaudiotest/StdOpt.cpp | 91 | ||||
| -rw-r--r-- | tests/Windows/rtaudiotest/StdOpt.h | 186 | ||||
| -rw-r--r-- | tests/Windows/rtaudiotest/readme.txt | 8 | ||||
| -rw-r--r-- | tests/Windows/rtaudiotest/rtaudiotest.cpp | 386 | ||||
| -rw-r--r-- | tests/Windows/rtaudiotest/rtaudiotest.dsp | 146 | ||||
| -rw-r--r-- | tests/Windows/rtaudiotest/rtaudiotest.dsw | 29 | ||||
| -rw-r--r-- | tests/call_inout.cpp | 6 | ||||
| -rw-r--r-- | tests/call_saw.cpp | 4 | ||||
| -rw-r--r-- | tests/in_out.cpp | 2 | ||||
| -rw-r--r-- | tests/info.cpp | 2 | ||||
| -rw-r--r-- | tests/play_raw.cpp | 2 | ||||
| -rw-r--r-- | tests/play_saw.cpp | 2 | ||||
| -rw-r--r-- | tests/record_raw.cpp | 2 | ||||
| -rw-r--r-- | tests/twostreams.cpp | 2 |
15 files changed, 857 insertions, 11 deletions
diff --git a/tests/Windows/rtaudiotest/Release/.placeholder b/tests/Windows/rtaudiotest/Release/.placeholder new file mode 100644 index 0000000..e69de29 --- /dev/null +++ b/tests/Windows/rtaudiotest/Release/.placeholder diff --git a/tests/Windows/rtaudiotest/StdOpt.cpp b/tests/Windows/rtaudiotest/StdOpt.cpp new file mode 100644 index 0000000..02c8eea --- /dev/null +++ b/tests/Windows/rtaudiotest/StdOpt.cpp @@ -0,0 +1,91 @@ +/************************************************************************/
+/*! \class CommandLine
+ \brief Command-line option parser.
+
+ Copyright (c) 2005 Robin Davies.
+
+ 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.
+
+ 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 ".\stdopt.h"
+
+using namespace stdopt;
+
+CommandLine::CommandLine()
+{
+}
+
+void CommandLine::ProcessCommandLine(int argc, char**argv)
+{
+ std::vector<std::string> cmdline;
+ for (int i = 0; i < argc; ++i) {
+ cmdline.push_back(argv[i]);
+ }
+ ProcessCommandLine(cmdline);
+}
+
+const CommandLine::COptionHandlerBase*CommandLine::GetOptionHandler(const std::string &name) const
+{
+ // Return excact matches only.
+ for (size_t i = 0; i < optionHandlers.size(); ++i)
+ {
+ if (optionHandlers[i]->getName() == name) {
+ return (optionHandlers[i]);
+ }
+ }
+ return NULL;
+}
+
+void CommandLine::ProcessCommandLine(const std::vector<std::string>& cmdline)
+{
+ for (size_t i = 1; i < cmdline.size(); ++i)
+ {
+ if (cmdline[i].length() != 0 && cmdline[i][0] == L'/' || (cmdline[i][0] == '-')) {
+ std::string arg = cmdline[i].substr(1);
+ const COptionHandlerBase *pHandler = GetOptionHandler(arg);
+ if (pHandler == NULL) {
+ throw CommandLineException(std::string("Unknown option: ") + arg);
+ }
+ if (pHandler->HasArgument())
+ {
+ std::string strArg;
+ if (i+1 < cmdline.size()) {
+ ++i;
+ strArg = cmdline[i];
+ }
+ pHandler->Process(strArg.c_str());
+ } else {
+ pHandler->Process(NULL);
+ }
+ } else {
+ args.push_back(cmdline[i]);
+ }
+ }
+}
+
+CommandLine::~CommandLine(void)
+{
+ for (size_t i = 0; i < optionHandlers.size(); ++i)
+ {
+ delete optionHandlers[i];
+ }
+ optionHandlers.resize(0);
+}
diff --git a/tests/Windows/rtaudiotest/StdOpt.h b/tests/Windows/rtaudiotest/StdOpt.h new file mode 100644 index 0000000..4de660a --- /dev/null +++ b/tests/Windows/rtaudiotest/StdOpt.h @@ -0,0 +1,186 @@ +/************************************************************************/
+/*! \class CommandLine
+ \brief Command-line opition parser.
+
+ Copyright (c) 2005 Robin Davies.
+
+ 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.
+
+ 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.
+*/
+/************************************************************************/
+
+#ifndef STDOPT_H
+#define STDOPT_H
+
+#include <vector>
+#include <string>
+#include <sstream>
+#include <exception>
+
+namespace stdopt
+{
+
+ class CommandLineException: public std::exception {
+ public:
+ CommandLineException(const std::string &error)
+ {
+ s = error;
+ }
+ const char*what() { return s.c_str(); }
+ private:
+ std::string s;
+ };
+
+ class CommandLine
+ {
+ public:
+ CommandLine();
+ virtual ~CommandLine();
+
+ void ProcessCommandLine(int argc, char**argv);
+ void ProcessCommandLine(const std::vector<std::string>& cmdline);
+
+ template <class TVAL> void AddOption(const char*name,TVAL*pResult, TVAL defaultValue)
+ {
+ this->optionHandlers.push_back(new COptionHandler<TVAL>(name,pResult));
+ *pResult = defaultValue;
+
+ }
+ template <class TVAL> void AddOption(const char*name,TVAL*pResult)
+ {
+ this->optionHandlers.push_back(new COptionHandler<TVAL>(name,pResult));
+ }
+ const std::vector<std::string> &GetArguments() { return args; }
+ template <class T> void GetArgument(size_t arg, T*pVal)
+ {
+ if (arg >= args.size()) {
+ std::stringstream os;
+ os << "Argument " << (arg+1) << " not provided.";
+ throw CommandLineException(os.str());
+ }
+ std::stringstream is(args[arg]);
+ T value;
+ is >> value;
+ if (!is.fail() && is.eof())
+ {
+ *pVal = value;
+ } else {
+ std::stringstream os;
+ os << "Argument " << (arg+1) << " was not in the correct format.";
+ throw CommandLineException(os.str());
+ }
+ }
+ void GetArgument(size_t arg, std::string*pVal)
+ {
+ if (arg >= args.size()) {
+ std::stringstream os;
+ os << "Argument " << (arg+1) << " not provided.";
+ throw CommandLineException(os.str());
+ }
+ *pVal = args[arg];
+ }
+
+
+ private:
+
+ class COptionHandlerBase {
+ public:
+ COptionHandlerBase(const std::string & name) { this->name = name;}
+ virtual ~COptionHandlerBase() { };
+ const std::string &getName() const { return name; }
+ virtual bool HasArgument()const = 0;
+ virtual void Process(const char* value) const = 0;
+ private:
+ std::string name;
+ };
+ template <class T> class COptionHandler: public COptionHandlerBase {
+ public:
+ COptionHandler(const std::string &name,T *result, T defaultValue = T())
+ : COptionHandlerBase(name)
+ {
+ _pResult = result;
+ *_pResult = defaultValue;
+
+ }
+ virtual bool HasArgument() const;
+
+ virtual void Process(const char *strValue) const {
+ std::stringstream is(strValue);
+ T value;
+ is >> value;
+ if (!is.fail() && is.eof())
+ {
+ *_pResult = value;
+ } else {
+ std::stringstream os;
+ os << "Invalid value provided for option '" << getName() << "'.";
+ throw CommandLineException(os.str().c_str());
+ }
+ }
+
+ private:
+ std::string strName;
+ T*_pResult;
+ };
+ const CommandLine::COptionHandlerBase*GetOptionHandler(const std::string &name) const;
+
+ std::vector<std::string > args;
+ std::vector<COptionHandlerBase*> optionHandlers;
+ };
+
+ // Argument specializations for bool.
+ template <class T> bool CommandLine::COptionHandler<T>::HasArgument()const {
+ return true;
+ };
+ inline bool CommandLine::COptionHandler<bool>::HasArgument() const {
+ return false;
+ }
+ inline void CommandLine::COptionHandler<bool>::Process(const char*strValue) const {
+ if (strValue == NULL)
+ {
+ *_pResult = true;
+ return;
+ }
+ switch (*strValue)
+ {
+ case '\0':
+ case '+':
+ *_pResult = true;
+ break;
+ case '-':
+ *_pResult = false;
+ break;
+ default:
+ throw CommandLineException("Please specify '+' or '-' for boolean options.");
+ }
+ }
+ // specializations for std::string.
+ inline void CommandLine::COptionHandler<std::string >::Process(const char*strValue)const {
+ *_pResult = strValue;
+ }
+
+ // specializations for std::vector<std::string>
+ inline void CommandLine::COptionHandler<std::vector<std::string> >::Process(const char*strValue)const {
+ _pResult->push_back(strValue);
+ }
+};
+
+
+
+#endif
diff --git a/tests/Windows/rtaudiotest/readme.txt b/tests/Windows/rtaudiotest/readme.txt new file mode 100644 index 0000000..d883384 --- /dev/null +++ b/tests/Windows/rtaudiotest/readme.txt @@ -0,0 +1,8 @@ +rtaudiotest - Test rtaudio devices.
+
+rtaudiotest is a small tool that allows easy testing of rtaudio devices
+and configurations.
+
+Run rtaudiotest.exe for a description of how to run it.
+
+rtaudiotest is currently only supported for the Windows platform.
diff --git a/tests/Windows/rtaudiotest/rtaudiotest.cpp b/tests/Windows/rtaudiotest/rtaudiotest.cpp new file mode 100644 index 0000000..90d8c2c --- /dev/null +++ b/tests/Windows/rtaudiotest/rtaudiotest.cpp @@ -0,0 +1,386 @@ +/************************************************************************/
+/*! \brief Interactively Test RtAudio parameters.
+
+ RtAudio is a command-line utility that allows users to enumerate
+ installed devices, and to test input, output and duplex operation
+ of RtAudio devices with various buffer and buffer-size
+ configurations.
+
+ Copyright (c) 2005 Robin Davies.
+
+ 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.
+
+ 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 "RtAudio.h"
+#include "FileWvOut.h"
+
+#include <cmath>
+#include <iostream>
+#include <stdopt.h>
+
+using namespace std;
+using namespace stdopt;
+
+#ifdef _WIN32
+// Correct windows.h standards violation.
+#undef min
+#undef max
+#endif
+
+#define DSOUND 1
+
+RtAudio::RtAudioApi rtApi = RtAudio::WINDOWS_DS;
+
+void DisplayHelp(std::ostream &os)
+{
+ os
+ << "rtaudiotest - Test rtaudio devices." << endl
+ << endl
+ << "Syntax:" << endl
+ << " rtaudiotest [options]* enum" << endl
+ << " - Display installed devices." << endl
+ << " rtaudiotest [options]* inputtest <devicenum> [<filename>]" << endl
+ << " - Capture audio to a .wav file." << endl
+ << " rtaudiotest [options]* outputtest <devicenum>" << endl
+ << " - Generate a test signal on the device.." << endl
+ << " rtaudiotest [options]* duplextest <inputDevicenum> <outputdevicenum>" << endl
+ << " - Echo input to output." << endl
+
+ << "Options:" << endl
+ << " -h -? Display this message." << endl
+ << " -dsound Use DirectX drivers." << endl
+ << " -asio Use ASIO drivers." << endl
+ << " -buffers N Use N buffers." << endl
+ << " -size N Use buffers of size N." << endl
+ << " -srate N Use a sample-rate of N (defaults to 44100)." << endl
+ << " -channels N Use N channels (defaults to 2)." << endl
+ << " -seconds N Run the test for N seconds (default 5)." << endl
+ << "Description: " << endl
+ << " RtAudio is a command-line utility that allows users to enumerate " << endl
+ << " installed devices, and to test input, output and duplex operation " << endl
+ << " of RtAudio devices with various buffer and buffer-size " << endl
+ << " configurations." << endl
+ << "Examples:" << endl
+ << " rtaudio -asio enum" << endl
+ << " rtaudio -dsound -buffers 4 -size 128 -seconds 3 inputtest 0 test.wav" << endl
+ ;
+
+}
+
+void EnumerateDevices(RtAudio::RtAudioApi api)
+{
+ RtAudio rt(api);
+ for (int i = 1; i <= rt.getDeviceCount(); ++i)
+ {
+ RtAudioDeviceInfo info = rt.getDeviceInfo(i);
+ cout << "Device " << i << ": " << info.name << endl;
+ }
+}
+
+struct TestConfiguration
+{
+ long srate;
+ int channels;
+ int bufferSize;
+ int buffers;
+ int seconds;
+};
+
+
+bool DisplayStats(RtAudio::RtAudioApi api)
+{
+#ifdef __WINDOWS_DS__
+ // Display latency results for Windows DSound drivers.
+ if (api == RtAudio::WINDOWS_DS)
+ {
+ RtApiDs::RtDsStatistics s = RtApiDs::getDsStatistics();
+
+ cout << " Latency: " << s.latency*1000.0 << "ms" << endl;
+ if (s.inputFrameSize)
+ {
+ cout << " Read overruns: " << s.numberOfReadOverruns << endl;
+ }
+ if (s.outputFrameSize)
+ {
+ cout << " Write underruns: " << s.numberOfWriteUnderruns << endl;
+ }
+
+ if (s.inputFrameSize)
+ {
+ cout << " Read lead time in sample frames (device): " << s.readDeviceSafeLeadBytes/ s.inputFrameSize << endl;
+ }
+ if (s.outputFrameSize)
+ {
+ cout << " Write lead time in sample frames (device): " << s.writeDeviceSafeLeadBytes / s.outputFrameSize << endl;
+ cout << " Write lead time in sample frames (buffer): " << s.writeDeviceBufferLeadBytes / s.outputFrameSize << endl;
+
+ }
+
+ }
+#endif
+ return true;
+}
+
+void InputTest( RtAudio::RtAudioApi api,
+ int inputDevice,
+ const std::string &fileName,
+ TestConfiguration &configuration )
+{
+ RtAudio rt(api);
+
+ int bufferSize = configuration.bufferSize;
+
+ RtAudioDeviceInfo info = rt.getDeviceInfo(inputDevice);
+ cout << "Reading from device " << inputDevice << " (" << info.name << ")\n";
+
+ rt.openStream(0,0,inputDevice,configuration.channels, RTAUDIO_SINT16, configuration.srate,&bufferSize,configuration.buffers);
+ if (bufferSize != configuration.bufferSize)
+ {
+ cout << "The buffer size was changed to " << bufferSize << " by the device." << endl;
+ configuration.bufferSize = bufferSize;
+
+ }
+
+ int nTicks = (int)ceil((configuration.srate* configuration.seconds)*1.0/configuration.bufferSize);
+
+ if (fileName.length() == 0)
+ {
+ // just run the stream.
+ rt.startStream();
+ for (int i = 0; i < nTicks; ++i)
+ {
+ rt.tickStream();
+ }
+ rt.stopStream();
+ } else
+ {
+ if (configuration.seconds > 10) {
+ throw CommandLineException("Capture of more than 10 seconds of data is not supported.");
+ }
+ std::vector<short> data;
+ // we could be smarter, but the point here is to capture data without interfering with the stream.
+ // File writes while ticking the stream is not cool.
+ data.resize(nTicks*configuration.bufferSize*configuration.channels); // potentially very big. That's why we restrict capture to 10 seconds.
+ short *pData = &data[0];
+
+ rt.startStream();
+ int i;
+ for (i = 0; i < nTicks; ++i)
+ {
+ rt.tickStream();
+ short *streamBuffer = (short*)rt.getStreamBuffer();
+ for (int samples = 0; samples < configuration.bufferSize; ++samples)
+ {
+ for (int channel = 0; channel < configuration.channels; ++channel)
+ {
+ *pData ++ = *streamBuffer++;
+ }
+ }
+ }
+ rt.stopStream();
+ remove(fileName.c_str());
+ FileWvOut wvOut;
+ wvOut.openFile( fileName.c_str(), configuration.channels, FileWrite::FILE_WAV );
+
+ StkFrames frame(1,configuration.channels,false);
+ pData = &data[0];
+
+ for (i = 0; i < nTicks; ++i) {
+ for (int samples = 0; samples < configuration.bufferSize; ++samples) {
+ for (int channel = 0; channel < configuration.channels; ++channel) {
+ frame[channel] = (float)( *pData++*( 1.0 / 32768.0 ) );
+ }
+ wvOut.tickFrame(frame);
+ }
+ }
+ wvOut.closeFile();
+ }
+ rt.closeStream();
+
+ if (DisplayStats(api)) {
+ cout << "Test succeeded." << endl;
+ }
+}
+
+void OutputTest( RtAudio::RtAudioApi api,
+ int outputDevice,
+ TestConfiguration &configuration )
+{
+ RtAudio rt(api);
+ int bufferSize = configuration.bufferSize;
+
+ RtAudioDeviceInfo info = rt.getDeviceInfo(outputDevice);
+ cout << "Writing to " << info.name << "...\n";
+
+ rt.openStream(outputDevice,configuration.channels, 0,0, RTAUDIO_SINT16, configuration.srate,&bufferSize,configuration.buffers);
+ if (bufferSize != configuration.bufferSize) {
+ cout << "The buffer size was changed to " << bufferSize << " by the device." << endl;
+ configuration.bufferSize = bufferSize;
+ }
+
+ rt.startStream();
+ short *pBuffer = (short*)rt.getStreamBuffer();
+ int nTicks = (int)ceil((configuration.srate* configuration.seconds)*1.0/configuration.bufferSize);
+
+ double phase = 0;
+ double deltaPhase = 880.0/configuration.srate;
+ for (int i = 0; i < nTicks; ++i) {
+ short *p = pBuffer;
+ for (int samp = 0; samp < configuration.bufferSize; ++samp) {
+ short val = (short)(sin(phase)*(32768/4)); // sin()*0.25 magnitude. Audible, but not damaging to ears or speakers.
+ phase += deltaPhase;
+
+ for (int chan = 0; chan < configuration.channels; ++chan) {
+ *p++ = val;
+ }
+ }
+ rt.tickStream();
+ }
+ rt.stopStream();
+ rt.closeStream();
+
+ if ( DisplayStats(api) ) {
+ cout << "Test succeeded." << endl;
+ }
+}
+
+void DuplexTest( RtAudio::RtAudioApi api,
+ int inputDevice,
+ int outputDevice,
+ TestConfiguration &configuration )
+{
+ RtAudio rt(api);
+ int bufferSize = configuration.bufferSize;
+
+ RtAudioDeviceInfo info = rt.getDeviceInfo(inputDevice);
+ cout << "Reading from " << info.name << ", " << endl;
+ info = rt.getDeviceInfo(outputDevice);
+ cout << "Writing to " << info.name << "..." << endl;
+
+ rt.openStream(outputDevice,configuration.channels, inputDevice,configuration.channels, RTAUDIO_SINT16, configuration.srate,&bufferSize,configuration.buffers);
+ if (bufferSize != configuration.bufferSize)
+ {
+ cout << "The buffer size was changed to " << bufferSize << " by the device." << endl;
+ configuration.bufferSize = bufferSize;
+ }
+
+ rt.startStream();
+ short *pBuffer = (short*)rt.getStreamBuffer();
+ int nTicks = (int)ceil((configuration.srate* configuration.seconds)*1.0/configuration.bufferSize);
+
+ for (int i = 0; i < nTicks; ++i) {
+ rt.tickStream();
+ }
+ rt.stopStream();
+ rt.closeStream();
+
+ if ( DisplayStats(api) ) {
+ cout << "Test succeeded." << endl;
+ }
+}
+
+int main(int argc, char **argv)
+{
+ try
+ {
+ CommandLine commandLine;
+
+ TestConfiguration configuration;
+ bool displayHelp;
+ bool useDsound;
+ bool useAsio;
+
+ commandLine.AddOption("h",&displayHelp);
+ commandLine.AddOption("?",&displayHelp);
+ commandLine.AddOption("dsound",&useDsound);
+ commandLine.AddOption("asio",&useAsio);
+ commandLine.AddOption("srate",&configuration.srate,44100L);
+ commandLine.AddOption("channels",&configuration.channels,2);
+ commandLine.AddOption("seconds",&configuration.seconds,5);
+ commandLine.AddOption("buffers",&configuration.buffers,2);
+ commandLine.AddOption("size",&configuration.bufferSize,128);
+
+ commandLine.ProcessCommandLine(argc,argv);
+
+ if (displayHelp || commandLine.GetArguments().size() == 0)
+ {
+ DisplayHelp(cout);
+ return 0;
+ }
+ if (useDsound)
+ {
+ rtApi = RtAudio::WINDOWS_DS;
+ } else if (useAsio)
+ {
+ rtApi = RtAudio::WINDOWS_ASIO;
+ } else {
+ throw CommandLineException("Please specify an API to use: '-dsound', or '-asio'");
+ }
+
+ std::string testName;
+ commandLine.GetArgument(0,&testName);
+ if (testName == "enum")
+ {
+ EnumerateDevices(rtApi);
+ } else if (testName == "inputtest")
+ {
+ int inputDevice;
+ std::string fileName;
+ commandLine.GetArgument(1,&inputDevice);
+ if (commandLine.GetArguments().size() >= 2)
+ {
+ commandLine.GetArgument(2,&fileName);
+ }
+ InputTest(rtApi,inputDevice,fileName,configuration);
+ } else if (testName == "outputtest")
+ {
+ int inputDevice;
+ commandLine.GetArgument(1,&inputDevice);
+ OutputTest(rtApi,inputDevice,configuration);
+ } else if (testName == "duplextest")
+ {
+ int inputDevice;
+ int outputDevice;
+ commandLine.GetArgument(1,&inputDevice);
+ commandLine.GetArgument(2,&outputDevice);
+ DuplexTest(rtApi,inputDevice,outputDevice,configuration);
+ } else {
+ throw CommandLineException("Not a valid test name.");
+ }
+
+ } catch (CommandLineException &e)
+ {
+ cerr << e.what() << endl << endl;
+ cerr << "Run 'rtaudiotest -h' to see the commandline syntax." << endl;
+ return 3;
+ } catch (RtError &e)
+ {
+ cerr << e.getMessage() << endl;
+ return 3;
+
+ } catch (std::exception &e)
+ {
+ cerr << "Error: " << e.what() << endl;
+ return 3;
+
+ }
+ return 0;
+}
diff --git a/tests/Windows/rtaudiotest/rtaudiotest.dsp b/tests/Windows/rtaudiotest/rtaudiotest.dsp new file mode 100644 index 0000000..519756b --- /dev/null +++ b/tests/Windows/rtaudiotest/rtaudiotest.dsp @@ -0,0 +1,146 @@ +# Microsoft Developer Studio Project File - Name="rtaudiotest" - Package Owner=<4>
+# Microsoft Developer Studio Generated Build File, Format Version 6.00
+# ** DO NOT EDIT **
+
+# TARGTYPE "Win32 (x86) Console Application" 0x0103
+
+CFG=rtaudiotest - 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 "rtaudiotest.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 "rtaudiotest.mak" CFG="rtaudiotest - Win32 Debug"
+!MESSAGE
+!MESSAGE Possible choices for configuration are:
+!MESSAGE
+!MESSAGE "rtaudiotest - Win32 Release" (based on "Win32 (x86) Console Application")
+!MESSAGE "rtaudiotest - 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)" == "rtaudiotest - 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 Ignore_Export_Lib 0
+# PROP Target_Dir ""
+# ADD BASE CPP /nologo /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /YX /FD /c
+# ADD CPP /nologo /MT /W3 /GX /Zi /O2 /I "..\..\include" /D "WIN32" /D "NDEBUG" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__WINDOWS_ASIO__" /D "__LITTLE_ENDIAN__" /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 dsound.lib winmm.lib /nologo /subsystem:console /debug /machine:I386
+
+!ELSEIF "$(CFG)" == "rtaudiotest - 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 /MTd /W3 /Gm /GX /ZI /Od /I "..\..\include" /D "WIN32" /D "_DEBUG" /D "_CONSOLE" /D "_MBCS" /D "__WINDOWS_DS__" /D "__WINDOWS_ASIO__" /D "__LITTLE_ENDIAN__" /FR /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 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib dsound.lib /nologo /subsystem:console /debug /machine:I386 /pdbtype:sept
+
+!ENDIF
+
+# Begin Target
+
+# Name "rtaudiotest - Win32 Release"
+# Name "rtaudiotest - Win32 Debug"
+# Begin Group "Source Files"
+
+# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
+# Begin Source File
+
+SOURCE=..\..\src\asio\asio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiodrivers.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\asio\asiolist.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\RtAudio.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\rtaudiotest.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdOpt.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\Stk.cpp
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\src\WvOut.cpp
+# End Source File
+# End Group
+# Begin Group "Header Files"
+
+# PROP Default_Filter "h;hpp;hxx;hm;inl"
+# Begin Source File
+
+SOURCE=..\..\include\RtAudio.h
+# End Source File
+# Begin Source File
+
+SOURCE=.\StdOpt.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\Stk.h
+# End Source File
+# Begin Source File
+
+SOURCE=..\..\include\WvOut.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/tests/Windows/rtaudiotest/rtaudiotest.dsw b/tests/Windows/rtaudiotest/rtaudiotest.dsw new file mode 100644 index 0000000..eabbccd --- /dev/null +++ b/tests/Windows/rtaudiotest/rtaudiotest.dsw @@ -0,0 +1,29 @@ +Microsoft Developer Studio Workspace File, Format Version 6.00
+# WARNING: DO NOT EDIT OR DELETE THIS WORKSPACE FILE!
+
+###############################################################################
+
+Project: "rtaudiotest"=".\rtaudiotest.dsp" - Package Owner=<4>
+
+Package=<5>
+{{{
+}}}
+
+Package=<4>
+{{{
+}}}
+
+###############################################################################
+
+Global:
+
+Package=<5>
+{{{
+}}}
+
+Package=<3>
+{{{
+}}}
+
+###############################################################################
+
diff --git a/tests/call_inout.cpp b/tests/call_inout.cpp index e941e1e..f51ad6f 100644 --- a/tests/call_inout.cpp +++ b/tests/call_inout.cpp @@ -53,7 +53,7 @@ int inout(char *buffer, int buffer_size, void *) int main(int argc, char *argv[]) { int chans, fs, device = 0; - RtAudio *audio; + RtAudio *audio = 0; char input; // minimal command-line checking @@ -67,8 +67,8 @@ int main(int argc, char *argv[]) // Open the realtime output device int buffer_size = 512; try { - audio = new RtAudio(device, chans, device, chans, - FORMAT, fs, &buffer_size, 8); + audio = new RtAudio( device, chans, device, chans, + FORMAT, fs, &buffer_size, 8 ); } catch (RtError &error) { error.printMessage(); diff --git a/tests/call_saw.cpp b/tests/call_saw.cpp index 57f225c..b37841b 100644 --- a/tests/call_saw.cpp +++ b/tests/call_saw.cpp @@ -76,8 +76,8 @@ int saw(char *buffer, int buffer_size, void *data) int main(int argc, char *argv[]) { int buffer_size, fs, device = 0; - RtAudio *audio; - double *data; + RtAudio *audio = 0; + double *data = 0; char input; // minimal command-line checking diff --git a/tests/in_out.cpp b/tests/in_out.cpp index bba4d73..18fa8c1 100644 --- a/tests/in_out.cpp +++ b/tests/in_out.cpp @@ -51,7 +51,7 @@ int main(int argc, char *argv[]) int chans, fs, buffer_size, device = 0; long frames, counter = 0; MY_TYPE *buffer; - RtAudio *audio; + RtAudio *audio = 0; // minimal command-line checking if (argc != 3 && argc != 4 ) usage(); diff --git a/tests/info.cpp b/tests/info.cpp index 81a4234..113efb0 100644 --- a/tests/info.cpp +++ b/tests/info.cpp @@ -12,7 +12,7 @@ int main(int argc, char *argv[]) { - RtAudio *audio; + RtAudio *audio = 0; RtAudioDeviceInfo info; try { audio = new RtAudio(); diff --git a/tests/play_raw.cpp b/tests/play_raw.cpp index fcc921f..6dd477d 100644 --- a/tests/play_raw.cpp +++ b/tests/play_raw.cpp @@ -60,7 +60,7 @@ int main(int argc, char *argv[]) MY_TYPE *buffer; char *file; FILE *fd; - RtAudio *audio; + RtAudio *audio = 0; // minimal command-line checking if (argc != 4 && argc != 5 ) usage(); diff --git a/tests/play_saw.cpp b/tests/play_saw.cpp index 4b2cbdd..b99248f 100644 --- a/tests/play_saw.cpp +++ b/tests/play_saw.cpp @@ -58,7 +58,7 @@ int main(int argc, char *argv[]) int chans, fs, buffer_size, device = 0; long frames, counter = 0, i, j; MY_TYPE *buffer; - RtAudio *audio; + RtAudio *audio = 0; double *data = 0; // minimal command-line checking diff --git a/tests/record_raw.cpp b/tests/record_raw.cpp index 717ce2c..3a207f9 100644 --- a/tests/record_raw.cpp +++ b/tests/record_raw.cpp @@ -54,7 +54,7 @@ int main(int argc, char *argv[]) long frames, counter = 0; MY_TYPE *buffer; FILE *fd; - RtAudio *audio; + RtAudio *audio = 0; // minimal command-line checking if (argc != 3 && argc != 4 ) usage(); diff --git a/tests/twostreams.cpp b/tests/twostreams.cpp index 508cf4d..17badd0 100644 --- a/tests/twostreams.cpp +++ b/tests/twostreams.cpp @@ -62,7 +62,7 @@ int main(int argc, char *argv[]) int chans, fs, buffer_size, device = 0; long frames, counter = 0, i, j; MY_TYPE *buffer1, *buffer2; - RtAudio *stream1, *stream2; + RtAudio *stream1 = 0, *stream2 = 0; FILE *fd; double *data = 0; |
