annotate include/RTAudio.h @ 13:6adb088196a7

Fixed ADC bug; added a simple passthrough test
author andrewm
date Fri, 23 Jan 2015 15:17:09 +0000
parents a6beeba3a648
children 670be80463a3
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_
andrewm@0 16
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@5 37 // Structure which contains initialisation parameters for the
andrewm@5 38 // real-time audio system
andrewm@5 39 typedef struct {
andrewm@5 40 // These items might be adjusted by the user:
andrewm@5 41 int periodSize; // Number of (matrix) frames per period; audio is twice this
andrewm@5 42 int beginMuted; // Whether to begin with the speakers muted
andrewm@5 43 float dacLevel; // Level for the audio DAC output
andrewm@5 44 float adcLevel; // Level for the audio ADC input
andrewm@5 45 float headphoneLevel; // Level for the headphone output
andrewm@12 46 int useMatrix; // Whether to use the matrix
andrewm@12 47 int numMatrixChannels; // How many channels for the ADC and DAC
andrewm@5 48 int verbose; // Whether to use verbose logging
andrewm@5 49
andrewm@5 50 // These items are hardware-dependent and should only be changed
andrewm@5 51 // to run on different hardware
andrewm@5 52 int codecI2CAddress; // Where the codec can be found on the I2C bus
andrewm@5 53 int ampMutePin; // Pin where amplifier mute can be found
andrewm@5 54 } RTAudioSettings;
andrewm@5 55
andrewm@0 56 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks
andrewm@0 57
andrewm@0 58 // Flag that indicates when the audio will stop; can be read or
andrewm@0 59 // set by other components which should end at the same time as the audio
andrewm@0 60 extern bool gShouldStop;
andrewm@0 61
andrewm@5 62 // Command-line settings
andrewm@5 63 void BeagleRT_defaultSettings(RTAudioSettings *settings);
andrewm@5 64 int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions,
andrewm@5 65 const struct option *customLongOptions, RTAudioSettings *settings);
andrewm@5 66 void BeagleRT_usage();
andrewm@0 67
andrewm@5 68 // Basic audio control functions: init, start, stop and clean up
andrewm@5 69 int BeagleRT_initAudio(RTAudioSettings *settings, void *userData);
andrewm@5 70 int BeagleRT_startAudio();
andrewm@5 71 void BeagleRT_stopAudio();
andrewm@5 72 void BeagleRT_cleanupAudio();
andrewm@5 73
andrewm@5 74 // Volume/level controls
andrewm@5 75 // These return 0 on success
andrewm@5 76
andrewm@5 77 // Set the level of the DAC; affects all outputs (headphone, line, speaker)
andrewm@5 78 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps
andrewm@5 79 int BeagleRT_setDACLevel(float decibels);
andrewm@5 80
andrewm@5 81 // Set the level of the ADC
andrewm@5 82 // 0dB is the maximum, -12dB is the minimum; 1.5dB steps
andrewm@5 83 int BeagleRT_setADCLevel(float decibels);
andrewm@5 84
andrewm@5 85 // Set the level of the onboard headphone amplifier; affects headphone
andrewm@5 86 // output only (not line out or speaker)
andrewm@5 87 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps
andrewm@5 88 int BeagleRT_setHeadphoneLevel(float decibels);
andrewm@5 89
andrewm@5 90 // Mute or unmute the onboard speaker amplifiers
andrewm@5 91 // mute == 0 means unmute; otherwise mute
andrewm@5 92 // Returns 0 on success
andrewm@5 93 int BeagleRT_muteSpeakers(int mute);
andrewm@5 94
andrewm@5 95 // Functions for creating auxiliary tasks
andrewm@0 96 AuxiliaryTask createAuxiliaryTaskLoop(void (*functionToCall)(void), int priority, const char *name);
andrewm@0 97 void scheduleAuxiliaryTask(AuxiliaryTask task);
andrewm@0 98
andrewm@0 99 void setVerboseLevel(int level);
andrewm@0 100
andrewm@0 101 #endif /* RTAUDIO_H_ */