Beispiel #1
0
        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());
        }
Beispiel #2
0
        public static GcAdpcmFormat GenerateAdpcmEmpty(int sampleCount, int channelCount, int sampleRate, int samplesPerSeekTableEntry = 0x3800)
        {
            var channels = new GcAdpcmChannel[channelCount];

            for (int i = 0; i < channelCount; i++)
            {
                var builder = new GcAdpcmChannelBuilder(new byte[GcAdpcmMath.SampleCountToByteCount(sampleCount)], new short[16], sampleCount);
                builder.WithSeekTable(new short[sampleCount.DivideByRoundUp(samplesPerSeekTableEntry) * 2], samplesPerSeekTableEntry, true);
                channels[i] = builder.Build();
            }

            var adpcm = new GcAdpcmFormat(channels, sampleRate);

            return(adpcm);
        }