wavestream.h
author Sam Lantinga <slouken@libsdl.org>
Tue, 07 Jul 2015 11:43:05 -0700
changeset 709 1ef7c1254ffb
parent 625 1d489d8ec2e0
child 711 f40c5ac95b12
permissions -rw-r--r--
Added support for 'smpl' format loop points in music WAV files
     1 /*
     2   SDL_mixer:  An audio mixer library based on the SDL library
     3   Copyright (C) 1997-2013 Sam Lantinga <slouken@libsdl.org>
     4 
     5   This software is provided 'as-is', without any express or implied
     6   warranty.  In no event will the authors be held liable for any damages
     7   arising from the use of this software.
     8 
     9   Permission is granted to anyone to use this software for any purpose,
    10   including commercial applications, and to alter it and redistribute it
    11   freely, subject to the following restrictions:
    12 
    13   1. The origin of this software must not be misrepresented; you must not
    14      claim that you wrote the original software. If you use this software
    15      in a product, an acknowledgment in the product documentation would be
    16      appreciated but is not required.
    17   2. Altered source versions must be plainly marked as such, and must not be
    18      misrepresented as being the original software.
    19   3. This notice may not be removed or altered from any source distribution.
    20 */
    21 
    22 /* $Id$ */
    23 
    24 /* This file supports streaming WAV files */
    25 
    26 typedef struct {
    27     SDL_bool active;
    28     Uint32 start;
    29     Uint32 stop;
    30     Uint32 initial_play_count;
    31     Uint32 current_play_count;
    32 } WAVLoopPoint;
    33 
    34 typedef struct {
    35     SDL_RWops *src;
    36     SDL_bool freesrc;
    37     SDL_AudioSpec spec;
    38     Sint64 start;
    39     Sint64 stop;
    40     SDL_AudioCVT cvt;
    41     int numloops;
    42     WAVLoopPoint *loops;
    43 } WAVStream;
    44 
    45 /* Initialize the WAVStream player, with the given mixer settings
    46    This function returns 0, or -1 if there was an error.
    47  */
    48 extern int WAVStream_Init(SDL_AudioSpec *mixer);
    49 
    50 /* Unimplemented */
    51 extern void WAVStream_SetVolume(int volume);
    52 
    53 /* Load a WAV stream from an SDL_RWops object */
    54 extern WAVStream *WAVStream_LoadSong_RW(SDL_RWops *src, int freesrc);
    55 
    56 /* Start playback of a given WAV stream */
    57 extern void WAVStream_Start(WAVStream *wave);
    58 
    59 /* Play some of a stream previously started with WAVStream_Start() */
    60 extern int WAVStream_PlaySome(Uint8 *stream, int len);
    61 
    62 /* Stop playback of a stream previously started with WAVStream_Start() */
    63 extern void WAVStream_Stop(void);
    64 
    65 /* Close the given WAV stream */
    66 extern void WAVStream_FreeSong(WAVStream *wave);
    67 
    68 /* Return non-zero if a stream is currently playing */
    69 extern int WAVStream_Active(void);