Mercurial > hg > beaglert
diff core/RTAudio.cpp @ 16:670be80463a3 matrix_gpio
- analog matrixIn/matrixOut are now mapped as floats from 0 to 1
- use of an external PRU code can be enabled with -P <filename>
- 16 channels of programmable GPIO can be accessed straight from render() either writing directly to the matrixGpio[] array or using digitalWrite(),
digitalRead(), setDigitalDirection() macros from Utilities.h .
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Mon, 27 Apr 2015 13:01:57 +0100 |
parents | 901d205d1a3c |
children | c98863e63174 |
line wrap: on
line diff
--- a/core/RTAudio.cpp Sat Feb 07 16:41:56 2015 +0000 +++ b/core/RTAudio.cpp Mon Apr 27 13:01:57 2015 +0100 @@ -56,16 +56,18 @@ bool gShouldStop = false; // general settings +char *gPRUFilename;//[256] = "pru_rtaudio.bin"; // path to PRU binary file int gRTAudioVerbose = 0; // Verbosity level for debugging int gAmplifierMutePin = -1; int gAmplifierShouldBeginMuted = 0; // Number of audio and matrix channels, globally accessible -// At least gNumMatrixChannels needs to be global to be used -// by the analogRead() and analogWrite() macros without creating +// At least gNumMatrixChannels and gNumMatrixGpioChannels 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; // initAudio() prepares the infrastructure for running PRU-based real-time // audio, but does not actually start the calculations. @@ -83,7 +85,7 @@ { rt_print_auto_init(1); setVerboseLevel(settings->verbose); - + gPRUFilename=settings->pruFilename; if(gRTAudioVerbose == 1) rt_printf("Running with Xenomai\n"); @@ -106,7 +108,7 @@ if(gpio_export(settings->ampMutePin)) { if(gRTAudioVerbose) - cout << "Warning: couldn't export amplifier mute pin\n"; + cout << "Warning: couldn't export amplifier mute pin " << settings-> ampMutePin << "\n"; } if(gpio_set_dir(settings->ampMutePin, OUTPUT_PIN)) { if(gRTAudioVerbose) @@ -142,7 +144,8 @@ gPRU = new PRU(); gAudioCodec = new I2c_Codec(); - if(gPRU->prepareGPIO(settings->useMatrix, 1, 1)) { + 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)) { cout << "Error: unable to prepare GPIO for PRU audio\n"; return 1; } @@ -177,8 +180,7 @@ gNumAudioChannels = 2; gNumMatrixChannels = settings->useMatrix ? settings->numMatrixChannels : 0; - - if(!initialise_render(gNumMatrixChannels, gNumAudioChannels, + if(!initialise_render(gNumMatrixChannels, gNumMatrixGpioChannels, gNumAudioChannels, settings->useMatrix ? settings->periodSize : 0, /* matrix period size */ audioPeriodSize, matrixSampleRate, audioSampleRate, @@ -208,8 +210,8 @@ gShouldStop = 1; } else { - if(gPRU->start()) { - rt_printf("Error: unable to start PRU\n"); + if(gPRU->start(gPRUFilename)) { + rt_printf("Error: unable to start PRU from file %s\n", gPRUFilename); gShouldStop = 1; } else {