1
1
Fork 0
mirror of https://github.com/QB64Official/qb64.git synced 2024-06-26 11:20:37 +00:00

Mimic QB45 behavior - Sound() frequency 20KHz or above produces silence

This commit is contained in:
Samuel Gomes 2022-08-20 00:11:06 +05:30
parent 79040102b3
commit 629b9b9c80

View file

@ -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;
}
/// <summary>