mirror of
https://github.com/QB64Official/qb64.git
synced 2024-09-28 11:17:47 +00:00
Mimic QB45 behavior - Sound() frequency 20KHz or above produces silence
This commit is contained in:
parent
79040102b3
commit
629b9b9c80
1 changed files with 15 additions and 2 deletions
|
@ -692,9 +692,22 @@ static ma_uint8 *GenerateWaveform(double frequency, double length, double volume
|
||||||
samplesi = 1;
|
samplesi = 1;
|
||||||
|
|
||||||
*soundwave_bytes = samplesi * SAMPLE_FRAME_SIZE(ma_int16, 2);
|
*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)
|
if (!data)
|
||||||
return nullptr;
|
return nullptr;
|
||||||
|
|
||||||
sp = (ma_int16 *)data;
|
sp = (ma_int16 *)data;
|
||||||
|
|
||||||
direction = 1;
|
direction = 1;
|
||||||
|
@ -744,7 +757,7 @@ static ma_uint8 *GenerateWaveform(double frequency, double length, double volume
|
||||||
if (waveend)
|
if (waveend)
|
||||||
*soundwave_bytes = waveend * SAMPLE_FRAME_SIZE(ma_int16, 2);
|
*soundwave_bytes = waveend * SAMPLE_FRAME_SIZE(ma_int16, 2);
|
||||||
|
|
||||||
return (ma_uint8 *)data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
Loading…
Reference in a new issue