diff core/RTAudioCommandLine.cpp @ 45:579c86316008 newapi

Major API overhaul. Moved to a single data structure for handling render functions. Functionally, generally similar except for scheduling within PRU loop function, which now uses interrupts from the PRU rather than polling. This requires an updated kernel.
author andrewm
date Thu, 28 May 2015 14:35:55 -0400
parents 46d87f680da5
children 643cbee74eda
line wrap: on
line diff
--- a/core/RTAudioCommandLine.cpp	Wed May 13 12:23:37 2015 +0100
+++ b/core/RTAudioCommandLine.cpp	Thu May 28 14:35:55 2015 -0400
@@ -9,10 +9,10 @@
 #include <cstdlib>
 #include <cstring>
 #include <getopt.h>
-#include "../include/RTAudio.h"
+#include "../include/BeagleRT.h"
 
 #ifndef OPT_PRU_FILE
-#define OPT_PRU_FILE 176 // this is an extended ascii code
+#define OPT_PRU_FILE 176 // this is an extended ASCII code
 #endif
 
 // Default command-line options for RTAudio
@@ -30,31 +30,40 @@
 	{"hp-level", 1, NULL, 'H'},
 	{"receive-port", 1, NULL, 'r'},
 	{"transmit-port", 1, NULL, 't'},
-	{"server-name",1,NULL,'s'},
-	{"pru-file",1,NULL,OPT_PRU_FILE},
+	{"server-name", 1, NULL, 's'},
+	{"pru-file", 1, NULL, OPT_PRU_FILE},
 	{NULL, 0, NULL, 0}
 };
 
 const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:g:G:r:t:s:";
 
-// This function sets the default settings for the RTAudioSettings structure
-void BeagleRT_defaultSettings(RTAudioSettings *settings)
+// This function sets the default settings for the BeagleRTInitSettings structure
+void BeagleRT_defaultSettings(BeagleRTInitSettings *settings)
 {
 	// Set default values for settings
 	settings->periodSize = 8;
+	settings->useAnalog = 1;
+	settings->useDigital = 1;
+	settings->numAnalogChannels = 8;
+	settings->numDigitalChannels = 16;
+
 	settings->beginMuted = 0;
 	settings->dacLevel = DEFAULT_DAC_LEVEL;
 	settings->adcLevel = DEFAULT_ADC_LEVEL;
 	settings->headphoneLevel = DEFAULT_HP_LEVEL;
-	settings->useAnalog = 1;
-	settings->useDigital = 1;
-	settings->numAnalogChannels = 8;
-	settings->numDigitalChannels = 16;
+
 	settings->verbose = 0;
-	settings->pruFilename[0]='\0';
+	settings->pruFilename[0] = '\0';
+
+	// These two deliberately have no command-line flags by default.
+	// A given program might prefer one mode or another, but it's unlikely
+	// the user would want to switch at runtime
+	settings->interleave = 1;
+	settings->analogOutputsPersist = 1;
+
 	settings->codecI2CAddress = CODEC_I2C_ADDRESS;
-	settings->receivePort=9998;
-	settings->transmitPort=9999;
+	settings->receivePort = 9998;
+	settings->transmitPort = 9999;
 	strcpy(settings->serverName, "127.0.0.1");
 	settings->ampMutePin = kAmplifierMutePin;
 }
@@ -65,7 +74,7 @@
 // be stored in settings, otherwise arguments will be returned
 // as getopt() normally does.
 
-int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions, const struct option *customLongOptions, RTAudioSettings *settings)
+int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions, const struct option *customLongOptions, BeagleRTInitSettings *settings)
 {
 	static int firstRun = 1;
 	static char totalShortOptions[256];
@@ -189,7 +198,7 @@
 						" Using default severName Instead ( " << settings->serverName << " ).\n";
 			break;
 		case OPT_PRU_FILE:
-			if(strlen(optarg)<MAX_PRU_FILENAME_LENGTH)
+			if(strlen(optarg) < MAX_PRU_FILENAME_LENGTH)
 				strcpy(settings->pruFilename, optarg);
 			else
 				std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n";