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