-
Notifications
You must be signed in to change notification settings - Fork 1
/
snd_allegro.c
72 lines (59 loc) · 1.42 KB
/
snd_allegro.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
/*
* snd_allegro.c
*
* allegro sound interface
*/
/* $Id: snd_allegro.c,v 1.2 1999/10/31 14:43:02 nyef Exp $ */
#include <allegro.h>
#include "ui.h"
#include "snd.h"
AUDIOSTREAM *sound_stream;
void snd_output_4_waves(int samples, u8 *wave1, u8 *wave2, u8 *wave3, u8 *wave4)
{
unsigned char *final_wave;
int i;
if (sound_stream) {
final_wave = NULL;
while (!final_wave) { /* Wheee... Primitive Framesync. :-) */
final_wave = get_audio_stream_buffer(sound_stream);
}
for (i = 0; i < samples; i++) {
final_wave[i] = (wave1[i] + wave2[i] + wave3[i] + wave4[i]) >> 2;
}
free_audio_stream_buffer(sound_stream);
}
}
void snd_init(void)
{
sound_stream = NULL;
}
int snd_open(int samples_per_sync, int sample_rate)
{
if (install_sound(DIGI_AUTODETECT, MIDI_NONE, NULL) != 0) {
deb_printf("Error initializing sound system\n%s\n", allegro_error);
return 0;
} else {
sound_stream = play_audio_stream(samples_per_sync, 8, sample_rate, 255, 128);
if (!sound_stream) {
deb_printf("unable to create audio stream.\n");
return 0;
}
}
return 1;
}
void snd_close(void)
{
if (sound_stream) {
stop_audio_stream(sound_stream);
}
}
/*
* $Log: snd_allegro.c,v $
* Revision 1.2 1999/10/31 14:43:02 nyef
* fixed to compile without warnings
* fixed to only stop the audio stream if we actually had one
*
* Revision 1.1 1999/10/31 02:37:46 nyef
* Initial revision
*
*/