(PCK): use WaveAudio.WriteRiffHeader.

This commit is contained in:
morkt 2017-01-31 15:36:18 +04:00
parent 8e48c06aaf
commit b92d004b02

View File

@ -156,30 +156,14 @@ namespace GameRes.Formats.Crowd
public override Stream OpenEntry (ArcFile arc, Entry entry) public override Stream OpenEntry (ArcFile arc, Entry entry)
{ {
var input = arc.File.CreateStream (entry.Offset, entry.Size);
var went = entry as PkwEntry; var went = entry as PkwEntry;
if (null == went) if (null == went)
return arc.File.CreateStream (entry.Offset, entry.Size); return input;
var riff = new byte[0x2c]; using (var riff = new MemoryStream (0x2C))
using (var buf = new MemoryStream (riff))
using (var wav = new BinaryWriter (buf))
{ {
wav.Write (0x46464952); // 'RIFF' WaveAudio.WriteRiffHeader (riff, went.Format, went.Size);
uint total_size = went.UnpackedSize - 8; return new PrefixStream (riff.ToArray(), input);
wav.Write (total_size);
wav.Write (0x45564157); // 'WAVE'
wav.Write (0x20746d66); // 'fmt '
wav.Write (0x10);
wav.Write (went.Format.FormatTag);
wav.Write (went.Format.Channels);
wav.Write (went.Format.SamplesPerSecond);
wav.Write (went.Format.AverageBytesPerSecond);
wav.Write (went.Format.BlockAlign);
wav.Write (went.Format.BitsPerSample);
wav.Write (0x61746164); // 'data'
wav.Write (went.Size);
wav.Flush ();
var input = arc.File.CreateStream (entry.Offset, entry.Size);
return new PrefixStream (riff, input);
} }
} }
} }