public bool StartSpeech(ushort textNum)
{
if (!SystemVars.Instance.SystemFlags.HasFlag(SystemFlags.AllowSpeech))
return false;
var speechFileNum = (ushort)(_speechConvertTable[textNum >> 12] + (textNum & 0xFFF));
var speechData = _skyDisk.LoadFile(speechFileNum + 50000);
if (speechData == null)
{
// TODO: debug(9, "File %d (speechFile %d from section %d) wasn't found", speechFileNum + 50000, textNum & 0xFFF, textNum >> 12);
return false;
}
var header = ServiceLocator.Platform.ToStructure<DataFileHeader>(speechData, 0);
var speechSize = header.s_tot_size - ServiceLocator.Platform.SizeOf<DataFileHeader>();
var playBuffer = new byte[speechSize];
Array.Copy(speechData, ServiceLocator.Platform.SizeOf<DataFileHeader>(), playBuffer, 0, speechSize);
// Workaround for BASS bug #897775 - some voice-overs are played at
// half speed in 0.0368 (the freeware CD version), in 0.0372 they sound
// just fine.
int rate;
if (_skyDisk.DetermineGameVersion().Version.Minor == 368 && (textNum == 20905 || textNum == 20906))
rate = 22050;
else
rate = 11025;
_mixer.StopID(SoundSpeech);
var stream = new RawStream(AudioFlags.Unsigned, rate, true, new MemoryStream(playBuffer, 0, speechSize));
_ingameSpeech = _mixer.PlayStream(SoundType.Speech, stream, SoundSpeech);
return true;
}