comparison 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
comparison
equal deleted inserted replaced
40:419ce4ebfc4c 45:579c86316008
7 7
8 #include <iostream> 8 #include <iostream>
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
11 #include <getopt.h> 11 #include <getopt.h>
12 #include "../include/RTAudio.h" 12 #include "../include/BeagleRT.h"
13 13
14 #ifndef OPT_PRU_FILE 14 #ifndef OPT_PRU_FILE
15 #define OPT_PRU_FILE 176 // this is an extended ascii code 15 #define OPT_PRU_FILE 176 // this is an extended ASCII code
16 #endif 16 #endif
17 17
18 // Default command-line options for RTAudio 18 // Default command-line options for RTAudio
19 struct option gDefaultLongOptions[] = 19 struct option gDefaultLongOptions[] =
20 { 20 {
28 {"dac-level", 1, NULL, 'D'}, 28 {"dac-level", 1, NULL, 'D'},
29 {"adc-level", 1, NULL, 'A'}, 29 {"adc-level", 1, NULL, 'A'},
30 {"hp-level", 1, NULL, 'H'}, 30 {"hp-level", 1, NULL, 'H'},
31 {"receive-port", 1, NULL, 'r'}, 31 {"receive-port", 1, NULL, 'r'},
32 {"transmit-port", 1, NULL, 't'}, 32 {"transmit-port", 1, NULL, 't'},
33 {"server-name",1,NULL,'s'}, 33 {"server-name", 1, NULL, 's'},
34 {"pru-file",1,NULL,OPT_PRU_FILE}, 34 {"pru-file", 1, NULL, OPT_PRU_FILE},
35 {NULL, 0, NULL, 0} 35 {NULL, 0, NULL, 0}
36 }; 36 };
37 37
38 const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:g:G:r:t:s:"; 38 const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:g:G:r:t:s:";
39 39
40 // This function sets the default settings for the RTAudioSettings structure 40 // This function sets the default settings for the BeagleRTInitSettings structure
41 void BeagleRT_defaultSettings(RTAudioSettings *settings) 41 void BeagleRT_defaultSettings(BeagleRTInitSettings *settings)
42 { 42 {
43 // Set default values for settings 43 // Set default values for settings
44 settings->periodSize = 8; 44 settings->periodSize = 8;
45 settings->useAnalog = 1;
46 settings->useDigital = 1;
47 settings->numAnalogChannels = 8;
48 settings->numDigitalChannels = 16;
49
45 settings->beginMuted = 0; 50 settings->beginMuted = 0;
46 settings->dacLevel = DEFAULT_DAC_LEVEL; 51 settings->dacLevel = DEFAULT_DAC_LEVEL;
47 settings->adcLevel = DEFAULT_ADC_LEVEL; 52 settings->adcLevel = DEFAULT_ADC_LEVEL;
48 settings->headphoneLevel = DEFAULT_HP_LEVEL; 53 settings->headphoneLevel = DEFAULT_HP_LEVEL;
49 settings->useAnalog = 1; 54
50 settings->useDigital = 1;
51 settings->numAnalogChannels = 8;
52 settings->numDigitalChannels = 16;
53 settings->verbose = 0; 55 settings->verbose = 0;
54 settings->pruFilename[0]='\0'; 56 settings->pruFilename[0] = '\0';
57
58 // These two deliberately have no command-line flags by default.
59 // A given program might prefer one mode or another, but it's unlikely
60 // the user would want to switch at runtime
61 settings->interleave = 1;
62 settings->analogOutputsPersist = 1;
63
55 settings->codecI2CAddress = CODEC_I2C_ADDRESS; 64 settings->codecI2CAddress = CODEC_I2C_ADDRESS;
56 settings->receivePort=9998; 65 settings->receivePort = 9998;
57 settings->transmitPort=9999; 66 settings->transmitPort = 9999;
58 strcpy(settings->serverName, "127.0.0.1"); 67 strcpy(settings->serverName, "127.0.0.1");
59 settings->ampMutePin = kAmplifierMutePin; 68 settings->ampMutePin = kAmplifierMutePin;
60 } 69 }
61 70
62 // This function drops in place of getopt() in the main() function 71 // This function drops in place of getopt() in the main() function
63 // and handles the initialisation of the RTAudio settings using 72 // and handles the initialisation of the RTAudio settings using
64 // standard command-line arguments. System default arguments will 73 // standard command-line arguments. System default arguments will
65 // be stored in settings, otherwise arguments will be returned 74 // be stored in settings, otherwise arguments will be returned
66 // as getopt() normally does. 75 // as getopt() normally does.
67 76
68 int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions, const struct option *customLongOptions, RTAudioSettings *settings) 77 int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions, const struct option *customLongOptions, BeagleRTInitSettings *settings)
69 { 78 {
70 static int firstRun = 1; 79 static int firstRun = 1;
71 static char totalShortOptions[256]; 80 static char totalShortOptions[256];
72 static struct option totalLongOptions[256]; 81 static struct option totalLongOptions[256];
73 82
187 else 196 else
188 std::cerr << "Warning: server name is too long (>" << MAX_SERVERNAME_LENGTH << " characters)." 197 std::cerr << "Warning: server name is too long (>" << MAX_SERVERNAME_LENGTH << " characters)."
189 " Using default severName Instead ( " << settings->serverName << " ).\n"; 198 " Using default severName Instead ( " << settings->serverName << " ).\n";
190 break; 199 break;
191 case OPT_PRU_FILE: 200 case OPT_PRU_FILE:
192 if(strlen(optarg)<MAX_PRU_FILENAME_LENGTH) 201 if(strlen(optarg) < MAX_PRU_FILENAME_LENGTH)
193 strcpy(settings->pruFilename, optarg); 202 strcpy(settings->pruFilename, optarg);
194 else 203 else
195 std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n"; 204 std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n";
196 break; 205 break;
197 case '?': 206 case '?':