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()); }
protected override IAudioFormat ToAudioStream(HpsStructure structure) { var channels = new GcAdpcmChannel[structure.ChannelCount]; for (int c = 0; c < structure.ChannelCount; c++) { int audioLength = structure.Blocks.Sum(x => x.Channels[c].AudioData.Length); var audio = new byte[audioLength]; int currentPosition = 0; foreach (HpsBlock block in structure.Blocks) { byte[] source = block.Channels[c].AudioData; Array.Copy(source, 0, audio, currentPosition, source.Length); currentPosition += source.Length; } var channelBuilder = new GcAdpcmChannelBuilder(audio, structure.Channels[c].Coefs, structure.Channels[c].SampleCount) { Gain = structure.Channels[c].Gain, StartContext = structure.Channels[c].Start }; channelBuilder.WithLoop(structure.Looping, structure.LoopStart, structure.SampleCount) .WithLoopContext(structure.LoopStart, structure.Channels[c].Loop?.PredScale ?? 0, structure.Channels[c].Loop?.Hist1 ?? 0, structure.Channels[c].Loop?.Hist2 ?? 0); channels[c] = channelBuilder.Build(); } return(new GcAdpcmFormatBuilder(channels, structure.SampleRate) .WithLoop(structure.Looping, structure.LoopStart, structure.SampleCount) .Build()); }
protected override IAudioFormat ToAudioStream(DspStructure structure) { var channels = new GcAdpcmChannel[structure.ChannelCount]; for (int c = 0; c < structure.ChannelCount; c++) { var channelBuilder = new GcAdpcmChannelBuilder(structure.AudioData[c], structure.Channels[c].Coefs, structure.SampleCount) { Gain = structure.Channels[c].Gain, StartContext = structure.Channels[c].Start }; channelBuilder.WithLoop(structure.Looping, structure.LoopStart, structure.LoopEnd) .WithLoopContext(structure.LoopStart, structure.Channels[c].Loop.PredScale, structure.Channels[c].Loop.Hist1, structure.Channels[c].Loop.Hist2); channels[c] = channelBuilder.Build(); } return(new GcAdpcmFormatBuilder(channels, structure.SampleRate) .WithLoop(structure.Looping, structure.LoopStart, structure.LoopEnd) .Build()); }