public bool TryGetArchData(PSB psb, PsbDictionary dic, out IArchData data) { data = null; //if (psb.Platform != PsbSpec.nx) //{ // return false; //} if (dic.Count != 1 || !(dic["archData"] is PsbDictionary archDic)) { return(false); } if (archDic["body"] is PsbDictionary body && body["data"] is PsbResource aData && body["sampleCount"] is PsbNumber sampleCount && archDic["ext"] is PsbString ext && ext.Value == Extensions[0] && archDic["samprate"] is PsbNumber sampRate) { data = new OpusArchData { Data = aData, SampRate = sampRate.IntValue, SampleCount = sampleCount.IntValue }; return(true); } return(false); }
public IArchData ToArchData(byte[] wave, string waveExt, Dictionary <string, object> context = null) { WaveReader reader = new WaveReader(); var data = reader.Read(wave); using MemoryStream oms = new MemoryStream(); NxOpusWriter writer = new NxOpusWriter(); writer.WriteToStream(data, oms, new NxOpusConfiguration()); OpusArchData archData = new OpusArchData { Data = new PsbResource { Data = oms.ToArray() } }; var format = data.GetAllFormats().FirstOrDefault(); if (format != null) { archData.SampleCount = format.SampleCount; archData.SampRate = format.SampleRate; archData.ChannelCount = format.ChannelCount; } return(archData); }