diff projects/d-box/main.cpp @ 108:3068421c0737 ultra-staging

Merged default into ultra-staging
author Giulio Moro <giuliomoro@yahoo.it>
date Tue, 18 Aug 2015 00:35:15 +0100
parents 59edd5780fef
children
line wrap: on
line diff
--- a/projects/d-box/main.cpp	Mon Jun 08 01:07:48 2015 +0100
+++ b/projects/d-box/main.cpp	Tue Aug 18 00:35:15 2015 +0100
@@ -33,7 +33,7 @@
 // get_opt_long
 #include <getopt.h>
 
-#include "../../include/RTAudio.h"
+#include <BeagleRT.h>
 #include "config.h"
 #include "sensors.h"
 #include "OscillatorBank.h"
@@ -76,7 +76,7 @@
 char sdPath[256]			= "/dev/mmcblk0p2";			// system path of the SD, partition 2
 char mountPath[256]			= "/root/d-box/usersounds";	// mount point of SD partition 2 [where user files are]
 char gUserDirName[256] 		= "usersounds";				// Directory in which user analysis files can be found [dir of mountPath]
-char gDefaultDirName[256] 	= "sounds";					// Directory in which built in analysis files can be found
+char gDefaultDirName[256] 	= "/root/d-box/sounds";		// Directory in which built in analysis files can be found
 char *gDirName;
 bool gIsLoading 			= false;
 int fileCnt 				= 0;
@@ -262,11 +262,13 @@
 }
 
 
-void parseArguments(arg_data args, RTAudioSettings *settings)
+void parseArguments(arg_data args, BeagleRTInitSettings *settings)
 {
 	// Default filename;
 	gPartialFilename = strdup("D-Box_sound_250_60_40_h88_2.txt");
 
+	const int kOptionAudioTest = 1000;
+
 	// TODO: complete this
 	struct option long_option[] =
 	{
@@ -274,10 +276,10 @@
 		{"audioin", 1, NULL, 'i'},
 		{"file", 1, NULL, 'f'},
 		{"keyboard", 1, NULL, 'k'},
-		{"audio-test", 0, NULL, 'T'},
-		{"sensor-type", 1, NULL, 'S'},
-		{"sensor0", 1, NULL, 'Q'},
-		{"sensor1", 1, NULL, 'R'},
+		{"audio-test", 0, NULL, kOptionAudioTest},
+		{"sensor-type", 1, NULL, 't'},
+		{"sensor0", 1, NULL, 'q'},
+		{"sensor1", 1, NULL, 'r'},
 		{"log", 1, NULL, 'l'},
 		{"usesd", 1, NULL, 'u'},
 		{"oversamp", 1, NULL, 'o'},
@@ -293,7 +295,7 @@
 	while (1)
 	{
 		int c;
-		if ((c = BeagleRT_getopt_long(args.argc, args.argv, "hf:ki:sTQ:R:S:l:u:o:n:g:", long_option, settings)) < 0)
+		if ((c = BeagleRT_getopt_long(args.argc, args.argv, "hf:ki:sq:r:t:l:u:o:n:g:", long_option, settings)) < 0)
 				break;
 		switch (c)
 		{
@@ -313,16 +315,16 @@
 		case 's':
 				forceSensors = true;
 				break;
-		case 'T':
+		case kOptionAudioTest:
 				useAudioTest = true;
 				break;
-		case 'S':
+		case 't':
 				sensorType = atoi(optarg);
 				break;
-		case 'Q':
+		case 'q':
 				touchSensor0Address = atoi(optarg);
 				break;
-		case 'R':
+		case 'r':
 				touchSensor1Address = atoi(optarg);
 				break;
 		case 'l':
@@ -361,7 +363,7 @@
 
 int main(int argc, char *argv[])
 {
-	RTAudioSettings settings;	// Standard audio settings
+	BeagleRTInitSettings settings;	// Standard audio settings
 	RT_TASK rtSensorThread;
 	const char rtSensorThreadName[] = "dbox-sensor";
 	int oscBankHopSize;
@@ -371,7 +373,7 @@
 	args.argv = argv;
 	parseArguments(args, &settings);
 
-	setVerboseLevel(gVerbose);
+	BeagleRT_setVerboseLevel(gVerbose);
 	if(gVerbose == 1 && useAudioTest)
 		cout << "main() : running in audio test mode" << endl;
 
@@ -415,7 +417,7 @@
 		if(gVerbose==1)
 			cout << "main() : creating control thread" << endl;
 
-		if(rt_task_create(&rtSensorThread, rtSensorThreadName, 0, 95, T_JOINABLE | T_FPU)) {
+		if(rt_task_create(&rtSensorThread, rtSensorThreadName, 0, BEAGLERT_AUDIO_PRIORITY - 5, T_JOINABLE | T_FPU)) {
 			  cout << "Error:unable to create Xenomai control thread" << endl;
 			  return -1;
 		}