Explorar el Código

Add volume() function to AudioInputUSB

main
PaulStoffregen hace 7 años
padre
commit
a47e0cfb8f
Se han modificado 2 ficheros con 5 adiciones y 3 borrados
  1. +1
    -1
      teensy3/usb_audio.cpp
  2. +4
    -2
      teensy3/usb_audio.h

+ 1
- 1
teensy3/usb_audio.cpp Ver fichero

uint16_t AudioInputUSB::incoming_count; uint16_t AudioInputUSB::incoming_count;
uint8_t AudioInputUSB::receive_flag; uint8_t AudioInputUSB::receive_flag;


struct usb_audio_features_struct AudioInputUSB::features = {0,0,FEATURE_MAX_VOLUME};
struct usb_audio_features_struct AudioInputUSB::features = {0,0,FEATURE_MAX_VOLUME/2};


#define DMABUFATTR __attribute__ ((section(".dmabuffers"), aligned (4))) #define DMABUFATTR __attribute__ ((section(".dmabuffers"), aligned (4)))
uint16_t usb_audio_receive_buffer[AUDIO_RX_SIZE/2] DMABUFATTR; uint16_t usb_audio_receive_buffer[AUDIO_RX_SIZE/2] DMABUFATTR;

+ 4
- 2
teensy3/usb_audio.h Ver fichero

friend void usb_audio_receive_callback(unsigned int len); friend void usb_audio_receive_callback(unsigned int len);
friend int usb_audio_set_feature(void *stp, uint8_t *buf); friend int usb_audio_set_feature(void *stp, uint8_t *buf);
friend int usb_audio_get_feature(void *stp, uint8_t *data, uint32_t *datalen); friend int usb_audio_get_feature(void *stp, uint8_t *data, uint32_t *datalen);

static struct usb_audio_features_struct features; static struct usb_audio_features_struct features;

float volume(void) {
if (features.mute) return 0.0;
return (float)(features.volume) * (1.0 / (float)FEATURE_MAX_VOLUME);
}
private: private:
static bool update_responsibility; static bool update_responsibility;
static audio_block_t *incoming_left; static audio_block_t *incoming_left;

Cargando…
Cancelar
Guardar