annotate include/RTAudio.h @ 39:638bc1ae2500 staging

Improved readibility of the DIGITAL code in the PRU, using register names instead of aliases and expanding some of the macros, removing unused macros. Binaries were not modified
author Giulio Moro <giuliomoro@yahoo.it>
date Wed, 13 May 2015 12:18:10 +0100
parents ad5cd8dd99b3
children
rev   line source
andrewm@0 1 /*
andrewm@0 2 * RTAudio.h
andrewm@0 3 *
andrewm@0 4 * Central control code for hard real-time audio on BeagleBone Black
andrewm@0 5 * using PRU and Xenomai Linux extensions. This code began as part
andrewm@0 6 * of the Hackable Instruments project (EPSRC) at Queen Mary University
andrewm@0 7 * of London, 2013-14.
andrewm@0 8 *
andrewm@0 9 * (c) 2014 Victor Zappi and Andrew McPherson
andrewm@0 10 * Queen Mary University of London
andrewm@0 11 */
andrewm@0 12
andrewm@0 13
andrewm@0 14 #ifndef RTAUDIO_H_
andrewm@0 15 #define RTAUDIO_H_
giuliomoro@24 16 #include "RTAudioSettings.h"
andrewm@0 17 #include "render.h"
andrewm@0 18
andrewm@0 19 // Useful constants
andrewm@0 20 #define DBOX_CAPE // New custom cape
andrewm@0 21
andrewm@0 22 #ifdef DBOX_CAPE
andrewm@0 23 #define CODEC_I2C_ADDRESS 0x18 // Address of TLV320AIC3104 codec
andrewm@0 24 #else
andrewm@0 25 #define CODEC_I2C_ADDRESS 0x1B // Address of TLV320AIC3106 codec
andrewm@0 26 #endif
andrewm@0 27
andrewm@5 28 // Default volume levels
andrewm@5 29 #define DEFAULT_DAC_LEVEL 0.0
andrewm@5 30 #define DEFAULT_ADC_LEVEL -6.0
andrewm@5 31 #define DEFAULT_HP_LEVEL -6.0
andrewm@5 32
andrewm@0 33 enum {
andrewm@0 34 kAmplifierMutePin = 61 // P8-26 controls amplifier mute
andrewm@0 35 };
andrewm@0 36
andrewm@0 37 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks
andrewm@0 38
andrewm@0 39 // Flag that indicates when the audio will stop; can be read or
andrewm@0 40 // set by other components which should end at the same time as the audio
andrewm@0 41 extern bool gShouldStop;
andrewm@0 42
andrewm@5 43 // Command-line settings
andrewm@5 44 void BeagleRT_defaultSettings(RTAudioSettings *settings);
andrewm@5 45 int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions,
andrewm@5 46 const struct option *customLongOptions, RTAudioSettings *settings);
andrewm@5 47 void BeagleRT_usage();
andrewm@0 48
andrewm@5 49 // Basic audio control functions: init, start, stop and clean up
andrewm@5 50 int BeagleRT_initAudio(RTAudioSettings *settings, void *userData);
andrewm@5 51 int BeagleRT_startAudio();
andrewm@5 52 void BeagleRT_stopAudio();
andrewm@5 53 void BeagleRT_cleanupAudio();
andrewm@5 54
andrewm@5 55 // Volume/level controls
andrewm@5 56 // These return 0 on success
andrewm@5 57
andrewm@5 58 // Set the level of the DAC; affects all outputs (headphone, line, speaker)
andrewm@5 59 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps
andrewm@5 60 int BeagleRT_setDACLevel(float decibels);
andrewm@5 61
andrewm@5 62 // Set the level of the ADC
andrewm@5 63 // 0dB is the maximum, -12dB is the minimum; 1.5dB steps
andrewm@5 64 int BeagleRT_setADCLevel(float decibels);
andrewm@5 65
andrewm@5 66 // Set the level of the onboard headphone amplifier; affects headphone
andrewm@5 67 // output only (not line out or speaker)
andrewm@5 68 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps
andrewm@5 69 int BeagleRT_setHeadphoneLevel(float decibels);
andrewm@5 70
andrewm@5 71 // Mute or unmute the onboard speaker amplifiers
andrewm@5 72 // mute == 0 means unmute; otherwise mute
andrewm@5 73 // Returns 0 on success
andrewm@5 74 int BeagleRT_muteSpeakers(int mute);
andrewm@5 75
andrewm@5 76 // Functions for creating auxiliary tasks
andrewm@0 77 AuxiliaryTask createAuxiliaryTaskLoop(void (*functionToCall)(void), int priority, const char *name);
andrewm@0 78 void scheduleAuxiliaryTask(AuxiliaryTask task);
andrewm@0 79
andrewm@0 80 void setVerboseLevel(int level);
andrewm@0 81
andrewm@0 82 #endif /* RTAUDIO_H_ */