2011-06-08 23:00:22 +02:00
|
|
|
/*
|
|
|
|
* simpleaudio.h
|
|
|
|
*
|
2012-08-14 06:09:24 +02:00
|
|
|
* Copyright (C) 2011-2012 Kamal Mostafa <kamal@whence.com>
|
2011-06-08 23:00:22 +02:00
|
|
|
*
|
2011-06-23 02:10:50 +02:00
|
|
|
* This program is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
2011-06-08 23:00:22 +02:00
|
|
|
*
|
2011-06-23 02:10:50 +02:00
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program. If not, see <http://www.gnu.org/licenses/>.
|
2011-06-08 23:00:22 +02:00
|
|
|
*/
|
|
|
|
|
2011-05-30 07:20:28 +02:00
|
|
|
#ifndef SIMPLEAUDIO_H
|
|
|
|
#define SIMPLEAUDIO_H
|
|
|
|
|
|
|
|
#include <sys/types.h>
|
|
|
|
|
|
|
|
struct simpleaudio;
|
|
|
|
typedef struct simpleaudio simpleaudio;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* simpleaudio_open_source_XXXX() routines which return a (simpleaudio *)
|
|
|
|
* are provided by the separate backend modules.
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2012-08-12 23:24:55 +02:00
|
|
|
/* sa_backend */
|
|
|
|
typedef enum {
|
|
|
|
SA_BACKEND_SYSDEFAULT=0,
|
|
|
|
SA_BACKEND_FILE,
|
2012-08-14 00:50:04 +02:00
|
|
|
SA_BACKEND_BENCHMARK,
|
2012-08-12 23:24:55 +02:00
|
|
|
SA_BACKEND_ALSA,
|
|
|
|
SA_BACKEND_PULSEAUDIO,
|
|
|
|
} sa_backend_t;
|
|
|
|
|
2012-08-12 06:00:37 +02:00
|
|
|
/* sa_stream_direction */
|
2012-08-12 23:24:55 +02:00
|
|
|
typedef enum {
|
|
|
|
SA_STREAM_PLAYBACK,
|
|
|
|
SA_STREAM_RECORD,
|
|
|
|
} sa_direction_t;
|
2011-06-17 23:21:31 +02:00
|
|
|
|
2012-08-12 06:00:37 +02:00
|
|
|
/* sa_stream_format */
|
|
|
|
typedef enum {
|
2012-08-12 23:24:55 +02:00
|
|
|
SA_SAMPLE_FORMAT_S16,
|
|
|
|
SA_SAMPLE_FORMAT_FLOAT,
|
|
|
|
} sa_format_t;
|
2011-05-30 07:20:28 +02:00
|
|
|
|
2012-08-08 23:25:53 +02:00
|
|
|
simpleaudio *
|
2012-08-12 23:24:55 +02:00
|
|
|
simpleaudio_open_stream(
|
|
|
|
sa_backend_t sa_backend,
|
2012-09-10 00:24:01 +02:00
|
|
|
const char *backend_device,
|
2012-08-12 23:24:55 +02:00
|
|
|
sa_direction_t sa_stream_direction,
|
|
|
|
sa_format_t sa_format,
|
2012-08-11 19:07:12 +02:00
|
|
|
unsigned int rate, unsigned int channels,
|
2012-08-08 23:25:53 +02:00
|
|
|
char *app_name, char *stream_name );
|
|
|
|
|
2011-05-30 07:20:28 +02:00
|
|
|
unsigned int
|
|
|
|
simpleaudio_get_rate( simpleaudio *sa );
|
|
|
|
|
|
|
|
unsigned int
|
|
|
|
simpleaudio_get_channels( simpleaudio *sa );
|
|
|
|
|
2012-08-12 05:40:20 +02:00
|
|
|
unsigned int
|
|
|
|
simpleaudio_get_framesize( simpleaudio *sa );
|
|
|
|
|
2012-08-12 23:24:55 +02:00
|
|
|
sa_format_t
|
2012-08-12 06:00:37 +02:00
|
|
|
simpleaudio_get_format( simpleaudio *sa );
|
|
|
|
|
2012-08-12 05:40:20 +02:00
|
|
|
unsigned int
|
|
|
|
simpleaudio_get_samplesize( simpleaudio *sa );
|
|
|
|
|
2012-08-30 09:00:19 +02:00
|
|
|
void
|
|
|
|
simpleaudio_set_rxnoise( simpleaudio *sa, float rxnoise_factor );
|
|
|
|
|
2011-06-08 01:31:26 +02:00
|
|
|
ssize_t
|
2012-08-12 23:39:23 +02:00
|
|
|
simpleaudio_read( simpleaudio *sa, void *buf, size_t nframes );
|
2011-05-30 07:20:28 +02:00
|
|
|
|
2011-06-17 23:21:31 +02:00
|
|
|
ssize_t
|
2012-08-12 23:39:23 +02:00
|
|
|
simpleaudio_write( simpleaudio *sa, void *buf, size_t nframes );
|
2011-06-17 23:21:31 +02:00
|
|
|
|
2011-05-30 07:20:28 +02:00
|
|
|
void
|
|
|
|
simpleaudio_close( simpleaudio *sa );
|
|
|
|
|
|
|
|
|
2011-06-18 20:29:00 +02:00
|
|
|
/*
|
|
|
|
* simpleaudio tone generator
|
|
|
|
*/
|
|
|
|
|
|
|
|
void
|
|
|
|
simpleaudio_tone_reset();
|
|
|
|
|
|
|
|
void
|
|
|
|
simpleaudio_tone(simpleaudio *sa_out, float tone_freq, size_t nsamples_dur);
|
|
|
|
|
2012-08-14 06:09:24 +02:00
|
|
|
void
|
2012-08-25 09:32:11 +02:00
|
|
|
simpleaudio_tone_init( unsigned int new_sin_table_len, float mag );
|
2011-06-18 20:29:00 +02:00
|
|
|
|
2011-05-30 07:20:28 +02:00
|
|
|
#endif
|