diff core/RTAudio.cpp @ 19:c98863e63174 matrix_gpio

Renamed matrixGpio to digital and matrix to analog
author Giulio Moro <giuliomoro@yahoo.it>
date Thu, 30 Apr 2015 16:58:41 +0100
parents 670be80463a3
children ad5cd8dd99b3
line wrap: on
line diff
--- a/core/RTAudio.cpp	Thu Apr 30 16:02:47 2015 +0100
+++ b/core/RTAudio.cpp	Thu Apr 30 16:58:41 2015 +0100
@@ -61,21 +61,21 @@
 int gAmplifierMutePin = -1;
 int gAmplifierShouldBeginMuted = 0;
 
-// Number of audio and matrix channels, globally accessible
-// At least gNumMatrixChannels and gNumMatrixGpioChannels need to be global to be used
-// by the analogRead() and analogWrite() and the digital macros without creating
+// Number of audio and analog channels, globally accessible
+// At least gNumAnalogChannels and gNumDigitalChannels need to be global to be used
+// by the AnalogRead() and AnalogWrite() and the digital macros without creating
 // extra confusion in their use cases by passing this argument
 int gNumAudioChannels = 0;
-int gNumMatrixChannels = 0;
-int gNumMatrixGpioChannels = 0;
+int gNumAnalogChannels = 0;
+int gNumDigitalChannels = 0;
 
 // initAudio() prepares the infrastructure for running PRU-based real-time
 // audio, but does not actually start the calculations.
 // periodSize indicates the number of _sensor_ frames per period: the audio period size
 // is twice this value. In total, the audio latency in frames will be 4*periodSize,
 // plus any latency inherent in the ADCs and DACs themselves.
-// useMatrix indicates whether to enable the ADC and DAC or just use the audio codec.
-// numMatrixChannels indicates how many ADC and DAC channels to use.
+// useAnalog indicates whether to enable the ADC and DAC or just use the audio codec.
+// numAnalogChannels indicates how many ADC and DAC channels to use.
 // userData is an opaque pointer which will be passed through to the initialise_render()
 // function for application-specific use
 //
@@ -91,10 +91,10 @@
 
 	if(gRTAudioVerbose) {
 		cout << "Starting with period size " << settings->periodSize << "; ";
-		if(settings->useMatrix)
-			cout << "matrix enabled\n";
+		if(settings->useAnalog)
+			cout << "analog enabled\n";
 		else
-			cout << "matrix disabled\n";
+			cout << "analog disabled\n";
 		cout << "DAC level " << settings->dacLevel << "dB; ADC level " << settings->adcLevel;
 		cout << "dB; headphone level " << settings->headphoneLevel << "dB\n";
 		if(settings->beginMuted)
@@ -122,21 +122,21 @@
 		}
 	}
 
-	// Limit the matrix channels to sane values
-	if(settings->numMatrixChannels >= 8)
-		settings->numMatrixChannels = 8;
-	else if(settings->numMatrixChannels >= 4)
-		settings->numMatrixChannels = 4;
+	// Limit the analog channels to sane values
+	if(settings->numAnalogChannels >= 8)
+		settings->numAnalogChannels = 8;
+	else if(settings->numAnalogChannels >= 4)
+		settings->numAnalogChannels = 4;
 	else
-		settings->numMatrixChannels = 2;
+		settings->numAnalogChannels = 2;
 
 	// Sanity check the combination of channels and period size
-	if(settings->numMatrixChannels <= 4 && settings->periodSize < 2) {
-		cout << "Error: " << settings->numMatrixChannels << " channels and period size of " << settings->periodSize << " not supported.\n";
+	if(settings->numAnalogChannels <= 4 && settings->periodSize < 2) {
+		cout << "Error: " << settings->numAnalogChannels << " channels and period size of " << settings->periodSize << " not supported.\n";
 		return 1;
 	}
-	if(settings->numMatrixChannels <= 2 && settings->periodSize < 4) {
-		cout << "Error: " << settings->numMatrixChannels << " channels and period size of " << settings->periodSize << " not supported.\n";
+	if(settings->numAnalogChannels <= 2 && settings->periodSize < 4) {
+		cout << "Error: " << settings->numAnalogChannels << " channels and period size of " << settings->periodSize << " not supported.\n";
 		return 1;
 	}
 
@@ -144,12 +144,12 @@
 	gPRU = new PRU();
 	gAudioCodec = new I2c_Codec();
 
-	gNumMatrixGpioChannels = settings->useMatrixGpio ? settings->numMatrixGpioChannels : 0; //this is called here to make sure prepareGPIO initializes the appropriate GPIO pins
-	if(gPRU->prepareGPIO(settings->useMatrix, settings->useMatrixGpio, 1, 1)) {
+	gNumDigitalChannels = settings->useDigital ? settings->numDigitalChannels : 0; //this is called here to make sure prepareGPIO initializes the appropriate GPIO pins
+	if(gPRU->prepareGPIO(settings->useAnalog, settings->useDigital, 1, 1)) {
 		cout << "Error: unable to prepare GPIO for PRU audio\n";
 		return 1;
 	}
-	if(gPRU->initialise(0, settings->periodSize, settings->numMatrixChannels, true)) {
+	if(gPRU->initialise(0, settings->periodSize, settings->numAnalogChannels, true)) {
 		cout << "Error: unable to initialise PRU\n";
 		return 1;
 	}
@@ -167,23 +167,23 @@
 	BeagleRT_setADCLevel(settings->adcLevel);
 	BeagleRT_setHeadphoneLevel(settings->headphoneLevel);
 
-	// Initialise the rendering environment: pass the number of audio and matrix
-	// channels, the period size for matrix and audio, and the sample rates
+	// Initialise the rendering environment: pass the number of audio and analog
+	// channels, the period size for analog and audio, and the sample rates
 
 	int audioPeriodSize = settings->periodSize * 2;
 	float audioSampleRate = 44100.0;
-	float matrixSampleRate = 22050.0;
-	if(settings->useMatrix) {
-		audioPeriodSize = settings->periodSize * settings->numMatrixChannels / 4;
-		matrixSampleRate = audioSampleRate * 4.0 / (float)settings->numMatrixChannels;
+	float analogSampleRate = 22050.0;
+	if(settings->useAnalog) {
+		audioPeriodSize = settings->periodSize * settings->numAnalogChannels / 4;
+		analogSampleRate = audioSampleRate * 4.0 / (float)settings->numAnalogChannels;
 	}
 
 	gNumAudioChannels = 2;
-	gNumMatrixChannels = settings->useMatrix ? settings->numMatrixChannels : 0;
-	if(!initialise_render(gNumMatrixChannels, gNumMatrixGpioChannels, gNumAudioChannels,
-				          settings->useMatrix ? settings->periodSize : 0, /* matrix period size */
+	gNumAnalogChannels = settings->useAnalog ? settings->numAnalogChannels : 0;
+	if(!initialise_render(gNumAnalogChannels, gNumDigitalChannels, gNumAudioChannels,
+				          settings->useAnalog ? settings->periodSize : 0, /* analog period size */
 				          audioPeriodSize,
-				          matrixSampleRate, audioSampleRate,
+				          analogSampleRate, audioSampleRate,
 				          userData)) {
 		cout << "Couldn't initialise audio rendering\n";
 		return 1;