diff --git a/internal/c/parts/audio/out/audio.cpp b/internal/c/parts/audio/out/audio.cpp index 6430d70b0..b10c77da8 100644 --- a/internal/c/parts/audio/out/audio.cpp +++ b/internal/c/parts/audio/out/audio.cpp @@ -692,9 +692,22 @@ static ma_uint8 *GenerateWaveform(double frequency, double length, double volume samplesi = 1; *soundwave_bytes = samplesi * SAMPLE_FRAME_SIZE(ma_int16, 2); - data = (ma_uint8 *)malloc(*soundwave_bytes); + + // Frequency equal to or above 20000 will produce silence + // This is per QuickBASIC 4.5 behavior + if (frequency < 20000) + { + data = (ma_uint8 *)malloc(*soundwave_bytes); + } + else + { + data = (ma_uint8 *)calloc(*soundwave_bytes, sizeof(ma_uint8)); + return data; + } + if (!data) return nullptr; + sp = (ma_int16 *)data; direction = 1; @@ -744,7 +757,7 @@ static ma_uint8 *GenerateWaveform(double frequency, double length, double volume if (waveend) *soundwave_bytes = waveend * SAMPLE_FRAME_SIZE(ma_int16, 2); - return (ma_uint8 *)data; + return data; } ///