Mercurial > hg > beaglert
diff core/RTAudio.cpp @ 301:e4392164b458 prerelease
RENAMED BeagleRT to Bela AAAAAAAAAAAAAAAAAAAAAAAAAAAAAA, scripts probably not working
author | Giulio Moro <giuliomoro@yahoo.it> |
---|---|
date | Fri, 27 May 2016 14:34:41 +0100 |
parents | c55c6f6c233c |
children | 421a69d42943 |
line wrap: on
line diff
--- a/core/RTAudio.cpp Fri May 27 13:58:20 2016 +0100 +++ b/core/RTAudio.cpp Fri May 27 14:34:41 2016 +0100 @@ -27,7 +27,7 @@ #include <native/intr.h> #include <rtdk.h> -#include "../include/BeagleRT.h" +#include "../include/Bela.h" #include "../include/PRU.h" #include "../include/I2c_Codec.h" #include "../include/GPIOcontrol.h" @@ -77,7 +77,7 @@ int gAmplifierShouldBeginMuted = 0; // Context which holds all the audio/sensor data passed to the render routines -BeagleRTContext gContext; +BelaContext gContext; // User data passed in from main() void *gUserData; @@ -96,7 +96,7 @@ // // Returns 0 on success. -int BeagleRT_initAudio(BeagleRTInitSettings *settings, void *userData) +int Bela_initAudio(BelaInitSettings *settings, void *userData) { // Sanity checks if(settings->pruNumber < 0 || settings->pruNumber > 1) { @@ -110,12 +110,12 @@ rt_print_auto_init(1); - BeagleRT_setVerboseLevel(settings->verbose); + Bela_setVerboseLevel(settings->verbose); strncpy(gPRUFilename, settings->pruFilename, MAX_PRU_FILENAME_LENGTH); gUserData = userData; // Initialise context data structure - memset(&gContext, 0, sizeof(BeagleRTContext)); + memset(&gContext, 0, sizeof(BelaContext)); if(gRTAudioVerbose) { cout << "Starting with period size " << settings->periodSize << "; "; @@ -231,17 +231,17 @@ } // Set default volume levels - BeagleRT_setDACLevel(settings->dacLevel); - BeagleRT_setADCLevel(settings->adcLevel); + Bela_setDACLevel(settings->dacLevel); + Bela_setADCLevel(settings->adcLevel); // TODO: add more argument checks for(int n = 0; n < 2; n++){ if(settings->pgaGain[n] > 59.5){ std::cerr << "PGA gain out of range [0,59.5]\n"; exit(1); } - BeagleRT_setPgaGain(settings->pgaGain[n], n); + Bela_setPgaGain(settings->pgaGain[n], n); } - BeagleRT_setHeadphoneLevel(settings->headphoneLevel); + Bela_setHeadphoneLevel(settings->headphoneLevel); // Call the user-defined initialisation function if(!setup(&gContext, userData)) { @@ -279,7 +279,7 @@ if(!gAmplifierShouldBeginMuted) { // First unmute the amplifier - if(BeagleRT_muteSpeakers(0)) { + if(Bela_muteSpeakers(0)) { if(gRTAudioVerbose) rt_printf("Warning: couldn't set value (high) on amplifier mute pin\n"); } @@ -306,7 +306,7 @@ // (equal or lower) priority. Audio priority is defined in BEAGLERT_AUDIO_PRIORITY; // priority should be generally be less than this. // Returns an (opaque) pointer to the created task on success; 0 on failure -AuxiliaryTask BeagleRT_createAuxiliaryTask(void (*functionToCall)(void* args), int priority, const char *name, void* args, bool autoSchedule) +AuxiliaryTask Bela_createAuxiliaryTask(void (*functionToCall)(void* args), int priority, const char *name, void* args, bool autoSchedule) { InternalAuxiliaryTask *newTask = (InternalAuxiliaryTask*)malloc(sizeof(InternalAuxiliaryTask)); @@ -330,7 +330,7 @@ return (AuxiliaryTask)newTask; } -AuxiliaryTask BeagleRT_createAuxiliaryTask(void (*functionToCall)(void), int priority, const char *name, bool autoSchedule) +AuxiliaryTask Bela_createAuxiliaryTask(void (*functionToCall)(void), int priority, const char *name, bool autoSchedule) { InternalAuxiliaryTask *newTask = (InternalAuxiliaryTask*)malloc(sizeof(InternalAuxiliaryTask)); @@ -356,20 +356,20 @@ // Schedule a previously created (and started) auxiliary task. It will run when the priority rules next // allow it to be scheduled. -void BeagleRT_scheduleAuxiliaryTask(AuxiliaryTask task) +void Bela_scheduleAuxiliaryTask(AuxiliaryTask task) { InternalAuxiliaryTask *taskToSchedule = (InternalAuxiliaryTask *)task; if(taskToSchedule->started == false){ // Note: this is not the safest method to check if a task - BeagleRT_startAuxiliaryTask(task); // is started (or ready to be resumed), but it probably is the fastest. + Bela_startAuxiliaryTask(task); // is started (or ready to be resumed), but it probably is the fastest. // A safer approach would use rt_task_inquire() } rt_task_resume(&taskToSchedule->task); } -void BeagleRT_autoScheduleAuxiliaryTasks(){ +void Bela_autoScheduleAuxiliaryTasks(){ vector<InternalAuxiliaryTask*>::iterator it; for(it = getAuxTasks().begin(); it != getAuxTasks().end(); it++) { if ((InternalAuxiliaryTask *)(*it)->autoSchedule){ - BeagleRT_scheduleAuxiliaryTask(*it); + Bela_scheduleAuxiliaryTask(*it); } } } @@ -407,7 +407,7 @@ } -int BeagleRT_startAuxiliaryTask(AuxiliaryTask task){ +int Bela_startAuxiliaryTask(AuxiliaryTask task){ InternalAuxiliaryTask *taskStruct; taskStruct = (InternalAuxiliaryTask *)task; if(taskStruct->started == true) @@ -424,7 +424,7 @@ // It launches the real-time Xenomai task which runs the audio loop. Returns 0 // on success. -int BeagleRT_startAudio() +int Bela_startAudio() { // Create audio thread with high Xenomai priority if(rt_task_create(&gRTAudioThread, gRTAudioThreadName, 0, BEAGLERT_AUDIO_PRIORITY, T_JOINABLE | T_FPU)) { @@ -450,7 +450,7 @@ // The user may have created other tasks. Start those also. vector<InternalAuxiliaryTask*>::iterator it; for(it = getAuxTasks().begin(); it != getAuxTasks().end(); it++) { - int ret = BeagleRT_startAuxiliaryTask(*it); + int ret = Bela_startAuxiliaryTask(*it); if(ret != 0) return -2; } @@ -460,7 +460,7 @@ // Stop the PRU-based audio from running and wait // for the tasks to complete before returning. -void BeagleRT_stopAudio() +void Bela_stopAudio() { // Tell audio thread to stop (if this hasn't been done already) gShouldStop = true; @@ -483,7 +483,7 @@ } // Free any resources associated with PRU real-time audio -void BeagleRT_cleanupAudio() +void Bela_cleanupAudio() { cleanup(&gContext, gUserData); @@ -519,7 +519,7 @@ // Set the level of the DAC; affects all outputs (headphone, line, speaker) // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps -int BeagleRT_setDACLevel(float decibels) +int Bela_setDACLevel(float decibels) { if(gAudioCodec == 0) return -1; @@ -528,7 +528,7 @@ // Set the level of the ADC // 0dB is the maximum, -12dB is the minimum; 1.5dB steps -int BeagleRT_setADCLevel(float decibels) +int Bela_setADCLevel(float decibels) { if(gAudioCodec == 0) return -1; @@ -537,7 +537,7 @@ // Set the level of the Programmable Gain Amplifier // 59.5dB is maximum, 0dB is minimum; 0.5dB steps -int BeagleRT_setPgaGain(float decibels, int channel){ +int Bela_setPgaGain(float decibels, int channel){ if(gAudioCodec == 0) return -1; return gAudioCodec->setPga(decibels, channel); @@ -546,7 +546,7 @@ // Set the level of the onboard headphone amplifier; affects headphone // output only (not line out or speaker) // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps -int BeagleRT_setHeadphoneLevel(float decibels) +int Bela_setHeadphoneLevel(float decibels) { if(gAudioCodec == 0) return -1; @@ -556,7 +556,7 @@ // Mute or unmute the onboard speaker amplifiers // mute == 0 means unmute; otherwise mute // Returns 0 on success -int BeagleRT_muteSpeakers(int mute) +int Bela_muteSpeakers(int mute) { int pinValue = mute ? LOW : HIGH; @@ -568,7 +568,7 @@ } // Set the verbosity level -void BeagleRT_setVerboseLevel(int level) +void Bela_setVerboseLevel(int level) { gRTAudioVerbose = level; }