playwave.c
author Sam Lantinga <slouken@libsdl.org>
Thu, 01 Mar 2018 09:34:14 -0800
changeset 848 3907db698eb5
parent 817 aef7a1784ffd
child 926 d6c9518fb5ee
permissions -rw-r--r--
Updated copyright for 2018
slouken@0
     1
/*
slouken@518
     2
  PLAYWAVE:  A test application for the SDL mixer library.
slouken@848
     3
  Copyright (C) 1997-2018 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@0
    24
#include <stdlib.h>
slouken@0
    25
#include <stdio.h>
slouken@0
    26
#include <string.h>
slouken@488
    27
slouken@47
    28
#ifdef unix
slouken@0
    29
#include <unistd.h>
slouken@0
    30
#endif
slouken@0
    31
slouken@24
    32
#include "SDL.h"
slouken@34
    33
#include "SDL_mixer.h"
slouken@0
    34
slouken@503
    35
#ifdef HAVE_SIGNAL_H
slouken@503
    36
#include <signal.h>
slouken@503
    37
#endif
slouken@503
    38
slouken@0
    39
slouken@113
    40
/*
slouken@113
    41
 * rcg06132001 various mixer tests. Define the ones you want.
slouken@113
    42
 */
icculus@391
    43
/*#define TEST_MIX_DECODERS*/
slouken@127
    44
/*#define TEST_MIX_VERSIONS*/
slouken@127
    45
/*#define TEST_MIX_CHANNELFINISHED*/
slouken@113
    46
/*#define TEST_MIX_PANNING*/
slouken@113
    47
/*#define TEST_MIX_DISTANCE*/
slouken@127
    48
/*#define TEST_MIX_POSITION*/
slouken@113
    49
slouken@113
    50
slouken@113
    51
#if (defined TEST_MIX_POSITION)
slouken@113
    52
slouken@113
    53
#if (defined TEST_MIX_PANNING)
slouken@113
    54
#error TEST_MIX_POSITION interferes with TEST_MIX_PANNING.
slouken@113
    55
#endif
slouken@113
    56
slouken@113
    57
#if (defined TEST_MIX_DISTANCE)
slouken@113
    58
#error TEST_MIX_POSITION interferes with TEST_MIX_DISTANCE.
slouken@113
    59
#endif
slouken@113
    60
slouken@113
    61
#endif
slouken@113
    62
slouken@113
    63
slouken@113
    64
/* rcg06192001 for debugging purposes. */
slouken@113
    65
static void output_test_warnings(void)
slouken@113
    66
{
slouken@113
    67
#if (defined TEST_MIX_CHANNELFINISHED)
slouken@777
    68
    SDL_Log("Warning: TEST_MIX_CHANNELFINISHED is enabled in this binary...\n");
slouken@113
    69
#endif
slouken@113
    70
#if (defined TEST_MIX_PANNING)
slouken@777
    71
    SDL_Log("Warning: TEST_MIX_PANNING is enabled in this binary...\n");
slouken@113
    72
#endif
slouken@113
    73
#if (defined TEST_MIX_VERSIONS)
slouken@777
    74
    SDL_Log("Warning: TEST_MIX_VERSIONS is enabled in this binary...\n");
slouken@113
    75
#endif
slouken@113
    76
#if (defined TEST_MIX_DISTANCE)
slouken@777
    77
    SDL_Log("Warning: TEST_MIX_DISTANCE is enabled in this binary...\n");
slouken@113
    78
#endif
slouken@113
    79
#if (defined TEST_MIX_POSITION)
slouken@777
    80
    SDL_Log("Warning: TEST_MIX_POSITION is enabled in this binary...\n");
slouken@113
    81
#endif
slouken@113
    82
}
slouken@113
    83
slouken@113
    84
slouken@0
    85
static int audio_open = 0;
slouken@0
    86
static Mix_Chunk *wave = NULL;
slouken@0
    87
icculus@390
    88
/* rcg06042009 Report available decoders. */
icculus@390
    89
#if (defined TEST_MIX_DECODERS)
icculus@390
    90
static void report_decoders(void)
icculus@390
    91
{
slouken@617
    92
    int i, total;
icculus@390
    93
slouken@777
    94
    SDL_Log("Supported decoders...\n");
slouken@617
    95
    total = Mix_GetNumChunkDecoders();
slouken@617
    96
    for (i = 0; i < total; i++) {
slouken@777
    97
        SDL_Log(" - chunk decoder: %s\n", Mix_GetChunkDecoder(i));
slouken@617
    98
    }
icculus@390
    99
slouken@617
   100
    total = Mix_GetNumMusicDecoders();
slouken@617
   101
    for (i = 0; i < total; i++) {
slouken@777
   102
        SDL_Log(" - music decoder: %s\n", Mix_GetMusicDecoder(i));
slouken@617
   103
    }
icculus@390
   104
}
icculus@390
   105
#endif
slouken@113
   106
slouken@113
   107
/* rcg06192001 Check new Mixer version API. */
slouken@113
   108
#if (defined TEST_MIX_VERSIONS)
slouken@113
   109
static void output_versions(const char *libname, const SDL_version *compiled,
slouken@617
   110
                            const SDL_version *linked)
slouken@113
   111
{
slouken@777
   112
    SDL_Log("This program was compiled against %s %d.%d.%d,\n"
slouken@617
   113
            " and is dynamically linked to %d.%d.%d.\n", libname,
slouken@617
   114
            compiled->major, compiled->minor, compiled->patch,
slouken@617
   115
            linked->major, linked->minor, linked->patch);
slouken@113
   116
}
slouken@113
   117
slouken@113
   118
static void test_versions(void)
slouken@113
   119
{
slouken@617
   120
    SDL_version compiled;
slouken@617
   121
    const SDL_version *linked;
slouken@113
   122
slouken@617
   123
    SDL_VERSION(&compiled);
slouken@617
   124
    linked = SDL_Linked_Version();
slouken@617
   125
    output_versions("SDL", &compiled, linked);
slouken@113
   126
slouken@617
   127
    SDL_MIXER_VERSION(&compiled);
slouken@617
   128
    linked = Mix_Linked_Version();
slouken@617
   129
    output_versions("SDL_mixer", &compiled, linked);
slouken@113
   130
}
slouken@113
   131
#endif
slouken@113
   132
slouken@113
   133
slouken@113
   134
#ifdef TEST_MIX_CHANNELFINISHED  /* rcg06072001 */
slouken@113
   135
static volatile int channel_is_done = 0;
sezero@817
   136
static void SDLCALL channel_complete_callback (int chan)
slouken@113
   137
{
slouken@617
   138
    Mix_Chunk *done_chunk = Mix_GetChunk(chan);
slouken@777
   139
    SDL_Log("We were just alerted that Mixer channel #%d is done.\n", chan);
slouken@777
   140
    SDL_Log("Channel's chunk pointer is (%p).\n", done_chunk);
slouken@777
   141
    SDL_Log(" Which %s correct.\n", (wave == done_chunk) ? "is" : "is NOT");
slouken@617
   142
    channel_is_done = 1;
slouken@113
   143
}
slouken@113
   144
#endif
slouken@113
   145
slouken@113
   146
slouken@113
   147
/* rcg06192001 abstract this out for testing purposes. */
slouken@113
   148
static int still_playing(void)
slouken@113
   149
{
slouken@113
   150
#ifdef TEST_MIX_CHANNELFINISHED
slouken@617
   151
    return(!channel_is_done);
slouken@113
   152
#else
slouken@617
   153
    return(Mix_Playing(0));
slouken@113
   154
#endif
slouken@113
   155
}
slouken@113
   156
slouken@113
   157
slouken@113
   158
#if (defined TEST_MIX_PANNING)
slouken@113
   159
static void do_panning_update(void)
slouken@113
   160
{
slouken@617
   161
    static Uint8 leftvol = 128;
slouken@617
   162
    static Uint8 rightvol = 128;
slouken@617
   163
    static Uint8 leftincr = -1;
slouken@617
   164
    static Uint8 rightincr = 1;
slouken@617
   165
    static int panningok = 1;
slouken@617
   166
    static Uint32 next_panning_update = 0;
slouken@113
   167
slouken@617
   168
    if ((panningok) && (SDL_GetTicks() >= next_panning_update)) {
slouken@617
   169
        panningok = Mix_SetPanning(0, leftvol, rightvol);
slouken@617
   170
        if (!panningok) {
slouken@777
   171
            SDL_Log("Mix_SetPanning(0, %d, %d) failed!\n",
slouken@617
   172
                    (int) leftvol, (int) rightvol);
slouken@777
   173
            SDL_Log("Reason: [%s].\n", Mix_GetError());
slouken@617
   174
        }
slouken@113
   175
slouken@617
   176
        if ((leftvol == 255) || (leftvol == 0)) {
slouken@617
   177
            if (leftvol == 255)
slouken@777
   178
                SDL_Log("All the way in the left speaker.\n");
slouken@617
   179
                leftincr *= -1;
slouken@617
   180
        }
slouken@113
   181
slouken@617
   182
        if ((rightvol == 255) || (rightvol == 0)) {
slouken@617
   183
            if (rightvol == 255)
slouken@777
   184
                SDL_Log("All the way in the right speaker.\n");
slouken@617
   185
            rightincr *= -1;
slouken@617
   186
        }
slouken@113
   187
slouken@617
   188
        leftvol += leftincr;
slouken@617
   189
        rightvol += rightincr;
slouken@617
   190
        next_panning_update = SDL_GetTicks() + 10;
slouken@617
   191
    }
slouken@113
   192
}
slouken@113
   193
#endif
slouken@113
   194
slouken@113
   195
slouken@113
   196
#if (defined TEST_MIX_DISTANCE)
slouken@113
   197
static void do_distance_update(void)
slouken@113
   198
{
slouken@617
   199
    static Uint8 distance = 1;
slouken@617
   200
    static Uint8 distincr = 1;
slouken@617
   201
    static int distanceok = 1;
slouken@617
   202
    static Uint32 next_distance_update = 0;
slouken@113
   203
slouken@617
   204
    if ((distanceok) && (SDL_GetTicks() >= next_distance_update)) {
slouken@617
   205
        distanceok = Mix_SetDistance(0, distance);
slouken@617
   206
        if (!distanceok) {
slouken@777
   207
            SDL_Log("Mix_SetDistance(0, %d) failed!\n", (int) distance);
slouken@777
   208
            SDL_Log("Reason: [%s].\n", Mix_GetError());
slouken@617
   209
        }
slouken@113
   210
slouken@617
   211
        if (distance == 0) {
slouken@777
   212
            SDL_Log("Distance at nearest point.\n");
slouken@617
   213
            distincr *= -1;
slouken@617
   214
        }
slouken@617
   215
        else if (distance == 255) {
slouken@777
   216
            SDL_Log("Distance at furthest point.\n");
slouken@617
   217
            distincr *= -1;
slouken@617
   218
        }
slouken@113
   219
slouken@617
   220
        distance += distincr;
slouken@617
   221
        next_distance_update = SDL_GetTicks() + 15;
slouken@617
   222
    }
slouken@113
   223
}
slouken@113
   224
#endif
slouken@113
   225
slouken@113
   226
slouken@113
   227
#if (defined TEST_MIX_POSITION)
slouken@113
   228
static void do_position_update(void)
slouken@113
   229
{
slouken@617
   230
    static Sint16 distance = 1;
slouken@617
   231
    static Sint8 distincr = 1;
slouken@617
   232
    static Uint16 angle = 0;
slouken@617
   233
    static Sint8 angleincr = 1;
slouken@617
   234
    static int positionok = 1;
slouken@617
   235
    static Uint32 next_position_update = 0;
slouken@113
   236
slouken@617
   237
    if ((positionok) && (SDL_GetTicks() >= next_position_update)) {
slouken@617
   238
        positionok = Mix_SetPosition(0, angle, distance);
slouken@617
   239
        if (!positionok) {
slouken@777
   240
            SDL_Log("Mix_SetPosition(0, %d, %d) failed!\n",
slouken@617
   241
                    (int) angle, (int) distance);
slouken@777
   242
            SDL_Log("Reason: [%s].\n", Mix_GetError());
slouken@617
   243
        }
slouken@113
   244
slouken@617
   245
        if (angle == 0) {
slouken@777
   246
            SDL_Log("Due north; now rotating clockwise...\n");
slouken@617
   247
            angleincr = 1;
slouken@617
   248
        }
slouken@113
   249
slouken@617
   250
        else if (angle == 360) {
slouken@777
   251
            SDL_Log("Due north; now rotating counter-clockwise...\n");
slouken@617
   252
            angleincr = -1;
slouken@617
   253
        }
slouken@113
   254
slouken@617
   255
        distance += distincr;
slouken@113
   256
slouken@617
   257
        if (distance < 0) {
slouken@617
   258
            distance = 0;
slouken@617
   259
            distincr = 3;
slouken@777
   260
            SDL_Log("Distance is very, very near. Stepping away by threes...\n");
slouken@617
   261
        } else if (distance > 255) {
slouken@617
   262
            distance = 255;
slouken@617
   263
            distincr = -3;
slouken@777
   264
            SDL_Log("Distance is very, very far. Stepping towards by threes...\n");
slouken@617
   265
        }
slouken@113
   266
slouken@617
   267
        angle += angleincr;
slouken@617
   268
        next_position_update = SDL_GetTicks() + 30;
slouken@617
   269
    }
slouken@113
   270
}
slouken@113
   271
#endif
slouken@113
   272
slouken@113
   273
slouken@321
   274
static void CleanUp(int exitcode)
slouken@0
   275
{
slouken@777
   276
    if (wave) {
slouken@617
   277
        Mix_FreeChunk(wave);
slouken@617
   278
        wave = NULL;
slouken@617
   279
    }
slouken@777
   280
    if (audio_open) {
slouken@617
   281
        Mix_CloseAudio();
slouken@617
   282
        audio_open = 0;
slouken@617
   283
    }
slouken@617
   284
    SDL_Quit();
slouken@321
   285
slouken@617
   286
    exit(exitcode);
slouken@0
   287
}
slouken@0
   288
slouken@113
   289
slouken@113
   290
static void Usage(char *argv0)
slouken@0
   291
{
slouken@802
   292
    SDL_Log("Usage: %s [-8] [-f32] [-r rate] [-c channels] [-f] [-F] [-l] [-m] <wavefile>\n", argv0);
slouken@0
   293
}
slouken@92
   294
slouken@92
   295
slouken@113
   296
/*
slouken@113
   297
 * rcg06182001 This is sick, but cool.
slouken@113
   298
 *
slouken@113
   299
 *  Actually, it's meant to be an example of how to manipulate a voice
slouken@113
   300
 *  without having to use the mixer effects API. This is more processing
slouken@113
   301
 *  up front, but no extra during the mixing process. Also, in a case like
slouken@113
   302
 *  this, when you need to touch the whole sample at once, it's the only
slouken@113
   303
 *  option you've got. And, with the effects API, you are altering a copy of
slouken@113
   304
 *  the original sample for each playback, and thus, your changes aren't
slouken@113
   305
 *  permanent; here, you've got a reversed sample, and that's that until
slouken@113
   306
 *  you either reverse it again, or reload it.
slouken@113
   307
 */
slouken@113
   308
static void flip_sample(Mix_Chunk *wave)
slouken@92
   309
{
slouken@617
   310
    Uint16 format;
slouken@617
   311
    int channels, i, incr;
slouken@617
   312
    Uint8 *start = wave->abuf;
slouken@617
   313
    Uint8 *end = wave->abuf + wave->alen;
slouken@113
   314
slouken@617
   315
    Mix_QuerySpec(NULL, &format, &channels);
slouken@617
   316
    incr = (format & 0xFF) * channels;
slouken@113
   317
slouken@617
   318
    end -= incr;
slouken@113
   319
slouken@617
   320
    switch (incr) {
slouken@617
   321
        case 8:
slouken@617
   322
            for (i = wave->alen / 2; i >= 0; i -= 1) {
slouken@617
   323
                Uint8 tmp = *start;
slouken@617
   324
                *start = *end;
slouken@617
   325
                *end = tmp;
slouken@617
   326
                start++;
slouken@617
   327
                end--;
slouken@617
   328
            }
slouken@617
   329
            break;
slouken@113
   330
slouken@617
   331
        case 16:
slouken@617
   332
            for (i = wave->alen / 2; i >= 0; i -= 2) {
slouken@617
   333
                Uint16 tmp = *start;
slouken@617
   334
                *((Uint16 *) start) = *((Uint16 *) end);
slouken@617
   335
                *((Uint16 *) end) = tmp;
slouken@617
   336
                start += 2;
slouken@617
   337
                end -= 2;
slouken@617
   338
            }
slouken@617
   339
            break;
slouken@113
   340
slouken@617
   341
        case 32:
slouken@617
   342
            for (i = wave->alen / 2; i >= 0; i -= 4) {
slouken@617
   343
                Uint32 tmp = *start;
slouken@617
   344
                *((Uint32 *) start) = *((Uint32 *) end);
slouken@617
   345
                *((Uint32 *) end) = tmp;
slouken@617
   346
                start += 4;
slouken@617
   347
                end -= 4;
slouken@617
   348
            }
slouken@617
   349
            break;
slouken@113
   350
slouken@617
   351
        default:
slouken@777
   352
            SDL_Log("Unhandled format in sample flipping.\n");
slouken@617
   353
            return;
slouken@617
   354
    }
slouken@92
   355
}
slouken@92
   356
slouken@92
   357
slouken@113
   358
int main(int argc, char *argv[])
slouken@0
   359
{
slouken@617
   360
    int audio_rate;
slouken@617
   361
    Uint16 audio_format;
slouken@617
   362
    int audio_channels;
slouken@617
   363
    int loops = 0;
slouken@617
   364
    int i;
slouken@617
   365
    int reverse_stereo = 0;
slouken@617
   366
    int reverse_sample = 0;
slouken@113
   367
slouken@488
   368
#ifdef HAVE_SETBUF
slouken@617
   369
    setbuf(stdout, NULL);    /* rcg06132001 for debugging purposes. */
slouken@617
   370
    setbuf(stderr, NULL);    /* rcg06192001 for debugging purposes, too. */
slouken@488
   371
#endif
slouken@617
   372
    output_test_warnings();
slouken@0
   373
slouken@617
   374
    /* Initialize variables */
slouken@617
   375
    audio_rate = MIX_DEFAULT_FREQUENCY;
slouken@617
   376
    audio_format = MIX_DEFAULT_FORMAT;
slouken@617
   377
    audio_channels = 2;
slouken@0
   378
slouken@617
   379
    /* Check command line usage */
slouken@777
   380
    for (i=1; argv[i] && (*argv[i] == '-'); ++i) {
slouken@777
   381
        if ((strcmp(argv[i], "-r") == 0) && argv[i+1]) {
slouken@617
   382
            ++i;
slouken@617
   383
            audio_rate = atoi(argv[i]);
slouken@617
   384
        } else
slouken@777
   385
        if (strcmp(argv[i], "-m") == 0) {
slouken@617
   386
            audio_channels = 1;
slouken@617
   387
        } else
slouken@777
   388
        if ((strcmp(argv[i], "-c") == 0) && argv[i+1]) {
slouken@617
   389
            ++i;
slouken@617
   390
            audio_channels = atoi(argv[i]);
slouken@617
   391
        } else
slouken@777
   392
        if (strcmp(argv[i], "-l") == 0) {
slouken@617
   393
            loops = -1;
slouken@617
   394
        } else
slouken@777
   395
        if (strcmp(argv[i], "-8") == 0) {
slouken@617
   396
            audio_format = AUDIO_U8;
slouken@617
   397
        } else
slouken@777
   398
        if (strcmp(argv[i], "-f32") == 0) {
slouken@732
   399
            audio_format = AUDIO_F32;
slouken@732
   400
        } else
slouken@777
   401
        if (strcmp(argv[i], "-f") == 0) { /* rcg06122001 flip stereo */
slouken@617
   402
            reverse_stereo = 1;
slouken@617
   403
        } else
slouken@777
   404
        if (strcmp(argv[i], "-F") == 0) { /* rcg06172001 flip sample */
slouken@617
   405
            reverse_sample = 1;
slouken@617
   406
        } else {
slouken@617
   407
            Usage(argv[0]);
slouken@617
   408
            return(1);
slouken@617
   409
        }
slouken@617
   410
    }
slouken@777
   411
    if (! argv[i]) {
slouken@617
   412
        Usage(argv[0]);
slouken@617
   413
        return(1);
slouken@617
   414
    }
slouken@0
   415
slouken@617
   416
    /* Initialize the SDL library */
slouken@777
   417
    if (SDL_Init(SDL_INIT_AUDIO) < 0) {
slouken@777
   418
        SDL_Log("Couldn't initialize SDL: %s\n",SDL_GetError());
slouken@617
   419
        return(255);
slouken@617
   420
    }
slouken@488
   421
#ifdef HAVE_SIGNAL_H
slouken@617
   422
    signal(SIGINT, CleanUp);
slouken@617
   423
    signal(SIGTERM, CleanUp);
slouken@488
   424
#endif
slouken@0
   425
slouken@617
   426
    /* Open the audio device */
slouken@617
   427
    if (Mix_OpenAudio(audio_rate, audio_format, audio_channels, 4096) < 0) {
slouken@777
   428
        SDL_Log("Couldn't open audio: %s\n", SDL_GetError());
slouken@617
   429
        CleanUp(2);
slouken@617
   430
    } else {
slouken@617
   431
        Mix_QuerySpec(&audio_rate, &audio_format, &audio_channels);
slouken@802
   432
        SDL_Log("Opened audio at %d Hz %d bit%s %s", audio_rate,
slouken@617
   433
            (audio_format&0xFF),
slouken@802
   434
            (SDL_AUDIO_ISFLOAT(audio_format) ? " (float)" : ""),
slouken@617
   435
            (audio_channels > 2) ? "surround" :
slouken@617
   436
            (audio_channels > 1) ? "stereo" : "mono");
slouken@777
   437
        if (loops) {
slouken@777
   438
          SDL_Log(" (looping)\n");
slouken@617
   439
        } else {
slouken@617
   440
          putchar('\n');
slouken@617
   441
        }
slouken@617
   442
    }
slouken@617
   443
    audio_open = 1;
slouken@0
   444
slouken@113
   445
#if (defined TEST_MIX_VERSIONS)
slouken@617
   446
    test_versions();
slouken@113
   447
#endif
slouken@113
   448
icculus@390
   449
#if (defined TEST_MIX_DECODERS)
slouken@617
   450
    report_decoders();
icculus@390
   451
#endif
icculus@390
   452
slouken@617
   453
    /* Load the requested wave file */
slouken@617
   454
    wave = Mix_LoadWAV(argv[i]);
slouken@777
   455
    if (wave == NULL) {
slouken@777
   456
        SDL_Log("Couldn't load %s: %s\n",
slouken@617
   457
                        argv[i], SDL_GetError());
slouken@617
   458
        CleanUp(2);
slouken@617
   459
    }
slouken@0
   460
slouken@617
   461
    if (reverse_sample) {
slouken@617
   462
        flip_sample(wave);
slouken@617
   463
    }
slouken@113
   464
slouken@92
   465
#ifdef TEST_MIX_CHANNELFINISHED  /* rcg06072001 */
slouken@617
   466
    Mix_ChannelFinished(channel_complete_callback);
slouken@92
   467
#endif
slouken@92
   468
slouken@777
   469
    if ((!Mix_SetReverseStereo(MIX_CHANNEL_POST, reverse_stereo)) &&
slouken@777
   470
         (reverse_stereo))
slouken@617
   471
    {
slouken@777
   472
        SDL_Log("Failed to set up reverse stereo effect!\n");
slouken@777
   473
        SDL_Log("Reason: [%s].\n", Mix_GetError());
slouken@617
   474
    }
slouken@113
   475
slouken@617
   476
    /* Play and then exit */
slouken@617
   477
    Mix_PlayChannel(0, wave, loops);
slouken@92
   478
slouken@617
   479
    while (still_playing()) {
slouken@113
   480
slouken@113
   481
#if (defined TEST_MIX_PANNING)  /* rcg06132001 */
slouken@617
   482
        do_panning_update();
slouken@92
   483
#endif
slouken@92
   484
slouken@113
   485
#if (defined TEST_MIX_DISTANCE) /* rcg06192001 */
slouken@617
   486
        do_distance_update();
slouken@113
   487
#endif
slouken@113
   488
slouken@113
   489
#if (defined TEST_MIX_POSITION) /* rcg06202001 */
slouken@617
   490
        do_position_update();
slouken@113
   491
#endif
slouken@113
   492
slouken@617
   493
        SDL_Delay(1);
slouken@113
   494
slouken@617
   495
    } /* while still_playing() loop... */
slouken@113
   496
slouken@617
   497
    CleanUp(0);
slouken@321
   498
slouken@617
   499
    /* Not reached, but fixes compiler warnings */
slouken@617
   500
    return 0;
slouken@0
   501
}
slouken@113
   502
slouken@113
   503
/* end of playwave.c ... */
slouken@113
   504
slouken@777
   505
/* vi: set ts=4 sw=4 expandtab: */