* Fix bad names in the PCM sound header. Audio now works well :)

This commit is contained in:
iProgramInCpp
2023-07-31 15:15:20 +03:00
parent a9e1c09bbe
commit ea16d96a4c
2 changed files with 4 additions and 11 deletions

View File

@@ -105,12 +105,6 @@ void SoundSystemWindows::playAt(const SoundDesc& sound, float x, float y, float
}
}
if (sound.m_pHeader->m_id == 1) //for some reason if the id is 1 you need to pitch the sound down
{
pitch /= 2.f;
}
HRESULT result;
IDirectSoundBuffer* tempBuffer;
unsigned char* bufferPtr;
@@ -123,8 +117,8 @@ void SoundSystemWindows::playAt(const SoundDesc& sound, float x, float y, float
WAVEFORMATEX waveFormat;
waveFormat.wFormatTag = WAVE_FORMAT_PCM;
waveFormat.nSamplesPerSec = DWORD(float(sound.m_pHeader->m_sample_rate) * pitch);
waveFormat.wBitsPerSample = 16;
waveFormat.nChannels = sound.m_header.m_channels;
waveFormat.wBitsPerSample = 8 * sound.m_pHeader->m_bytes_per_sample;
waveFormat.nChannels = sound.m_pHeader->m_channels;
waveFormat.nBlockAlign = (waveFormat.wBitsPerSample / 8) * waveFormat.nChannels;
waveFormat.nAvgBytesPerSec = waveFormat.nSamplesPerSec * waveFormat.nBlockAlign;
waveFormat.cbSize = 0;
@@ -185,7 +179,6 @@ void SoundSystemWindows::playAt(const SoundDesc& sound, float x, float y, float
return;
}
(*soundbuffer)->Play(0, 0, 0);
m_buffers.push_back(soundbuffer);
}

View File

@@ -12,8 +12,8 @@
struct PCMSoundHeader
{
int m_id;
int m_channels;
int m_bytes_per_sample;
int m_sample_rate;
int m_length;
};
@@ -31,6 +31,6 @@ struct SoundDesc
m_pHeader = &header;
m_header = header;
m_pData = data;
field_4 = header.m_id * header.m_length * header.m_channels;
field_4 = header.m_channels * header.m_length * header.m_bytes_per_sample;
}
};