From 7b131442adebacbb03f3e9c85e143aacacb52923 Mon Sep 17 00:00:00 2001 From: morkt Date: Sat, 16 May 2015 00:35:32 +0400 Subject: [PATCH] format ids that require conversion are stored in a static HashSet. --- GameRes/AudioWAV.cs | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/GameRes/AudioWAV.cs b/GameRes/AudioWAV.cs index 127facb3..4ae0b524 100644 --- a/GameRes/AudioWAV.cs +++ b/GameRes/AudioWAV.cs @@ -23,6 +23,7 @@ // IN THE SOFTWARE. // +using System.Collections.Generic; using System.ComponentModel.Composition; using System.IO; using System.Text; @@ -49,11 +50,17 @@ namespace GameRes public override string SourceFormat { get { return "wav"; } } + static readonly HashSet ConversionRequired = new HashSet { + WaveFormatEncoding.Adpcm, // 2 + WaveFormatEncoding.MuLaw, // 7 + WaveFormatEncoding.DviAdpcm, // 0x11 + }; + public WaveInput (Stream file) : base (file) { m_reader = new WaveFileReader (file); var wf = m_reader.WaveFormat; - if (WaveFormatEncoding.Adpcm == wf.Encoding || WaveFormatEncoding.MuLaw == wf.Encoding) // 2 || 7 + if (ConversionRequired.Contains (wf.Encoding)) { var wav = WaveFormatConversionStream.CreatePcmStream (m_reader); wf = wav.WaveFormat;