X-Git-Url: http://git.harvie.cz/?a=blobdiff_plain;f=c%2Fsampler%2Fc%2Fsdl-old2.c;fp=c%2Fsampler%2Fc%2Fsdl-old2.c;h=0000000000000000000000000000000000000000;hb=51baeaf524489d11b6455a97b2d26b8309b79607;hp=d677ce9371ad7ceac9af8e53397623dc4dea3aef;hpb=2e9749f0922e4c0337845b1d2de733d1ceab3195;p=mirrors%2FPrograms.git diff --git a/c/sampler/c/sdl-old2.c b/c/sampler/c/sdl-old2.c deleted file mode 100644 index d677ce9..0000000 --- a/c/sampler/c/sdl-old2.c +++ /dev/null @@ -1,115 +0,0 @@ -/* play.c - a simple utility to play WAV files (not part of tcpsound) - */ - -#include -#include -#include -//#include -#include -#include - -#define NUM_SOUNDS 5 - -struct sample { - Uint8 *data; - Uint32 dpos; - Uint32 dlen; -} sounds[NUM_SOUNDS]; - -void -mixaudio(void *unused, Uint8 *stream, int len) -{ - int i; - Uint32 amount; - for (i = 0; i < NUM_SOUNDS; i++) { - amount = (sounds[i].dlen-sounds[i].dpos); - if (amount > (Uint32)len) { - amount = len; - } - SDL_MixAudio(stream, &sounds[i].data[sounds[i].dpos], amount, SDL_MIX_MAXVOLUME); - sounds[i].dpos += amount; - } - (void)unused; -} - -void -PlaySound(char *file) -{ - int index; - SDL_AudioSpec wave; - Uint8 *data; - Uint32 dlen; - SDL_AudioCVT cvt; - - /* Look for an empty (or finished) sound slot */ - for ( index=0; index\n", argv[0]); - return EXIT_FAILURE; - } - - /* Set 16-bit stereo audio at 22Khz */ - fmt.freq = 22050; - fmt.format = AUDIO_S16; - fmt.channels = 2; - fmt.samples = 512; /* A good value for games */ - fmt.callback = mixaudio; - fmt.userdata = NULL; - - /* Open the audio device and start playing sound! */ - if (SDL_OpenAudio(&fmt, NULL) < 0) { - printf("Unable to open audio: %s\n", SDL_GetError()); - return EXIT_FAILURE; - } - - SDL_PauseAudio(0); - - for (i = 1; i < argc; i++) { - fprintf(stderr, "%s", argv[i]); - PlaySound(argv[i]); -/* fgetc(stdin); - */ -sleep(2); - } - - SDL_CloseAudio(); - - return EXIT_SUCCESS; -} -