private static GcAdpcmFormat ToAdpcmStream(BxstmStructure structure) { StreamInfo streamInfo = structure.StreamInfo; List <GcAdpcmChannelInfo> channelInfo = structure.ChannelInfo.Channels; var channels = new GcAdpcmChannel[streamInfo.ChannelCount]; for (int c = 0; c < channels.Length; c++) { var channelBuilder = new GcAdpcmChannelBuilder(structure.AudioData[c], channelInfo[c].Coefs, streamInfo.SampleCount) { Gain = channelInfo[c].Gain, StartContext = channelInfo[c].Start }; channelBuilder.WithLoop(streamInfo.Looping, streamInfo.LoopStart, streamInfo.SampleCount) .WithLoopContext(streamInfo.LoopStart, channelInfo[c].Loop.PredScale, channelInfo[c].Loop.Hist1, channelInfo[c].Loop.Hist2); if (structure.SeekTable != null) { channelBuilder.WithSeekTable(structure.SeekTable[c], streamInfo.SamplesPerSeekTableEntry); } channels[c] = channelBuilder.Build(); } return(new GcAdpcmFormatBuilder(channels, streamInfo.SampleRate) .WithTracks(structure.TrackInfo?.Tracks) .WithLoop(streamInfo.Looping, streamInfo.LoopStart, streamInfo.SampleCount) .Build()); }
private static Pcm8SignedFormat ToPcm8Stream(BxstmStructure structure) { StreamInfo info = structure.StreamInfo; return(new Pcm8FormatBuilder(structure.AudioData, info.SampleRate, true) .WithTracks(structure.TrackInfo?.Tracks) .WithLoop(info.Looping, info.LoopStart, info.SampleCount) .Build() as Pcm8SignedFormat); }
private static Pcm16Format ToPcm16Stream(BxstmStructure structure) { StreamInfo info = structure.StreamInfo; short[][] channels = structure.AudioData.Select(x => x.ToShortArray(structure.Endianness)).ToArray(); return(new Pcm16FormatBuilder(channels, info.SampleRate) .WithTracks(structure.TrackInfo?.Tracks) .WithLoop(info.Looping, info.LoopStart, info.SampleCount) .Build()); }
public static IAudioFormat ToAudioStream(BxstmStructure structure) { if (structure.PrefetchData != null) { // Read only the first prefetch region for now PrefetchData pdat = structure.PrefetchData[0]; structure.StreamInfo.Looping = false; structure.StreamInfo.SampleCount = pdat.SampleCount; } switch (structure.StreamInfo.Codec) { case NwCodec.GcAdpcm: return(ToAdpcmStream(structure)); case NwCodec.Pcm16Bit: return(ToPcm16Stream(structure)); case NwCodec.Pcm8Bit: return(ToPcm8Stream(structure)); default: return(null); } }