Beispiel #1
0
        private void ParseDreamcast()
        {
            uint sampleTable = ReadUint(0x3C);
            uint sampleCount = ReadUint(sampleTable) + 1;

            for (uint i = 0; i < sampleCount; i++)
            {
                uint        sampleEntryStart = sampleTable + 4 + (i * 0x10);
                AudioSample sample           = new AudioSample();
                uint        info             = ReadUint(sampleEntryStart);
                sample.Location        = info & 0x7FFFFF;
                sample.LowFrequency    = ((info & 0x800000) == 0x800000);
                sample.Compressed      = ((info & 0x1000000) == 0x1000000);
                sample.UnknownFlag2    = ((info & 0x2000000) == 0x2000000);
                sample.LoopStart       = ReadUShort(sampleEntryStart + 4);
                sample.LoopEnd         = ReadUShort(sampleEntryStart + 6);
                sample.LowFrequencyAlt = ReadUint(sampleEntryStart + 8) > 0;
                sample.Size            = ReadUint(sampleEntryStart + 12);
                _samples.Add(sample);
                if (sample.Compressed && (sample.Size >> 1) > sample.LoopEnd)
                {
                    //sample.Size >> 1 is the total sample count on DC
                    //LoopEnd is always <= Sample count. If LoopEnd is > Sample count,
                    //we probably have 32 bit samples meaning we are the PC version
                    Is2018Format = true;
                }
            }
        }
Beispiel #2
0
 public byte[] GetSampleData(AudioSample sample, bool decompress, bool scaleTo32bit)
 {
     byte[] retval = null;
     if (!Is2018Format && sample.Compressed && decompress)
     {
         retval = adpcm2pcm(sample.Location, sample.Size);
     }
     else
     {
         retval = new byte[sample.Size];
         Array.Copy(_data, sample.Location, retval, 0, sample.Size);
     }
     if (scaleTo32bit)
     {
         retval = WavUtil.ChangeBitDepth16to32(retval);
     }
     return(retval);
 }
Beispiel #3
0
        public string PrintSamplesInfo()
        {
            StringBuilder sb = new StringBuilder();

            sb.AppendLine($"{_samples.Count} samples in file.");
            if (Is2018Format)
            {
                sb.AppendLine($"This file is probably from the 2018 port");
            }
            for (int i = 0; i < _samples.Count; i++)
            {
                AudioSample sample = _samples[i];
                sb.Append($"{i + 1}. ");
                sb.Append((sample.Compressed) ? "ADPCM " : "PCM ");
                sb.Append((sample.LowFrequency ? "Flag1=Yes " : "Flag1=No "));
                sb.Append((sample.UnknownFlag2 ? "Flag2=Yes. " : "Flag2=No. "));
                sb.Append($"Offset: {sample.Location.ToString("X")} Len: {sample.Size.ToString("X")} ");
                sb.AppendLine($"Loop Start: {sample.LoopStart} Loop End: {sample.LoopEnd}");
            }
            return(sb.ToString());
        }