Skip to content

Loop start/end position may be wrong (slightly off) #4

Description

@segfault-bilibili

Currently it seems to be:

  1. loop start sample offset = loop start block index * 0x400
  2. loop end sample offset = loop end block index * 0x400

The loop header section seems to be interpreted as:

  1. loop start block index: big endian unsigned 32-bit integer
  2. loop end block index: big endian unsigned 32-bit integer
  3. loop cycle count (when it equals to 128 it means infinite): big endian unsigned 16-bit integer
  4. loop r01 (sorry, but I can't understand what "r01" means): big endian unsigned 16-bit integer

However, according to VGAudio:

https://github.com/Thealexbarney/VGAudio/blob/9d8f6ea04c83cccccb3dd7851a631bbd53a8dbbe/src/VGAudio/Codecs/CriHca/HcaInfo.cs#L35

        public int LoopStartSample => LoopStartFrame * 1024 + PreLoopSamples - InsertedSamples;
        public int LoopEndSample => (LoopEndFrame + 1) * 1024 - PostLoopSamples - InsertedSamples;

https://github.com/Thealexbarney/VGAudio/blob/9d8f6ea04c83cccccb3dd7851a631bbd53a8dbbe/src/VGAudio/Containers/Hca/HcaReader.cs#L189

        private static void ReadLoopChunk(BinaryReader reader, HcaStructure structure)
        {
            structure.Hca.Looping = true;
            structure.Hca.LoopStartFrame = reader.ReadInt32();
            structure.Hca.LoopEndFrame = reader.ReadInt32();
            structure.Hca.PreLoopSamples = reader.ReadInt16();
            structure.Hca.PostLoopSamples = reader.ReadInt16();
            structure.Hca.SampleCount = Math.Min(structure.Hca.SampleCount, structure.Hca.LoopEndSample);
        }

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions