1 // SPDX-License-Identifier: GPL-2.0+
3 * Copyright (C) 2012 Samsung Electronics
4 * R. Chandrasekar <rcsekar@samsung.com>
11 void sound_create_square_wave(uint sample_rate, unsigned short *data, int size,
12 uint freq, uint channels)
14 const unsigned short amplitude = 16000; /* between 1 and 32767 */
15 const int period = freq ? sample_rate / freq : 0;
16 const int half = period / 2;
19 memset(data, 0, size);
23 /* Make sure we don't overflow our buffer */
30 for (i = 0; size && i < half; i++) {
31 for (j = 0; size && j < channels; j++, size -= 2)
34 for (i = 0; size && i < period - half; i++) {
35 for (j = 0; size && j < channels; j++, size -= 2)