music_mad.h 2.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. /*
  2. SDL_mixer: An audio mixer library based on the SDL library
  3. Copyright (C) 1997-2004 Sam Lantinga
  4. This library is free software; you can redistribute it and/or
  5. modify it under the terms of the GNU Library General Public
  6. License as published by the Free Software Foundation; either
  7. version 2 of the License, or (at your option) any later version.
  8. This library is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. Library General Public License for more details.
  12. You should have received a copy of the GNU Library General Public
  13. License along with this library; if not, write to the Free
  14. Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
  15. Sam Lantinga
  16. slouken@libsdl.org
  17. */
  18. #include "mad.h"
  19. #include "SDL_rwops.h"
  20. #include "SDL_audio.h"
  21. #define MAD_INPUT_BUFFER_SIZE (5*8192)
  22. #define MAD_OUTPUT_BUFFER_SIZE 8192
  23. enum {
  24. MS_input_eof = 0x0001,
  25. MS_input_error = 0x0001,
  26. MS_decode_eof = 0x0002,
  27. MS_decode_error = 0x0004,
  28. MS_error_flags = 0x000f,
  29. MS_playing = 0x0100,
  30. MS_cvt_decoded = 0x0200,
  31. };
  32. typedef struct {
  33. SDL_RWops *rw;
  34. void *resampler[2]; /* SDLPAL: Avoid to use SDL's stupid resampler */
  35. struct mad_stream stream;
  36. struct mad_frame frame;
  37. struct mad_synth synth;
  38. int frames_read;
  39. mad_timer_t next_frame_start;
  40. int status;
  41. int output_begin, output_end;
  42. int upsample; /* SDLPAL: Is upsample or downsample */
  43. int resampler_quality; /* SDLPAL:resampler quality */
  44. SDL_AudioSpec mixer;
  45. void (*converter)(signed short *, int);
  46. unsigned char input_buffer[MAD_INPUT_BUFFER_SIZE + MAD_BUFFER_GUARD];
  47. unsigned char output_buffer[MAD_OUTPUT_BUFFER_SIZE];
  48. } mad_data;
  49. mad_data *mad_openFile(const char *filename, SDL_AudioSpec *mixer, int resampler_quality);
  50. mad_data *mad_openFileRW(SDL_RWops *rw, SDL_AudioSpec *mixer, int resampler_quality);
  51. void mad_closeFile(mad_data *mp3_mad);
  52. void mad_start(mad_data *mp3_mad);
  53. void mad_stop(mad_data *mp3_mad);
  54. int mad_isPlaying(mad_data *mp3_mad);
  55. void mad_getSamples(mad_data *mp3_mad, Uint8 *stream, int len);
  56. void mad_seek(mad_data *mp3_mad, double position);