Mercurial > hg > beaglert
comparison core/RTAudioCommandLine.cpp @ 24:ad5cd8dd99b3 bbb_network
UDP communication in place, pre-alpha
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 08 May 2015 11:12:13 +0100 |
parents | 182ae9367104 |
children | cc434ecf4486 |
comparison
equal
deleted
inserted
replaced
23:182ae9367104 | 24:ad5cd8dd99b3 |
---|---|
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/RTAudio.h" |
13 | |
13 #ifndef OPT_PRU_FILE | 14 #ifndef OPT_PRU_FILE |
14 #define OPT_PRU_FILE -1 | 15 #define OPT_PRU_FILE -1 |
15 #endif | 16 #endif |
16 | 17 |
17 // Default command-line options for RTAudio | 18 // Default command-line options for RTAudio |
20 {"period", 1, NULL, 'p'}, | 21 {"period", 1, NULL, 'p'}, |
21 {"verbose", 0, NULL, 'v'}, | 22 {"verbose", 0, NULL, 'v'}, |
22 {"use-analog", 1, NULL, 'm'}, | 23 {"use-analog", 1, NULL, 'm'}, |
23 {"use-digital-gpio", 1, NULL, 'g'}, | 24 {"use-digital-gpio", 1, NULL, 'g'}, |
24 {"analog-channels", 1, NULL, 'C'}, | 25 {"analog-channels", 1, NULL, 'C'}, |
25 {"digital-gpio-channels", 1, NULL, 'G'}, | 26 {"digital-channels", 1, NULL, 'G'}, |
26 {"mute-speaker", 1, NULL, 'M'}, | 27 {"mute-speaker", 1, NULL, 'M'}, |
27 {"dac-level", 1, NULL, 'D'}, | 28 {"dac-level", 1, NULL, 'D'}, |
28 {"adc-level", 1, NULL, 'A'}, | 29 {"adc-level", 1, NULL, 'A'}, |
29 {"hp-level", 1, NULL, 'H'}, | 30 {"hp-level", 1, NULL, 'H'}, |
31 {"receive-port", 1, NULL, 'r'}, | |
32 {"transmit-port", 1, NULL, 't'}, | |
33 {"server-name",1,NULL,'s'}, | |
30 {"pru-file",1,NULL,OPT_PRU_FILE}, | 34 {"pru-file",1,NULL,OPT_PRU_FILE}, |
31 {NULL, 0, NULL, 0} | 35 {NULL, 0, NULL, 0} |
32 }; | 36 }; |
33 const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:g:G:"; | 37 |
38 const char gDefaultShortOptions[] = "p:vm:M:C:D:A:H:g:G:r:t:s:"; | |
34 | 39 |
35 // This function sets the default settings for the RTAudioSettings structure | 40 // This function sets the default settings for the RTAudioSettings structure |
36 void BeagleRT_defaultSettings(RTAudioSettings *settings) | 41 void BeagleRT_defaultSettings(RTAudioSettings *settings) |
37 { | 42 { |
38 // Set default values for settings | 43 // Set default values for settings |
46 settings->numAnalogChannels = 8; | 51 settings->numAnalogChannels = 8; |
47 settings->numDigitalChannels = 16; | 52 settings->numDigitalChannels = 16; |
48 settings->verbose = 0; | 53 settings->verbose = 0; |
49 settings->pruFilename[0]='\0'; | 54 settings->pruFilename[0]='\0'; |
50 settings->codecI2CAddress = CODEC_I2C_ADDRESS; | 55 settings->codecI2CAddress = CODEC_I2C_ADDRESS; |
56 settings->receivePort=9998; | |
57 settings->transmitPort=9999; | |
58 strcpy(settings->serverName, "127.0.0.1"); | |
51 settings->ampMutePin = kAmplifierMutePin; | 59 settings->ampMutePin = kAmplifierMutePin; |
52 } | 60 } |
53 | 61 |
54 // This function drops in place of getopt() in the main() function | 62 // This function drops in place of getopt() in the main() function |
55 // and handles the initialisation of the RTAudio settings using | 63 // and handles the initialisation of the RTAudio settings using |
165 settings->adcLevel = atof(optarg); | 173 settings->adcLevel = atof(optarg); |
166 break; | 174 break; |
167 case 'H': | 175 case 'H': |
168 settings->headphoneLevel = atof(optarg); | 176 settings->headphoneLevel = atof(optarg); |
169 break; | 177 break; |
170 case OPT_PRU_FILE: | 178 case 'r': |
179 settings->receivePort = atoi(optarg); | |
180 break; | |
181 case 't': | |
182 settings->transmitPort = atoi(optarg); | |
183 break; | |
184 case 's': | |
185 if(strlen(optarg)<MAX_SERVERNAME_LENGTH) | |
186 strcpy(settings->serverName, optarg); | |
187 else | |
188 std::cerr << "Warning: server name is too long (>" << MAX_SERVERNAME_LENGTH << " characters)." | |
189 " Using default severName Instead ( " << settings->serverName << " ).\n"; | |
190 break; | |
191 case 'OPT_PRU_FILE': | |
171 if(strlen(optarg)<MAX_PRU_FILENAME_LENGTH) | 192 if(strlen(optarg)<MAX_PRU_FILENAME_LENGTH) |
172 strcpy(settings->pruFilename, optarg); | 193 strcpy(settings->pruFilename, optarg); |
173 else | 194 else |
174 std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n"; | 195 std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n"; |
175 break; | 196 break; |
188 std::cerr << " --dac-level [-D] dBs: Set the DAC output level (0dB max; -63.5dB min)\n"; | 209 std::cerr << " --dac-level [-D] dBs: Set the DAC output level (0dB max; -63.5dB min)\n"; |
189 std::cerr << " --adc-level [-A] dBs: Set the ADC input level (0dB max; -12dB min)\n"; | 210 std::cerr << " --adc-level [-A] dBs: Set the ADC input level (0dB max; -12dB min)\n"; |
190 std::cerr << " --hp-level [-H] dBs: Set the headphone output level (0dB max; -63.5dB min)\n"; | 211 std::cerr << " --hp-level [-H] dBs: Set the headphone output level (0dB max; -63.5dB min)\n"; |
191 std::cerr << " --mute-speaker [-M] val: Set whether to mute the speaker initially (default: no)\n"; | 212 std::cerr << " --mute-speaker [-M] val: Set whether to mute the speaker initially (default: no)\n"; |
192 std::cerr << " --use-analog [-m] val: Set whether to use ADC/DAC analog (default: yes)\n"; | 213 std::cerr << " --use-analog [-m] val: Set whether to use ADC/DAC analog (default: yes)\n"; |
193 std::cerr << " --use-gpio-analog [-g] val: Set whether to use GPIO analog (default: yes)\n"; | 214 std::cerr << " --use-digital [-g] val: Set whether to use digital GPIO channels (default: yes)\n"; |
194 std::cerr << " --analog-channels [-C] val: Set the number of ADC/DAC channels (default: 8)\n"; | 215 std::cerr << " --analog-channels [-C] val: Set the number of ADC/DAC channels (default: 8)\n"; |
195 std::cerr << " --analog-gpio-channels [-G] val: Set the number of GPIO channels (default: 16)\n"; | 216 std::cerr << " --digital-channels [-G] val: Set the number of digital GPIO channels (default: 16)\n"; |
196 std::cerr << " --pru-file val: Set an optional external file to use for the PRU binary code\n"; | 217 std::cerr << " --receive-port [-r] val: Set the receive port (default: 9998)\n"; |
218 std::cerr << " --transmit-port [-t] val: Set the transmit port (default: 9999)\n"; | |
219 std::cerr << " --server-name [-s] val: Set the destination server name (default: '127.0.0.1')\n"; | |
220 std::cerr << " --pru-file val: Set an optional external file to use for the PRU binary code\n"; | |
197 std::cerr << " --verbose [-v]: Enable verbose logging information\n"; | 221 std::cerr << " --verbose [-v]: Enable verbose logging information\n"; |
198 } | 222 } |
199 | 223 |