comparison core/RTAudioCommandLine.cpp @ 171:e63563507edd

Added command-line options for the PGA
author Giulio Moro <giuliomoro@yahoo.it>
date Mon, 28 Dec 2015 03:53:36 +0100
parents a6d223473ea2
children a156a694864d
comparison
equal deleted inserted replaced
170:e80340fe527a 171:e63563507edd
9 #include <cstdlib> 9 #include <cstdlib>
10 #include <cstring> 10 #include <cstring>
11 #include <getopt.h> 11 #include <getopt.h>
12 #include "../include/BeagleRT.h" 12 #include "../include/BeagleRT.h"
13 13
14 #ifndef OPT_PRU_FILE 14 #define OPT_PRU_FILE 1000
15 #define OPT_PRU_FILE 176 // this is an extended ASCII code 15 #define OPT_PGA_GAIN_LEFT 1001
16 #endif 16 #define OPT_PGA_GAIN_RIGHT 1002
17
17 18
18 enum { 19 enum {
19 kAmplifierMutePin = 61 // P8-26 controls amplifier mute 20 kAmplifierMutePin = 61 // P8-26 controls amplifier mute
20 }; 21 };
21 22
29 {"analog-channels", 1, NULL, 'C'}, 30 {"analog-channels", 1, NULL, 'C'},
30 {"digital-channels", 1, NULL, 'B'}, 31 {"digital-channels", 1, NULL, 'B'},
31 {"mute-speaker", 1, NULL, 'M'}, 32 {"mute-speaker", 1, NULL, 'M'},
32 {"dac-level", 1, NULL, 'D'}, 33 {"dac-level", 1, NULL, 'D'},
33 {"adc-level", 1, NULL, 'A'}, 34 {"adc-level", 1, NULL, 'A'},
35 {"pga-gain-left", 1, NULL, OPT_PGA_GAIN_LEFT},
36 {"pga-gain-right", 1, NULL, OPT_PGA_GAIN_RIGHT},
34 {"hp-level", 1, NULL, 'H'}, 37 {"hp-level", 1, NULL, 'H'},
35 {"receive-port", 1, NULL, 'R'}, 38 {"receive-port", 1, NULL, 'R'},
36 {"transmit-port", 1, NULL, 'T'}, 39 {"transmit-port", 1, NULL, 'T'},
37 {"server-name", 1, NULL, 'S'}, 40 {"server-name", 1, NULL, 'S'},
38 {"pru-file", 1, NULL, OPT_PRU_FILE}, 41 {"pru-file", 1, NULL, OPT_PRU_FILE},
52 settings->numDigitalChannels = 16; 55 settings->numDigitalChannels = 16;
53 56
54 settings->beginMuted = 0; 57 settings->beginMuted = 0;
55 settings->dacLevel = DEFAULT_DAC_LEVEL; 58 settings->dacLevel = DEFAULT_DAC_LEVEL;
56 settings->adcLevel = DEFAULT_ADC_LEVEL; 59 settings->adcLevel = DEFAULT_ADC_LEVEL;
60 for(int n = 0; n < 2; n++)
61 settings->pgaGain[n] = DEFAULT_PGA_GAIN;
57 settings->headphoneLevel = DEFAULT_HP_LEVEL; 62 settings->headphoneLevel = DEFAULT_HP_LEVEL;
58 63
59 settings->verbose = 0; 64 settings->verbose = 0;
60 settings->pruFilename[0] = '\0'; 65 settings->pruFilename[0] = '\0';
61 66
205 if(strlen(optarg) < MAX_PRU_FILENAME_LENGTH) 210 if(strlen(optarg) < MAX_PRU_FILENAME_LENGTH)
206 strcpy(settings->pruFilename, optarg); 211 strcpy(settings->pruFilename, optarg);
207 else 212 else
208 std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n"; 213 std::cerr << "Warning: filename for the PRU code is too long (>" << MAX_PRU_FILENAME_LENGTH << " characters). Using embedded PRU code instead\n";
209 break; 214 break;
215 case OPT_PGA_GAIN_LEFT:
216 settings->pgaGain[0] = atof(optarg);
217 break;
218 case OPT_PGA_GAIN_RIGHT:
219 settings->pgaGain[1] = atof(optarg);
220 break;
210 case '?': 221 case '?':
211 default: 222 default:
212 return c; 223 return c;
213 } 224 }
214 } 225 }
219 void BeagleRT_usage() 230 void BeagleRT_usage()
220 { 231 {
221 std::cerr << " --period [-p] period: Set the hardware period (buffer) size in analog samples\n"; 232 std::cerr << " --period [-p] period: Set the hardware period (buffer) size in analog samples\n";
222 std::cerr << " --dac-level [-D] dBs: Set the DAC output level (0dB max; -63.5dB min)\n"; 233 std::cerr << " --dac-level [-D] dBs: Set the DAC output level (0dB max; -63.5dB min)\n";
223 std::cerr << " --adc-level [-A] dBs: Set the ADC input level (0dB max; -12dB min)\n"; 234 std::cerr << " --adc-level [-A] dBs: Set the ADC input level (0dB max; -12dB min)\n";
235 std::cerr << " --pga-gain-left dBs: Set the Programmable Gain Amplifier for the left audio channel (0dBmin; 59.5dB max; default: 16dB)\n";
236 std::cerr << " --pga-gain-right dBs: Set the Programmable Gain Amplifier for the right audio channel (0dBmin; 59.5dB max; default: 16dB)\n";
224 std::cerr << " --hp-level [-H] dBs: Set the headphone output level (0dB max; -63.5dB min)\n"; 237 std::cerr << " --hp-level [-H] dBs: Set the headphone output level (0dB max; -63.5dB min)\n";
225 std::cerr << " --mute-speaker [-M] val: Set whether to mute the speaker initially (default: no)\n"; 238 std::cerr << " --mute-speaker [-M] val: Set whether to mute the speaker initially (default: no)\n";
226 std::cerr << " --use-analog [-N] val: Set whether to use ADC/DAC analog (default: yes)\n"; 239 std::cerr << " --use-analog [-N] val: Set whether to use ADC/DAC analog (default: yes)\n";
227 std::cerr << " --use-digital [-G] val: Set whether to use digital GPIO channels (default: yes)\n"; 240 std::cerr << " --use-digital [-G] val: Set whether to use digital GPIO channels (default: yes)\n";
228 std::cerr << " --analog-channels [-C] val: Set the number of ADC/DAC channels (default: 8)\n"; 241 std::cerr << " --analog-channels [-C] val: Set the number of ADC/DAC channels (default: 8)\n";