#if !defined(__RPI_MICROPHONE_H__)
#define __RPI_MICROPHONE_H__

#include <pthread.h>
#include <stdbool.h>

typedef struct {
  int FFTbassbufferSize;
  int FFTmidbufferSize;
  int FFTtreblebufferSize;
  int bass_index;
  int mid_index;
  int treble_index;
  double *bass_multiplier;
  double *mid_multiplier;
  double *treble_multiplier;
  double *in_bass_l_raw;
  double *in_mid_l_raw;
  double *in_treble_l_raw;
  double *in_bass_l;
  double *in_mid_l;
  double *in_treble_l;
  int format;
  unsigned int rate;
  char *source; // alsa device, fifo path or pulse source
  int im;       // input mode alsa, fifo or pulse
  unsigned int channels;
  bool left, right, average;
  int terminate; // shared variable used to terminate audio thread
  char error_message[1024];
  pthread_mutex_t lock;
} audio_data_t;

void *microphone_listen(void *arg);

void microphone_setup(audio_data_t *audio);

void microphone_exec(audio_data_t *audio);

void reset_output_buffers(audio_data_t *data);

#endif /* __RPI_MICROPHONE_H__ */