annotate include/RTAudio.h @ 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
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
giuliomoro@16 32 #define MAX_PRU_FILENAME_LENGTH 256
andrewm@5 33
andrewm@0 34 enum {
andrewm@0 35 kAmplifierMutePin = 61 // P8-26 controls amplifier mute
andrewm@0 36 };
andrewm@0 37
andrewm@5 38 // Structure which contains initialisation parameters for the
andrewm@5 39 // real-time audio system
andrewm@5 40 typedef struct {
andrewm@5 41 // These items might be adjusted by the user:
giuliomoro@19 42 int periodSize; // Number of (analog) frames per period; audio is twice this
andrewm@5 43 int beginMuted; // Whether to begin with the speakers muted
andrewm@5 44 float dacLevel; // Level for the audio DAC output
andrewm@5 45 float adcLevel; // Level for the audio ADC input
andrewm@5 46 float headphoneLevel; // Level for the headphone output
giuliomoro@19 47 int useAnalog; // Whether to use the analog
giuliomoro@19 48 int useDigital; // Whether to use the 16 programmable GPIOs
giuliomoro@19 49 int numAnalogChannels; // How many channels for the ADC and DAC
giuliomoro@19 50 int numDigitalChannels; // How many channels for the GPIOs
andrewm@5 51 int verbose; // Whether to use verbose logging
giuliomoro@16 52 char pruFilename[MAX_PRU_FILENAME_LENGTH]; //the external .bin file to load. If empty will use PRU code from pru_rtaudio_bin.h
andrewm@5 53 // These items are hardware-dependent and should only be changed
andrewm@5 54 // to run on different hardware
andrewm@5 55 int codecI2CAddress; // Where the codec can be found on the I2C bus
andrewm@5 56 int ampMutePin; // Pin where amplifier mute can be found
andrewm@5 57 } RTAudioSettings;
andrewm@5 58
andrewm@0 59 typedef void* AuxiliaryTask; // Opaque data type to keep track of aux tasks
andrewm@0 60
andrewm@0 61 // Flag that indicates when the audio will stop; can be read or
andrewm@0 62 // set by other components which should end at the same time as the audio
andrewm@0 63 extern bool gShouldStop;
andrewm@0 64
andrewm@5 65 // Command-line settings
andrewm@5 66 void BeagleRT_defaultSettings(RTAudioSettings *settings);
andrewm@5 67 int BeagleRT_getopt_long(int argc, char *argv[], const char *customShortOptions,
andrewm@5 68 const struct option *customLongOptions, RTAudioSettings *settings);
andrewm@5 69 void BeagleRT_usage();
andrewm@0 70
andrewm@5 71 // Basic audio control functions: init, start, stop and clean up
andrewm@5 72 int BeagleRT_initAudio(RTAudioSettings *settings, void *userData);
andrewm@5 73 int BeagleRT_startAudio();
andrewm@5 74 void BeagleRT_stopAudio();
andrewm@5 75 void BeagleRT_cleanupAudio();
andrewm@5 76
andrewm@5 77 // Volume/level controls
andrewm@5 78 // These return 0 on success
andrewm@5 79
andrewm@5 80 // Set the level of the DAC; affects all outputs (headphone, line, speaker)
andrewm@5 81 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps
andrewm@5 82 int BeagleRT_setDACLevel(float decibels);
andrewm@5 83
andrewm@5 84 // Set the level of the ADC
andrewm@5 85 // 0dB is the maximum, -12dB is the minimum; 1.5dB steps
andrewm@5 86 int BeagleRT_setADCLevel(float decibels);
andrewm@5 87
andrewm@5 88 // Set the level of the onboard headphone amplifier; affects headphone
andrewm@5 89 // output only (not line out or speaker)
andrewm@5 90 // 0dB is the maximum, -63.5dB is the minimum; 0.5dB steps
andrewm@5 91 int BeagleRT_setHeadphoneLevel(float decibels);
andrewm@5 92
andrewm@5 93 // Mute or unmute the onboard speaker amplifiers
andrewm@5 94 // mute == 0 means unmute; otherwise mute
andrewm@5 95 // Returns 0 on success
andrewm@5 96 int BeagleRT_muteSpeakers(int mute);
andrewm@5 97
andrewm@5 98 // Functions for creating auxiliary tasks
andrewm@0 99 AuxiliaryTask createAuxiliaryTaskLoop(void (*functionToCall)(void), int priority, const char *name);
andrewm@0 100 void scheduleAuxiliaryTask(AuxiliaryTask task);
andrewm@0 101
andrewm@0 102 void setVerboseLevel(int level);
andrewm@0 103
andrewm@0 104 #endif /* RTAUDIO_H_ */