コード例 #1
0
        static Dictionary <string, List <Tuple <float, string> > > ExtractPlayerIntensities(MidiFile mf)
        {
            var partMap = new Dictionary <string, string> {
                { "PART BASS", "bass_intensity" },
                { "PART GUITAR", "guitar_intensity" },
                { "PART DRUMS", "drum_intensity" },
                { "PART VOCALS", "mic_intensity" },
#if DEBUG
                { "PART KEYS", "keyboard_intensity" },
#endif
            };
            var intensityMap = new Dictionary <string, string>
            {
                // All
                { "[idle_realtime]", "idle_realtime" },
                { "[idle]", "idle" },
                { "[idle_intense]", "idle_intense" },
                { "[play]", "play" },
                { "[mellow]", "mellow" },
                { "[intense]", "intense" },
                // Guitar/bass only
                { "[play_solo]", "play_solo" },
                // Vocal only
                { "[tambourine_start]", "tambourine_start" },
                { "[tambourine_end]", "tambourine_end" },
                { "[cowbell_start]", "cowbell_start" },
                { "[cowbell_end]", "cowbell_end" },
                { "[clap_start]", "clap_start" },
                { "[clap_end]", "clap_end" },
                // Drum only
                { "[ride_side_true]", "ride_side_true" },
                { "[ride_side_false]", "ride_side_false" },
            };
            var ret = new Dictionary <string, List <Tuple <float, string> > >();

            var tracks = new Midi.MidiHelper().ProcessTracks(mf);

            foreach (var track in tracks)
            {
                if (!partMap.ContainsKey(track.Name))
                {
                    continue;
                }
                var frames = new List <Tuple <float, string> >();
                foreach (var n in track.Items)
                {
                    if (n is Midi.MidiText t)
                    {
                        if (intensityMap.ContainsKey(t.Text))
                        {
                            frames.Add(Tuple.Create((float)n.StartTicks / mf.TicksPerQN, intensityMap[t.Text]));
                        }
                    }
                }
                ret[partMap[track.Name]] = frames;
            }
            return(ret);
        }
コード例 #2
0
        static GameObject[] ExtractVenuePropAnimsFromMidi(MidiFile mf)
        {
            var   objs      = new List <GameObject>();
            short index     = 1;
            var   editorCom = new Component
            {
                Rev      = 3,
                Name1    = "Editor",
                Name2    = "Editor",
                Unknown2 = 2,
                Props    = new[] { new Property("capabilities", new UIntValue(62)) }
            };

            objs.Add(new GameObject
            {
                Id = new GameObjectId {
                    Index = 0, Layer = 0
                },
                Rev        = 2,
                Name       = "root",
                Components = new[]
                {
                    editorComponent,
                    entityHeaderComponent,
                    new Component
                    {
                        Rev      = 3,
                        Name1    = "PropAnim",
                        Name2    = "PropAnim",
                        Unknown2 = 0,
                        Props    = StructValue.FromData(
                            StructType.FromData(DTX.FromDtaString(
                                                    @"(props 
                            (frame_range_start float)
                            (frame_range_end float)
                            (time_units int)
                            (is_looping bool))")),
                            DTX.FromDtaString(
                                @"(frame_range_start 3.402823E+38)
                          (frame_range_end -3.402823E+38)
                          (time_units 0)
                          (is_looping 0)")).Props
                    }
                }
            });
            var tracks  = new Midi.MidiHelper().ProcessTracks(mf);
            var partMap = new Dictionary <string, string> {
                { "PART BASS", "bass_intensity" },
                { "PART GUITAR", "guitar_intensity" },
                { "PART DRUMS", "drum_intensity" },
                { "PART VOCALS", "mic_intensity" },
#if DEBUG
                { "PART KEYS", "keyboard_intensity" },
#endif
            };
            var intensityMap = new Dictionary <string, string>
            {
                // All
                { "[idle_realtime]", "idle_realtime" },
                { "[idle]", "idle" },
                { "[idle_intense]", "idle_intense" },
                { "[play]", "play" },
                { "[mellow]", "mellow" },
                { "[intense]", "intense" },
                // Guitar/bass only
                { "[play_solo]", "play_solo" },
                // Vocal only
                { "[tambourine_start]", "tambourine_start" },
                { "[tambourine_end]", "tambourine_end" },
                { "[cowbell_start]", "cowbell_start" },
                { "[cowbell_end]", "cowbell_end" },
                { "[clap_start]", "clap_start" },
                { "[clap_end]", "clap_end" },
                // Drum only
                { "[ride_side_true]", "ride_side_true" },
                { "[ride_side_false]", "ride_side_false" },
            };

            void AddAnimTrack(StructValue props)
            {
                objs.Add(new GameObject
                {
                    Id = new GameObjectId {
                        Index = index, Layer = index++
                    },
                    Rev        = 2,
                    Name       = "Keys type 11",
                    Components = new[]
                    {
                        editorCom,
                        new Component
                        {
                            Rev      = 3,
                            Name1    = "PropKeysSymCom",
                            Name2    = "PropKeys",
                            Unknown2 = 0,
                            Props    = props.Props
                        }
                    }
                });
            }

            StructValue MakeAnimProps(string drivenProp, List <Tuple <float, string> > frames)
            {
                var propkeys = DTX.FromDtaString(
                    "(keys ()) " +
                    "(interpolation 0) " +
                    $"(driven_prop (0 0 RBVenueAuthoring 0 1 {drivenProp}))");
                var keyframes = propkeys.Array("keys").Array(1);

                foreach (var(frame, key) in frames)
                {
                    var keyframe = new DataArray();
                    keyframe.AddNode(new DataAtom(frame));
                    keyframe.AddNode(DataSymbol.Symbol(key));
                    keyframes.AddNode(keyframe);
                }
                return(StructValue.FromData(propKeysType, propkeys));
            }

            foreach (var track in tracks)
            {
                if (!partMap.ContainsKey(track.Name))
                {
                    continue;
                }
                var frames = new List <Tuple <float, string> >();
                foreach (var n in track.Items)
                {
                    if (n is Midi.MidiText t)
                    {
                        if (intensityMap.ContainsKey(t.Text))
                        {
                            frames.Add(Tuple.Create((float)n.StartTicks / mf.TicksPerQN, intensityMap[t.Text]));
                        }
                    }
                }
                AddAnimTrack(MakeAnimProps(partMap[track.Name], frames));
            }
            AddAnimTrack(MakeAnimProps("shot_bg", new List <Tuple <float, string> > {
                Tuple.Create(0f, "coop_all_far")
            }));
            AddAnimTrack(MakeAnimProps("shot_bk", new List <Tuple <float, string> > {
                Tuple.Create(0f, "coop_all_far")
            }));
            AddAnimTrack(MakeAnimProps("shot_gk", new List <Tuple <float, string> > {
                Tuple.Create(0f, "coop_all_far")
            }));
            AddAnimTrack(MakeAnimProps("crowd", new List <Tuple <float, string> > {
                Tuple.Create(0f, "crowd_realtime")
            }));
            AddAnimTrack(MakeAnimProps("world_event", new List <Tuple <float, string> > {
                Tuple.Create(0f, "none")
            }));
            //AddAnimTrack(MakeAnimProps("part2_sing", new List<Tuple<float, string>> {Tuple.Create(0f, "singalong_off") }));
            //AddAnimTrack(MakeAnimProps("part3_sing", new List<Tuple<float, string>> {Tuple.Create(0f, "singalong_off") }));
            //AddAnimTrack(MakeAnimProps("part4_sing", new List<Tuple<float, string>> {Tuple.Create(0f, "singalong_off") }));
            AddAnimTrack(MakeAnimProps("lightpreset", new List <Tuple <float, string> > {
                Tuple.Create(0f, "silhouettes")
            }));
            AddAnimTrack(MakeAnimProps("postproc", new List <Tuple <float, string> > {
                Tuple.Create(0f, "profilm_a")
            }));
            AddAnimTrack(MakeAnimProps("lightpreset_keyframe", new List <Tuple <float, string> > {
                Tuple.Create(0f, "next")
            }));
            AddAnimTrack(MakeAnimProps("spot_bass", new List <Tuple <float, string> > {
                Tuple.Create(0f, "off")
            }));
            AddAnimTrack(MakeAnimProps("spot_guitar", new List <Tuple <float, string> > {
                Tuple.Create(0f, "off")
            }));
            AddAnimTrack(MakeAnimProps("spot_drums", new List <Tuple <float, string> > {
                Tuple.Create(0f, "off")
            }));
            //AddAnimTrack(MakeAnimProps("spot_keyboard", new List<Tuple<float, string>> {Tuple.Create(0f, "off") }));
            AddAnimTrack(MakeAnimProps("spot_vocal", new List <Tuple <float, string> > {
                Tuple.Create(0f, "off")
            }));
            //AddAnimTrack(MakeAnimProps("shot_5", new List<Tuple<float, string>> {Tuple.Create(0f, "coop_all_far") }));
            AddAnimTrack(MakeAnimProps("stagekit_fog", new List <Tuple <float, string> > {
                Tuple.Create(0f, "off")
            }));
            return(objs.ToArray());
        }