2 * Copyright (C) 2012 Samsung Electronics
3 * R. Chandrasekar <rcsekar@samsung.com>
5 * SPDX-License-Identifier: GPL-2.0+
11 void sound_create_square_wave(unsigned short *data
, int size
, uint32_t freq
)
13 const int sample
= 48000;
14 const unsigned short amplitude
= 16000; /* between 1 and 32767 */
15 const int period
= freq
? sample
/ freq
: 0;
16 const int half
= period
/ 2;
20 /* Make sure we don't overflow our buffer */
26 for (i
= 0; size
&& i
< half
; i
++) {
31 for (i
= 0; size
&& i
< period
- half
; i
++) {