1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66
|
#ifndef __MP3_H
#define __MP3_H
/*
* Praat wrappers for libMAD (MPEG Audio Decoder)
* Copyright 2007 Erez Volk
*
* 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 2 of the License, or (at
* your option) any later version.
*
* 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, write to the Free Software
* Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
*/
#include <sys/types.h>
#include <stdio.h>
/* The following function is used to identify MP3 files */
int mp3_recognize (int nread, const char *data);
/* Actual decoding is done with an MP3_FILE object */
typedef struct _MP3_FILE *MP3_FILE;
typedef int MP3F_SAMPLE;
#if defined (_OFF_T) || defined (__off_t_defined)
typedef off_t MP3F_OFFSET;
#else
typedef unsigned long MP3F_OFFSET;
#endif
#define MP3F_MAX_CHANNELS 2
#define MP3F_MAX_SAMPLES 1152 /* Per callback */
typedef void (*MP3F_CALLBACK) (
const MP3F_SAMPLE *channels[MP3F_MAX_CHANNELS],
long num_samples,
void *context);
MP3_FILE mp3f_new (void);
void mp3f_delete (MP3_FILE mp3f);
void mp3f_set_file (MP3_FILE mp3f, FILE *f);
int mp3f_analyze (MP3_FILE mp3f);
unsigned mp3f_channels (MP3_FILE mp3f);
unsigned mp3f_frequency (MP3_FILE mp3f);
MP3F_OFFSET mp3f_samples (MP3_FILE mp3f);
void mp3f_set_callback (MP3_FILE mp3f,
MP3F_CALLBACK callback, void *context);
int mp3f_seek (MP3_FILE mp3f, MP3F_OFFSET sample);
int mp3f_read (MP3_FILE mp3f, MP3F_OFFSET num_samples);
#define mp3f_sample_to_float(s) ((float)((s) / (float)(1L << 28)))
short mp3f_sample_to_short (MP3F_SAMPLE sample);
#endif /* __MP3_H */
|