Exemple #1
0
        private static HeaderTable GetFullTable(string hcaFileName, string songName)
        {
            HcaInfo info;
            uint    lengthInSamples;
            float   lengthInSeconds;

            using (var fileStream = File.Open(hcaFileName, FileMode.Open, FileAccess.Read)) {
                var decoder = new OneWayHcaDecoder(fileStream);
                info            = decoder.HcaInfo;
                lengthInSamples = decoder.LengthInSamples;
                lengthInSeconds = decoder.LengthInSeconds;
            }
            var cue = new[] {
                new CueTable {
                    CueId               = 0,
                    ReferenceType       = 3,
                    ReferenceIndex      = 0,
                    UserData            = string.Empty,
                    WorkSize            = 0,
                    AisacControlMap     = null,
                    Length              = (uint)(lengthInSeconds * 1000),
                    NumAisacControlMaps = 0,
                    HeaderVisibility    = 1
                }
            };
            var cueName = new[] {
                new CueNameTable {
                    CueIndex = 0,
                    CueName  = songName
                }
            };
            var waveform = new[] {
                new WaveformTable {
                    Id            = 0,
                    EncodeType    = 2, // HCA
                    Streaming     = 0,
                    NumChannels   = (byte)info.ChannelCount,
                    LoopFlag      = 1,
                    SamplingRate  = (ushort)info.SamplingRate,
                    NumSamples    = lengthInSamples,
                    ExtensionData = ushort.MaxValue
                }
            };
            var synth = new[] {
                new SynthTable {
                    Type = 0,
                    VoiceLimitGroupName   = string.Empty,
                    CommandIndex          = ushort.MaxValue,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 },
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ControlWorkArea1      = 0,
                    ControlWorkArea2      = 0,
                    TrackValues           = null,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0
                }
            };
            var command = new[] {
                new CommandTable {
                    Command = new byte[0x0a] {
                        0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
                    }
                },
                new CommandTable {
                    Command = new byte[0x10] {
                        0x00, 0x41, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x03, 0x00, 0x57, 0x02, 0x00, 0x32
                    }
                }
            };
            var track = new[] {
                new TrackTable {
                    EventIndex            = 0,
                    CommandIndex          = ushort.MaxValue,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                }
            };
            var sequence = new[] {
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x00 }, // {0x01, 0x00}
                    CommandIndex          = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 0,
                    ControlWorkArea2 = 0
                }
            };
            var acfReference = new[] {
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "system",
                    Name2 = null,
                    Id    = 0
                },
                new AcfReferenceTable {
                    Name = "bgm",
                    Id   = 3
                }
            };
            var acbGuid = Guid.NewGuid();
            var hcaData = File.ReadAllBytes(hcaFileName);
            var header  = new HeaderTable {
                FileIdentifier = 0,
                Size           = 0,
                Version        = 0x01230100,
                Type           = 0,
                Target         = 0,
                AcfMd5Hash     = new byte[0x10] {
                    0x0e, 0xf7, 0x50, 0x41, 0x55, 0x0d, 0xda, 0xda, 0x89, 0xd0, 0x4e, 0x74, 0xbc, 0x91, 0x32, 0x2c
                },
                CategoryExtension         = 0,
                CueTable                  = cue,
                CueNameTable              = cueName,
                WaveformTable             = waveform,
                AisacTable                = null,
                GraphTable                = null,
                AisacNameTable            = null,
                GlobalAisacReferenceTable = null,
                SynthTable                = synth,
                CommandTable              = command,
                TrackTable                = track,
                SequenceTable             = sequence,
                AisacControlNameTable     = null,
                AutoModulationTable       = null,
                StreamAwbTocWorkOld       = null,
                AwbFile              = hcaData,
                VersionString        = StandardAcbVersionString,
                CueLimitWorkTable    = null,
                NumCueLimitListWorks = 0,
                NumCueLimitNodeWorks = 0,
                AcbGuid              = acbGuid.ToByteArray(),
                StreamAwbHash        = new byte[0x10],
                StreamAwbTocWork_Old = null,
                AcbVolume            = 1f,
                StringValueTable     = null,
                OutsideLinkTable     = null,
                BlockSequenceTable   = null,
                BlockTable           = null,
                Name = songName,
                CharacterEncodingType      = 0,
                EventTable                 = null,
                ActionTrackTable           = null,
                AcfReferenceTable          = acfReference,
                WaveformExtensionDataTable = null,
                BeatSyncInfoTable          = null,
                CuePriorityType            = byte.MaxValue,
                NumCueLimit                = 0,
                PaddingArea                = null,
                StreamAwbTocWork           = null,
                StreamAwbAfs2Header        = null
            };

            return(header);
        }
Exemple #2
0
        private static HeaderTable GetFullTable(string hcaFileName, string songName)
        {
            HcaInfo info;
            uint    lengthInSamples;
            float   lengthInSeconds;

            using (var fileStream = File.Open(hcaFileName, FileMode.Open, FileAccess.Read)) {
                var decoder = new OneWayHcaDecoder(fileStream);
                info            = decoder.HcaInfo;
                lengthInSamples = decoder.LengthInSamples;
                lengthInSeconds = decoder.LengthInSeconds;
            }
            var cue = new[] {
                new CueTable {
                    AisacControlMap     = null,
                    CueId               = 0,
                    HeaderVisibility    = 1,
                    NumAisacControlMaps = 0,
                    ReferenceType       = 3,
                    UserData            = string.Empty,
                    ReferenceIndex      = 0,
                    Worksize            = 0,
                    Length              = (uint)Math.Round(lengthInSeconds * 1000)
                },
                new CueTable {
                    AisacControlMap     = null,
                    CueId               = 1,
                    HeaderVisibility    = 1,
                    NumAisacControlMaps = 0,
                    ReferenceType       = 3,
                    UserData            = string.Empty,
                    ReferenceIndex      = 1,
                    Worksize            = 0,
                    Length              = 0xffffffff
                },
                new CueTable {
                    AisacControlMap     = null,
                    CueId               = 2,
                    HeaderVisibility    = 1,
                    NumAisacControlMaps = 0,
                    ReferenceType       = 3,
                    UserData            = string.Empty,
                    ReferenceIndex      = 2,
                    Worksize            = 0,
                    Length              = 0xffffffff
                }
            };
            var cueName = new[] {
                new CueNameTable {
                    CueName  = songName + "_bgm",
                    CueIndex = 0
                },
                new CueNameTable {
                    CueName  = songName + "_bgm_preview",
                    CueIndex = 1
                },
                new CueNameTable {
                    CueName  = songName + "_bgm_soundcheck",
                    CueIndex = 2
                }
            };
            var waveform = new[] {
                new WaveformTable {
                    MemoryAwbId     = 0,
                    EncodeType      = 2, // HCA
                    Streaming       = 0,
                    NumChannels     = (byte)info.ChannelCount,
                    LoopFlag        = 1,
                    SamplingRate    = (ushort)info.SamplingRate,
                    NumSamples      = lengthInSamples,
                    ExtensionData   = ushort.MaxValue,
                    StreamAwbPortNo = ushort.MaxValue,
                    StreamAwbId     = ushort.MaxValue
                }
            };
            var synth = new[] {
                new SynthTable {
                    VoiceLimitGroupName = string.Empty,
                    Type = 0,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    CommandIndex          = 65535,
                    ControlWorkArea1      = 0,
                    ControlWorkArea2      = 0,
                    LocalAisacs           = null,
                    TrackValues           = null,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 }
                },
                new SynthTable {
                    VoiceLimitGroupName = string.Empty,
                    Type = 0,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    CommandIndex          = 0,
                    ControlWorkArea1      = 1,
                    ControlWorkArea2      = 1,
                    LocalAisacs           = null,
                    TrackValues           = null,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 }
                },
                new SynthTable {
                    VoiceLimitGroupName = string.Empty,
                    Type = 0,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    CommandIndex          = 1,
                    ControlWorkArea1      = 2,
                    ControlWorkArea2      = 2,
                    LocalAisacs           = null,
                    TrackValues           = null,
                    ReferenceItems        = new byte[] { 0x00, 0x01, 0x00, 0x00 }
                }
            };
            var seqCommand = new[] {
                new SeqCommandTable {
                    Command = new byte[29] {
                        0x00, 0x41, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x04, 0x00, 0x00, 0x00, 0x0a, 0x00,
                        0x6f, 0x04, 0x00, 0x00, 0x00, 0x00, 0x00, 0x6f, 0x04, 0x00, 0x03, 0x27, 0x10
                    }
                },
                new SeqCommandTable {
                    Command = new byte[31] {
                        0x00, 0x41, 0x0c, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x09, 0x00,
                        0x6e, 0x01, 0x01, 0x00, 0x57, 0x02, 0x00, 0x23, 0x00, 0x6f, 0x04, 0x00, 0x00, 0x27, 0x10
                    }
                }
            };
            var track = new[] {
                new TrackTable {
                    CommandIndex          = ushort.MaxValue,
                    EventIndex            = 0,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                },
                new TrackTable {
                    CommandIndex          = ushort.MaxValue,
                    EventIndex            = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                },
                new TrackTable {
                    CommandIndex          = ushort.MaxValue,
                    EventIndex            = 2,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    TargetType            = 0,
                    TargetName            = string.Empty,
                    TargetId      = uint.MaxValue,
                    TargetAcbName = string.Empty,
                    Scope         = 0,
                    TargetTrackNo = ushort.MaxValue
                }
            };
            var sequence = new[] {
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x00 },
                    CommandIndex          = 0,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 0,
                    ControlWorkArea2 = 0
                },
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x01 },
                    CommandIndex          = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 1,
                    ControlWorkArea2 = 1
                },
                new SequenceTable {
                    PlaybackRatio         = 100,
                    NumTracks             = 1,
                    TrackIndex            = new byte[] { 0x00, 0x02 },
                    CommandIndex          = 1,
                    LocalAisacs           = null,
                    GlobalAisacStartIndex = ushort.MaxValue,
                    GlobalAisacNumRefs    = 0,
                    ParameterPallet       = ushort.MaxValue,
                    ActionTrackStartIndex = ushort.MaxValue,
                    NumActionTracks       = 0,
                    TrackValues           = null,
                    Type             = 0,
                    ControlWorkArea1 = 2,
                    ControlWorkArea2 = 2
                }
            };
            var stringValue = new[] {
                new StringValueTable {
                    StringValue = "MasterOut"
                },
                new StringValueTable {
                    StringValue = "bus_reverb"
                },
                new StringValueTable {
                    StringValue = "bus_voice_rip"
                },
                new StringValueTable {
                    StringValue = "stage_master"
                },
                new StringValueTable {
                    StringValue = string.Empty
                }
            };
            var acfReference = new[] {
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "master",
                    Name2 = string.Empty,
                    Id    = 1
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "song_option",
                    Name2 = string.Empty,
                    Id    = 4,
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "song_submix",
                    Name2 = string.Empty,
                    Id    = 10
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "MasterOut",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "bus_reverb",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "bus_voice_rip",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = "stage_master",
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 9,
                    Name  = string.Empty,
                    Name2 = string.Empty,
                    Id    = uint.MaxValue
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "bgm_option",
                    Name2 = string.Empty,
                    Id    = 3
                },
                new AcfReferenceTable {
                    Type  = 3,
                    Name  = "bgm_submix",
                    Name2 = string.Empty,
                    Id    = 9
                }
            };
            var synthCommand = new[] {
                new SynthCommandTable {
                    Command = new byte[14] {
                        0x00, 0x24, 0x04, 0x05, 0xdc, 0x01, 0xc8, 0x00, 0x28, 0x04, 0x05, 0xeb, 0x02, 0xc8
                    }
                },
                new SynthCommandTable {
                    Command = new byte[7] {
                        0x00, 0x28, 0x04, 0x05, 0xeb, 0x02, 0xc8
                    }
                }
            };
            var trackEvent = new[] {
                new TrackEventTable {
                    Command = new byte[10] {
                        0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00
                    }
                },
                new TrackEventTable {
                    Command = new byte[27] {
                        0x03, 0xe7, 0x04, 0x00, 0x01, 0x28, 0xe0, 0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x01, 0x07, 0xd1,
                        0x04, 0x00, 0x01, 0x77, 0x00, 0x0f, 0xa0, 0x00, 0x00, 0x00, 0x00
                    }
                },
                new TrackEventTable {
                    Command = new byte[10] {
                        0x07, 0xd0, 0x04, 0x00, 0x02, 0x00, 0x02, 0x00, 0x00, 0x00
                    }
                }
            };
            var hcaData = File.ReadAllBytes(hcaFileName);
            var header  = new HeaderTable {
                FileIdentifier             = 0,
                Size                       = 0,
                Version                    = 0x01290000,
                Type                       = 0,
                Target                     = 0,
                CategoryExtension          = 0,
                NumCueLimitListWorks       = 0,
                NumCueLimitNodeWorks       = 0,
                AcbVolume                  = 1,
                CharacterEncodingType      = 0,
                CuePriorityType            = byte.MaxValue,
                NumCueLimit                = 0,
                VersionString              = StandardAcbVersionString,
                Name                       = songName,
                AcfMd5Hash                 = Guid.NewGuid().ToByteArray(),
                AisacTable                 = null,
                GraphTable                 = null,
                GlobalAisacReferenceTable  = null,
                AisacNameTable             = null,
                AisacControlNameTable      = null,
                AutoModulationTable        = null,
                StreamAwbTocWorkOld        = null,
                CueLimitWorkTable          = null,
                StreamAwbTocWork_Old       = null,
                OutsideLinkTable           = null,
                BlockSequenceTable         = null,
                BlockTable                 = null,
                EventTable                 = null,
                ActionTrackTable           = null,
                WaveformExtensionDataTable = null,
                BeatSyncInfoTable          = null,
                TrackCommandTable          = null,
                SeqParameterPalletTable    = null,
                TrackParameterPalletTable  = null,
                SynthParameterPalletTable  = null,
                PaddingArea                = null,
                StreamAwbTocWork           = null,
                StreamAwbAfs2Header        = null,
                CueTable                   = cue,
                CueNameTable               = cueName,
                WaveformTable              = waveform,
                SynthTable                 = synth,
                SeqCommandTable            = seqCommand,
                TrackTable                 = track,
                SequenceTable              = sequence,
                AwbFile                    = hcaData,
                AcbGuid                    = Guid.NewGuid().ToByteArray(),
                StreamAwbHash              = Guid.Empty.ToByteArray(),
                StringValueTable           = stringValue,
                AcfReferenceTable          = acfReference,
                SynthCommandTable          = synthCommand,
                TrackEventTable            = trackEvent
            };

            return(header);
        }