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;
|
||||
|
||||
*soundwave_bytes = samplesi * SAMPLE_FRAME_SIZE(ma_int16, 2);
|
||||
|
||||
// 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>
|
||||
|
|
Loading…
Reference in a new issue