summaryrefslogtreecommitdiff
path: root/drivers/sound/sound.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/sound/sound.c')
-rw-r--r--drivers/sound/sound.c11
1 files changed, 7 insertions, 4 deletions
diff --git a/drivers/sound/sound.c b/drivers/sound/sound.c
index 4f0ad0d8f0..dd3f9db4f7 100644
--- a/drivers/sound/sound.c
+++ b/drivers/sound/sound.c
@@ -8,7 +8,7 @@
#include <sound.h>
void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
- uint freq)
+ uint freq, uint channels)
{
const unsigned short amplitude = 16000; /* between 1 and 32767 */
const int period = freq ? sample_rate / freq : 0;
@@ -21,14 +21,17 @@ void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
size--;
while (size) {
- int i;
+ int i, j;
+
for (i = 0; size && i < half; i++) {
size -= 2;
- *data++ = amplitude;
+ for (j = 0; j < channels; j++)
+ *data++ = amplitude;
}
for (i = 0; size && i < period - half; i++) {
size -= 2;
- *data++ = -amplitude;
+ for (j = 0; j < channels; j++)
+ *data++ = -amplitude;
}
}
}