Example #1
0
        protected override void SetupWriter(AudioData audio)
        {
            Adpcm = audio.GetFormat <GcAdpcmFormat>(new GcAdpcmParameters {
                Progress = Configuration.Progress
            });
            int channelSize = GetNextMultiple(MaxBlockSize / ChannelCount - 0x20, 0x20);

            MaxBlockSizeActual = channelSize * ChannelCount;
            int alignment = ByteCountToSampleCount(channelSize);

            if (!LoopPointsAreAligned(Adpcm.LoopStart, alignment))
            {
                Adpcm = Adpcm.GetCloneBuilder().WithAlignment(alignment).Build();
            }

            Parallel.For(0, ChannelCount, i =>
            {
                GcAdpcmChannelBuilder builder = Adpcm.Channels[i].GetCloneBuilder();

                builder.LoopAlignmentMultiple             = alignment;
                builder.EnsureLoopContextIsSelfCalculated = true;
                Adpcm.Channels[i] = builder.Build();
            });

            BlockMap = CreateBlockMap(Adpcm.SampleCount, Adpcm.Looping, Adpcm.LoopStart, Adpcm.ChannelCount, MaxBlockSizeActual);
        }
Example #2
0
        private void WriteSeekBlock(BinaryWriter writer)
        {
            if (Codec != NwCodec.GcAdpcm)
            {
                return;
            }
            writer.WriteUTF8("SEEK");
            writer.Write(SeekBlockSize);

            var table = Adpcm.BuildSeekTable(SeekTableEntryCount, Endianness.LittleEndian);

            writer.Write(table);
        }
Example #3
0
        private void WriteAdpcBlock(BinaryWriter writer)
        {
            if (Codec != NwCodec.GcAdpcm)
            {
                return;
            }
            writer.WriteUTF8("ADPC");
            writer.Write(AdpcBlockSize);

            byte[] table = Adpcm.BuildSeekTable(SeekTableEntryCount, Endianness.BigEndian);

            writer.Write(table);
        }
Example #4
0
        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;
            }
        }