protected override void SetupWriter(AudioData audio) { var parameters = new GcAdpcmParameters { Progress = Configuration.Progress }; if (Codec == NwCodec.GcAdpcm) { Adpcm = audio.GetFormat <GcAdpcmFormat>(parameters); if (!LoopPointsAreAligned(Adpcm.LoopStart, Configuration.LoopPointAlignment)) { Adpcm = Adpcm.GetCloneBuilder().WithAlignment(Configuration.LoopPointAlignment).Build(); } Parallel.For(0, Adpcm.ChannelCount, i => { GcAdpcmChannelBuilder builder = Adpcm.Channels[i].GetCloneBuilder() .WithSamplesPerSeekTableEntry(SamplesPerSeekTableEntry) .WithLoop(Adpcm.Looping, Adpcm.UnalignedLoopStart, Adpcm.UnalignedLoopEnd); builder.LoopAlignmentMultiple = Configuration.LoopPointAlignment; builder.EnsureLoopContextIsSelfCalculated = Configuration.RecalculateLoopContext; builder.EnsureSeekTableIsSelfCalculated = Configuration.RecalculateSeekTable; Adpcm.Channels[i] = builder.Build(); }); AudioFormat = Adpcm; Tracks = Adpcm.Tracks; } else if (Codec == NwCodec.Pcm16Bit) { Pcm16 = audio.GetFormat <Pcm16Format>(parameters); AudioFormat = Pcm16; Tracks = Pcm16.Tracks; } else if (Codec == NwCodec.Pcm8Bit) { Pcm8 = audio.GetFormat <Pcm8SignedFormat>(parameters); AudioFormat = Pcm8; Tracks = Pcm8.Tracks; } }
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()); }