コード例 #1
0
    public static float GetOffset(ChartEditor editor, ChartEvent chartEvent)
    {
        var events = editor.currentChart.events;

        int offset = 0;
        int index, length;

        SongObjectHelper.GetRange(events, chartEvent.tick, chartEvent.tick, out index, out length);

        // Determine the offset for the object
        for (int i = index; i < index + length; ++i)
        {
            if (events[i].GetType() != chartEvent.GetType())
            {
                continue;
            }

            if (events[i] < chartEvent)
            {
                offset += OFFSET_SPACING;
            }
        }

        return(offset);
    }
コード例 #2
0
    protected override void SetSongObjectAndController()
    {
        chartEvent = new ChartEvent(0, "Default");

        controller            = GetComponent <ChartEventController>();
        controller.chartEvent = chartEvent;
    }
コード例 #3
0
        public ActionResult PostEvents(ChartEvent ab, HttpPostedFileBase file2)
        {
            SeatBookerApp.Event ev = ab.Event1;


            if (file2 != null)
            {
                string imageName    = System.IO.Path.GetFileName(file2.FileName);
                string physicalPath = Server.MapPath("~/Content/img/" + imageName);
                file2.SaveAs(physicalPath);
                ev.Image = "Content/img/" + imageName;
            }

            string       selected = Request.Form["ChartList"];
            List <Chart> a        = es.Charts.ToList();
            Chart        found    = a.Find(c => c.Chart_ID == selected);



            ev.Row         = found.Seat_Row;
            ev.Col         = found.Seat_Column;
            ev.Row_Div     = found.Row_Div_No;
            ev.Col_Div     = found.Col_Div_No;
            ev.Chart_Title = found.Chart_ID;

            if (ModelState.IsValid)
            {
                es.Events.Add(ev);
                es.SaveChanges();
            }

            return(Redirect("Index"));
        }
コード例 #4
0
    public static void AddObjectToCurrentChart(ChartEvent chartEvent, ChartEditor editor, bool update = true)
    {
        ChartEvent eventToAdd = new ChartEvent(chartEvent);

        editor.currentChart.Add(eventToAdd, update);
        editor.currentSelectedObject = eventToAdd;
    }
コード例 #5
0
    static void AddChartEvent(ChartEvent chartEvent, IList <BaseAction> subActions)
    {
        ChartEditor editor = ChartEditor.Instance;

        TryRecordOverwrite(chartEvent, editor.currentChart.chartObjects, subActions);

        AddAndInvokeSubAction(new AddAction(chartEvent), subActions);
    }
コード例 #6
0
ファイル: ChartEvent.cs プロジェクト: LesCol/deobfuscateclon
 // Token: 0x060027B9 RID: 10169 RVA: 0x0012E7E4 File Offset: 0x0012C9E4
 protected virtual bool vmethod_10(GClass16 gclass16_0)
 {
     if (gclass16_0.GetType() == typeof(ChartEvent))
     {
         ChartEvent gclass = gclass16_0 as ChartEvent;
         return(this.uint_0 == gclass.uint_0 && this.string_0 == gclass.string_0);
     }
     return(base.vmethod_0(gclass16_0));
 }
コード例 #7
0
        private void PlaybackEventTrigger(ChartEvent evt, PlayDirection direction)
        {
            if (direction == PlayDirection.Forward)
            {
                switch (evt)
                {
                case EffectKindEvent effectKind:
                {
                    var effect = m_currentEffects[effectKind.EffectIndex] = effectKind.Effect;
                    if (effect == null)
                    {
                        m_audioController.RemoveEffect(effectKind.EffectIndex);
                    }
                    else
                    {
                        m_audioController.SetEffect(effectKind.EffectIndex, CurrentQuarterNodeDuration, effect, 1.0f);
                    }
                }
                break;

                case LaserApplicationEvent app: m_highwayControl.LaserApplication = app.Application; break;

                // TODO(local): left/right lasers separate + allow both independent if needed
                case LaserFilterGainEvent filterGain: laserGain = filterGain.Gain; break;

                case LaserFilterKindEvent filterKind:
                {
                    m_audioController.SetEffect(6, CurrentQuarterNodeDuration, currentLaserEffectDef = filterKind.Effect, m_audioController.GetEffectMix(6));
                }
                break;

                case LaserParamsEvent pars:
                {
                    if (pars.LaserIndex.HasFlag(LaserIndex.Left))
                    {
                        m_highwayControl.LeftLaserParams = pars.Params;
                    }
                    if (pars.LaserIndex.HasFlag(LaserIndex.Right))
                    {
                        m_highwayControl.RightLaserParams = pars.Params;
                    }
                }
                break;

                case SlamVolumeEvent pars: m_slamSample.Volume = pars.Volume; break;
                }
            }

            switch (evt)
            {
            case SpinImpulseEvent spin: m_highwayControl.ApplySpin(spin.Params, spin.AbsolutePosition); break;

            case SwingImpulseEvent swing: m_highwayControl.ApplySwing(swing.Params, swing.AbsolutePosition); break;

            case WobbleImpulseEvent wobble: m_highwayControl.ApplyWobble(wobble.Params, wobble.AbsolutePosition); break;
            }
        }
コード例 #8
0
        public ActionResult PostEvents(ChartEvent a)
        {
            a = new ChartEvent
            {
                Event1 = new Event(),
                Chart1 = es.Charts.ToList()
            };

            return(View(a));
        }
コード例 #9
0
    static byte[] GetUnrecognisedChartBytes(Chart chart, ExportOptions exportOptions)
    {
        List <SortableBytes> eventList = new List <SortableBytes>();
        del InsertionSort = (sortableByte) =>
        {
            int index = eventList.Count - 1;

            while (index >= 0 && sortableByte.tick < eventList[index].tick)
            {
                --index;
            }

            eventList.Insert(index + 1, sortableByte);
        };

        foreach (ChartObject chartObject in chart.chartObjects)
        {
            SortableBytes onEvent  = null;
            SortableBytes offEvent = null;

            Note note = chartObject as Note;
            if (note != null)
            {
                GetUnrecognisedChartNoteBytes(note, out onEvent, out offEvent);
            }

            Starpower sp = chartObject as Starpower;
            if (sp != null)     // Starpower cannot be split up between charts in a midi file
            {
                GetStarpowerBytes(sp, out onEvent, out offEvent);
            }

            ChartEvent chartEvent = chartObject as ChartEvent;
            if (chartEvent != null)     // Text events cannot be split up in the file
            {
                SortableBytes bytes = GetChartEventBytes(chartEvent);
                InsertionSort(bytes);
            }

            if (onEvent != null && offEvent != null)
            {
                InsertionSort(onEvent);

                if (offEvent.tick == onEvent.tick)
                {
                    ++offEvent.tick;
                }

                InsertionSort(offEvent);
            }
        }

        return(SortableBytesToTimedEventBytes(eventList.ToArray(), chart.song, exportOptions));
    }
コード例 #10
0
    public void UpdateEventName(string name)
    {
        // Make sure the user isn't editing to create 2 of the same events
        if (currentEvent != null)
        {
            var charsToRemove = new string[] { "\"" };
            foreach (var c in charsToRemove)
            {
                name = name.Replace(c, string.Empty);
            }

            string prevName = currentEvent.title;
            if (SongObjectHelper.FindObjectPosition(new MoonscraperChartEditor.Song.Event(name, currentEvent.tick), editor.currentSong.events) == SongObjectHelper.NOTFOUND)
            {
                bool tentativeRecord, lockedRecord;
                ShouldRecordInputField(name, currentEvent.title, out tentativeRecord, out lockedRecord);

                if (!lockedRecord)
                {
                    editor.commandStack.Pop();
                }

                if (tentativeRecord || lockedRecord)
                {
                    MoonscraperChartEditor.Song.Event newEvent = new MoonscraperChartEditor.Song.Event(name, currentEvent.tick);
                    editor.commandStack.Push(new SongEditModify <MoonscraperChartEditor.Song.Event>(currentEvent, newEvent));
                    editor.selectedObjectsManager.SelectSongObject(newEvent, editor.currentSong.events);
                }
            }
        }
        else if (currentChartEvent != null)
        {
            string prevName = currentChartEvent.eventName;
            if (SongObjectHelper.FindObjectPosition(new ChartEvent(currentChartEvent.tick, name), editor.currentChart.events) == SongObjectHelper.NOTFOUND)
            {
                bool tentativeRecord, lockedRecord;
                ShouldRecordInputField(name, currentChartEvent.eventName, out tentativeRecord, out lockedRecord);

                if (!lockedRecord)
                {
                    editor.commandStack.Pop();
                }

                if (tentativeRecord || lockedRecord)
                {
                    ChartEvent newChartEvent = new ChartEvent(currentChartEvent.tick, name);
                    editor.commandStack.Push(new SongEditModify <ChartEvent>(currentChartEvent, newChartEvent));
                    editor.selectedObjectsManager.SelectSongObject(newChartEvent, editor.currentChart.events);
                }
            }
        }
    }
コード例 #11
0
    static ChartEvent AddChartEvent(ChartEvent chartEvent, IList <SongObject> overwrittenList)
    {
        ChartEditor editor = ChartEditor.Instance;

        TryRecordOverwrite(chartEvent, editor.currentChart.chartObjects, overwrittenList);

        ChartEvent eventToAdd = new ChartEvent(chartEvent);

        editor.currentChart.Add(eventToAdd, false);
        Debug.Log("Added new chart event");

        return(eventToAdd);
    }
    public void UpdateEventName(string name)
    {
        // Make sure the user isn't editing to create 2 of the same events
        if (currentEvent != null)
        {
            string prevName = currentEvent.title;
            if (SongObjectHelper.FindObjectPosition(new Event(name, currentEvent.tick), editor.currentSong.events) == SongObjectHelper.NOTFOUND)
            {
                bool tentativeRecord, lockedRecord;
                ShouldRecordInputField(name, currentEvent.title, out tentativeRecord, out lockedRecord);

                if (!lockedRecord)
                {
                    editor.commandStack.Pop();
                }

                if (tentativeRecord || lockedRecord)
                {
                    Event newEvent = new Event(name, currentEvent.tick);
                    editor.commandStack.Push(new SongEditModify <Event>(currentEvent, newEvent));
                    editor.SelectSongObject(newEvent, editor.currentSong.events);
                }
            }
        }
        else if (currentChartEvent != null)
        {
            string prevName = currentChartEvent.eventName;
            if (SongObjectHelper.FindObjectPosition(new ChartEvent(currentChartEvent.tick, name), editor.currentChart.events) == SongObjectHelper.NOTFOUND)
            {
                bool tentativeRecord, lockedRecord;
                ShouldRecordInputField(name, currentChartEvent.eventName, out tentativeRecord, out lockedRecord);

                if (!lockedRecord)
                {
                    editor.commandStack.Pop();
                }

                if (tentativeRecord || lockedRecord)
                {
                    ChartEvent newChartEvent = new ChartEvent(currentChartEvent.tick, name);
                    editor.commandStack.Push(new SongEditModify <ChartEvent>(currentChartEvent, newChartEvent));
                    editor.SelectSongObject(newChartEvent, editor.currentChart.events);
                }
            }
        }
    }
コード例 #13
0
        static byte[] GetUnrecognisedChartBytes(Chart chart, ExportOptions exportOptions, float resolutionScaleRatio)
        {
            List <SortableBytes> eventList = new List <SortableBytes>();

            foreach (ChartObject chartObject in chart.chartObjects)
            {
                SortableBytes onEvent  = null;
                SortableBytes offEvent = null;

                Note note = chartObject as Note;
                if (note != null)
                {
                    GetUnrecognisedChartNoteBytes(note, out onEvent, out offEvent);
                }

                Starpower sp = chartObject as Starpower;
                if (sp != null)     // Starpower cannot be split up between charts in a midi file
                {
                    GetStarpowerBytes(sp, out onEvent, out offEvent);
                }

                ChartEvent chartEvent = chartObject as ChartEvent;
                if (chartEvent != null)     // Text events cannot be split up in the file
                {
                    SortableBytes bytes = GetChartEventBytes(chartEvent);
                    InsertionSort(eventList, bytes);
                }

                if (onEvent != null && offEvent != null)
                {
                    InsertionSort(eventList, onEvent);

                    if (offEvent.tick == onEvent.tick)
                    {
                        ++offEvent.tick;
                    }

                    InsertionSort(eventList, offEvent);
                }
            }

            return(SortableBytesToTimedEventBytes(eventList.ToArray(), chart.song, exportOptions, resolutionScaleRatio));
        }
コード例 #14
0
 protected override bool Equals(SongObject b)
 {
     if (b.GetType() == typeof(ChartEvent))
     {
         ChartEvent realB = b as ChartEvent;
         if (tick == realB.tick && eventName == realB.eventName)
         {
             return(true);
         }
         else
         {
             return(false);
         }
     }
     else
     {
         return(base.Equals(b));
     }
 }
コード例 #15
0
    protected override void AddObject()
    {
        ActionHistory.Add action;
        string            debugMessage = string.Empty;

        // Add chart event
        ChartEvent chartEvent = new ChartEvent(this.chartEvent);

        editor.currentChart.Add(chartEvent);

        action = new ActionHistory.Add(chartEvent);

        debugMessage = "Added Chart Event \"";

        debugMessage += chartEvent.eventName + "\"";

        Debug.Log(debugMessage);

        editor.actionHistory.Insert(action);
        editor.currentSelectedObject = chartEvent;
    }
コード例 #16
0
    void UpdateEvent(string name)
    {
        ChartEditor editor = ChartEditor.Instance;

        if (currentChartEvent != null)
        {
            ChartEvent newChartEvent = new ChartEvent(currentChartEvent.tick, name);
            editor.commandStack.Push(new SongEditModify <ChartEvent>(currentChartEvent, newChartEvent));
            editor.selectedObjectsManager.SelectSongObject(newChartEvent, editor.currentChart.events);
        }
        else if (currentEvent != null)
        {
            Event newEvent = new Event(name, currentEvent.tick);
            editor.commandStack.Push(new SongEditModify <Event>(currentEvent, newEvent));
            editor.selectedObjectsManager.SelectSongObject(newEvent, editor.currentSong.events);
        }
        else
        {
            Debug.LogError("Trying to update event when object is not recognised as an event");
        }
    }
コード例 #17
0
    protected override bool LessThan(SongObject b)
    {
        if (b.GetType() == typeof(ChartEvent))
        {
            ChartEvent realB = b as ChartEvent;
            if (tick < b.tick)
            {
                return(true);
            }
            else if (tick == b.tick)
            {
                if (string.Compare(eventName, realB.eventName) < 0)
                {
                    return(true);
                }
            }

            return(false);
        }
        else
        {
            return(base.LessThan(b));
        }
    }
コード例 #18
0
 public void CopyFrom(ChartEvent chartEvent)
 {
     tick      = chartEvent.tick;
     eventName = chartEvent.eventName;
 }
コード例 #19
0
    static SortableBytes[] GetChartSortableBytes(Song song, Song.Instrument instrument, Song.Difficulty difficulty, ExportOptions exportOptions)
    {
        Chart chart = song.GetChart(instrument, difficulty);

        Chart.GameMode gameMode = chart.gameMode;

        if (exportOptions.copyDownEmptyDifficulty)
        {
            Song.Difficulty chartDiff = difficulty;
            while (chart.notes.Count <= 0)
            {
                switch (chartDiff)
                {
                case (Song.Difficulty.Easy):
                    chartDiff = Song.Difficulty.Medium;
                    break;

                case (Song.Difficulty.Medium):
                    chartDiff = Song.Difficulty.Hard;
                    break;

                case (Song.Difficulty.Hard):
                    chartDiff = Song.Difficulty.Expert;
                    break;

                case (Song.Difficulty.Expert):
                default:
                    return(new SortableBytes[0]);
                }

                chart = song.GetChart(instrument, chartDiff);
            }
        }

        List <SortableBytes> eventList = new List <SortableBytes>();

        del InsertionSort = (sortableByte) =>
        {
            int index = eventList.Count - 1;

            while (index >= 0 && sortableByte.tick < eventList[index].tick)
            {
                --index;
            }

            eventList.Insert(index + 1, sortableByte);
        };

        foreach (ChartObject chartObject in chart.chartObjects)
        {
            Note note = chartObject as Note;

            SortableBytes onEvent  = null;
            SortableBytes offEvent = null;

            if (note != null)
            {
                int noteNumber = GetMidiNoteNumber(note, gameMode, difficulty);

                GetNoteNumberBytes(noteNumber, note, out onEvent, out offEvent);

                if (exportOptions.forced)
                {
                    // Forced notes
                    if ((note.flags & Note.Flags.Forced) != 0 && note.type != Note.NoteType.Tap && (note.previous == null || (note.previous.tick != note.tick)))     // Don't overlap on chords
                    {
                        // Add a note
                        int difficultyNumber;
                        int forcingOffset;

                        if (!c_difficultyToMidiNoteWriteDict.TryGetValue(difficulty, out difficultyNumber))
                        {
                            throw new Exception("Unhandled difficulty");
                        }

                        if (!c_forcingMidiWriteOffsets.TryGetValue(note.type, out forcingOffset))
                        {
                            throw new Exception("Unhandled note type found when trying to write forcing flag");
                        }

                        int forcedNoteNumber = difficultyNumber + forcingOffset;

                        SortableBytes forceOnEvent  = new SortableBytes(note.tick, new byte[] { ON_EVENT, (byte)forcedNoteNumber, VELOCITY });
                        SortableBytes forceOffEvent = new SortableBytes(note.tick + 1, new byte[] { OFF_EVENT, (byte)forcedNoteNumber, VELOCITY });

                        InsertionSort(forceOnEvent);
                        InsertionSort(forceOffEvent);
                    }

                    int openNote = gameMode == Chart.GameMode.GHLGuitar ? (int)Note.GHLiveGuitarFret.Open : (int)Note.GuitarFret.Open;
                    // Add tap sysex events
                    if (difficulty == Song.Difficulty.Expert && note.rawNote != openNote && (note.flags & Note.Flags.Tap) != 0 && (note.previous == null || (note.previous.flags & Note.Flags.Tap) == 0))  // This note is a tap while the previous one isn't as we're creating a range
                    {
                        // Find the next non-tap note
                        Note nextNonTap = note;
                        while (nextNonTap.next != null && nextNonTap.rawNote != openNote && (nextNonTap.next.flags & Note.Flags.Tap) != 0)
                        {
                            nextNonTap = nextNonTap.next;
                        }

                        // Tap event = 08-50-53-00-00-FF-04-01, end with 01 for On, 00 for Off
                        byte[] tapOnEventBytes  = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, 0xFF, 0x04, SYSEX_ON, SYSEX_END };
                        byte[] tapOffEventBytes = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, 0xFF, 0x04, SYSEX_OFF, SYSEX_END };

                        SortableBytes tapOnEvent  = new SortableBytes(note.tick, tapOnEventBytes);
                        SortableBytes tapOffEvent = new SortableBytes(nextNonTap.tick + 1, tapOffEventBytes);

                        InsertionSort(tapOnEvent);
                        InsertionSort(tapOffEvent);
                    }
                }

                if (gameMode != Chart.GameMode.Drums && gameMode != Chart.GameMode.GHLGuitar &&
                    difficulty == Song.Difficulty.Expert && note.guitarFret == Note.GuitarFret.Open && (note.previous == null || (note.previous.guitarFret != Note.GuitarFret.Open)))
                {
                    // Find the next non-open note
                    Note nextNonOpen = note;
                    while (nextNonOpen.next != null && nextNonOpen.next.guitarFret == Note.GuitarFret.Open)
                    {
                        nextNonOpen = nextNonOpen.next;
                    }

                    byte diff;

                    switch (difficulty)
                    {
                    case (Song.Difficulty.Easy):
                        diff = 0;
                        break;

                    case (Song.Difficulty.Medium):
                        diff = 1;
                        break;

                    case (Song.Difficulty.Hard):
                        diff = 2;
                        break;

                    case (Song.Difficulty.Expert):
                        diff = 3;
                        break;

                    default:
                        continue;
                    }

                    byte[] openOnEventBytes  = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, diff, 0x01, SYSEX_ON, SYSEX_END };
                    byte[] openOffEventBytes = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, diff, 0x01, SYSEX_OFF, SYSEX_END };

                    SortableBytes openOnEvent  = new SortableBytes(note.tick, openOnEventBytes);
                    SortableBytes openOffEvent = new SortableBytes(nextNonOpen.tick + 1, openOffEventBytes);

                    InsertionSort(openOnEvent);
                    InsertionSort(openOffEvent);
                }
            }

            Starpower sp = chartObject as Starpower;
            if (sp != null && difficulty == Song.Difficulty.Expert)     // Starpower cannot be split up between charts in a midi file
            {
                GetStarpowerBytes(sp, out onEvent, out offEvent);
            }

            ChartEvent chartEvent = chartObject as ChartEvent;
            if (chartEvent != null && difficulty == Song.Difficulty.Expert)     // Text events cannot be split up in the file
            {
                InsertionSort(GetChartEventBytes(chartEvent));
            }

            if (onEvent != null && offEvent != null)
            {
                InsertionSort(onEvent);

                if (offEvent.tick == onEvent.tick)
                {
                    ++offEvent.tick;
                }

                InsertionSort(offEvent);
            }
        }

        return(eventList.ToArray());
    }
コード例 #20
0
 private bool canHandle(ChartEvent chartEvent)
 {
     return(Equals(chartEvent.Chart, Chart));
 }
コード例 #21
0
 public ChartEvent(ChartEvent chartEvent) : base(chartEvent.tick)
 {
     eventName = chartEvent.eventName;
 }
コード例 #22
0
 public void StartEdit(ChartEvent eventObject)
 {
     StartRealEdit(eventObject);
 }
コード例 #23
0
ファイル: ChartEvent.cs プロジェクト: LesCol/deobfuscateclon
 // Token: 0x060027B1 RID: 10161 RVA: 0x00010ECA File Offset: 0x0000F0CA
 public ChartEvent(ChartEvent gclass18_0) : base(gclass18_0.uint_0)
 {
     this.string_0 = gclass18_0.string_0;
 }
コード例 #24
0
 static SortableBytes GetChartEventBytes(ChartEvent chartEvent)
 {
     byte[] textEvent = MetaTextEvent(TEXT_EVENT, chartEvent.eventName);
     return(new SortableBytes(chartEvent.tick, textEvent));
 }
コード例 #25
0
        static SortableBytes[] GetChartSortableBytes(Song song, Song.Instrument instrument, Song.Difficulty difficulty, ExportOptions exportOptions)
        {
            Chart chart = song.GetChart(instrument, difficulty);

            Chart.GameMode gameMode = chart.gameMode;

            if (exportOptions.copyDownEmptyDifficulty)
            {
                Song.Difficulty chartDiff = difficulty;
                while (chart.notes.Count <= 0)
                {
                    switch (chartDiff)
                    {
                    case (Song.Difficulty.Easy):
                        chartDiff = Song.Difficulty.Medium;
                        break;

                    case (Song.Difficulty.Medium):
                        chartDiff = Song.Difficulty.Hard;
                        break;

                    case (Song.Difficulty.Hard):
                        chartDiff = Song.Difficulty.Expert;
                        break;

                    case (Song.Difficulty.Expert):
                    default:
                        return(new SortableBytes[0]);
                    }

                    chart = song.GetChart(instrument, chartDiff);
                }
            }

            List <SortableBytes> eventList = new List <SortableBytes>();

            ChartEvent soloOnEvent = null;

            foreach (ChartObject chartObject in chart.chartObjects)
            {
                Note note = chartObject as Note;

                SortableBytes onEvent  = null;
                SortableBytes offEvent = null;

                if (note != null)
                {
                    int noteNumber = GetMidiNoteNumber(note, gameMode, difficulty);

                    GetNoteNumberBytes(noteNumber, note, out onEvent, out offEvent);

                    if (exportOptions.forced)
                    {
                        // Forced notes
                        if ((note.flags & Note.Flags.Forced) != 0 && note.type != Note.NoteType.Tap && (note.previous == null || (note.previous.tick != note.tick)))     // Don't overlap on chords
                        {
                            // Add a note
                            int difficultyNumber;
                            int forcingOffset;

                            if (!c_difficultyToMidiNoteWriteDict.TryGetValue(difficulty, out difficultyNumber))
                            {
                                throw new Exception("Unhandled difficulty");
                            }

                            if (!c_forcingMidiWriteOffsets.TryGetValue(note.type, out forcingOffset))
                            {
                                throw new Exception("Unhandled note type found when trying to write forcing flag");
                            }

                            int forcedNoteNumber = difficultyNumber + forcingOffset;

                            SortableBytes forceOnEvent  = new SortableBytes(note.tick, new byte[] { ON_EVENT, (byte)forcedNoteNumber, VELOCITY });
                            SortableBytes forceOffEvent = new SortableBytes(note.tick + 1, new byte[] { OFF_EVENT, (byte)forcedNoteNumber, VELOCITY });

                            InsertionSort(eventList, forceOnEvent);
                            InsertionSort(eventList, forceOffEvent);
                        }

                        if (instrument == Song.Instrument.Drums && ((note.flags & Note.Flags.ProDrums_Cymbal) == 0))     // We want to write our flags if the cymbal is toggled OFF, as these notes are cymbals by default
                        {
                            int tomToggleNoteNumber;
                            if (MidIOHelper.PAD_TO_CYMBAL_LOOKUP.TryGetValue(note.drumPad, out tomToggleNoteNumber))
                            {
                                SortableBytes tomToggleOnEvent  = new SortableBytes(note.tick, new byte[] { ON_EVENT, (byte)tomToggleNoteNumber, VELOCITY });
                                SortableBytes tomToggleOffEvent = new SortableBytes(note.tick + 1, new byte[] { OFF_EVENT, (byte)tomToggleNoteNumber, VELOCITY });

                                InsertionSort(eventList, tomToggleOnEvent);
                                InsertionSort(eventList, tomToggleOffEvent);
                            }
                        }

                        int openNote = gameMode == Chart.GameMode.GHLGuitar ? (int)Note.GHLiveGuitarFret.Open : (int)Note.GuitarFret.Open;
                        // Add tap sysex events
                        if (difficulty == Song.Difficulty.Expert && note.rawNote != openNote && (note.flags & Note.Flags.Tap) != 0 && (note.previous == null || (note.previous.flags & Note.Flags.Tap) == 0))  // This note is a tap while the previous one isn't as we're creating a range
                        {
                            // Find the next non-tap note
                            Note nextNonTap = note;
                            while (nextNonTap.next != null && nextNonTap.rawNote != openNote && (nextNonTap.next.flags & Note.Flags.Tap) != 0)
                            {
                                nextNonTap = nextNonTap.next;
                            }

                            // Tap event = 08-50-53-00-00-FF-04-01, end with 01 for On, 00 for Off
                            byte[] tapOnEventBytes  = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, 0xFF, 0x04, SYSEX_ON, SYSEX_END };
                            byte[] tapOffEventBytes = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, 0xFF, 0x04, SYSEX_OFF, SYSEX_END };

                            SortableBytes tapOnEvent  = new SortableBytes(note.tick, tapOnEventBytes);
                            SortableBytes tapOffEvent = new SortableBytes(nextNonTap.tick + 1, tapOffEventBytes);

                            InsertionSort(eventList, tapOnEvent);
                            InsertionSort(eventList, tapOffEvent);
                        }
                    }

                    if (gameMode != Chart.GameMode.Drums && gameMode != Chart.GameMode.GHLGuitar &&
                        difficulty == Song.Difficulty.Expert && note.guitarFret == Note.GuitarFret.Open && (note.previous == null || (note.previous.guitarFret != Note.GuitarFret.Open)))
                    {
                        // Find the next non-open note
                        Note nextNonOpen = note;
                        while (nextNonOpen.next != null && nextNonOpen.next.guitarFret == Note.GuitarFret.Open)
                        {
                            nextNonOpen = nextNonOpen.next;
                        }

                        byte diff;

                        switch (difficulty)
                        {
                        case (Song.Difficulty.Easy):
                            diff = 0;
                            break;

                        case (Song.Difficulty.Medium):
                            diff = 1;
                            break;

                        case (Song.Difficulty.Hard):
                            diff = 2;
                            break;

                        case (Song.Difficulty.Expert):
                            diff = 3;
                            break;

                        default:
                            continue;
                        }

                        byte[] openOnEventBytes  = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, diff, 0x01, SYSEX_ON, SYSEX_END };
                        byte[] openOffEventBytes = new byte[] { SYSEX_START, 0x08, 0x50, 0x53, 0x00, 0x00, diff, 0x01, SYSEX_OFF, SYSEX_END };

                        SortableBytes openOnEvent  = new SortableBytes(note.tick, openOnEventBytes);
                        SortableBytes openOffEvent = new SortableBytes(nextNonOpen.tick + 1, openOffEventBytes);

                        InsertionSort(eventList, openOnEvent);
                        InsertionSort(eventList, openOffEvent);
                    }
                }

                Starpower sp = chartObject as Starpower;
                if (sp != null && difficulty == Song.Difficulty.Expert)     // Starpower cannot be split up between charts in a midi file
                {
                    GetStarpowerBytes(sp, out onEvent, out offEvent);
                }

                ChartEvent chartEvent = chartObject as ChartEvent;
                if (chartEvent != null && difficulty == Song.Difficulty.Expert)     // Text events cannot be split up in the file
                {
                    if (soloOnEvent != null && chartEvent.eventName == MidIOHelper.SoloEndEventText)
                    {
                        GetSoloBytes(soloOnEvent, chartEvent.tick, out onEvent, out offEvent);
                        soloOnEvent = null;
                    }
                    else if (chartEvent.eventName == MidIOHelper.SoloEventText)
                    {
                        soloOnEvent = chartEvent;
                    }
                    else
                    {
                        InsertionSort(eventList, GetChartEventBytes(chartEvent));
                    }
                }

                if (onEvent != null && offEvent != null)
                {
                    InsertionSort(eventList, onEvent);

                    if (offEvent.tick == onEvent.tick)
                    {
                        ++offEvent.tick;
                    }

                    InsertionSort(eventList, offEvent);
                }
            }

            if (soloOnEvent != null)        // Found a solo event with no end. Assume the solo lasts for the rest of the song
            {
                SortableBytes onEvent  = null;
                SortableBytes offEvent = null;

                uint soloEndTick = chart.chartObjects[chart.chartObjects.Count - 1].tick;   // In order to get a solo event the chart objects needed to have some object in this container, no need to check size, hopefully...
                GetSoloBytes(soloOnEvent, soloEndTick, out onEvent, out offEvent);

                if (onEvent != null && offEvent != null)
                {
                    InsertionSort(eventList, onEvent);

                    if (offEvent.tick == onEvent.tick)
                    {
                        ++offEvent.tick;
                    }

                    InsertionSort(eventList, offEvent);
                }
            }

            return(eventList.ToArray());
        }
コード例 #26
0
    private static void ReadNotes(IList <MidiEvent> track, Song song, Song.Instrument instrument)
    {
        List <NoteOnEvent> forceNotesList    = new List <NoteOnEvent>();
        List <NoteOnEvent> proDrumsNotesList = new List <NoteOnEvent>();
        List <SysexEvent>  tapAndOpenEvents  = new List <SysexEvent>();

        Chart unrecognised = new Chart(song, Song.Instrument.Unrecognised);

        Chart.GameMode gameMode = Song.InstumentToChartGameMode(instrument);

        if (instrument == Song.Instrument.Unrecognised)
        {
            song.unrecognisedCharts.Add(unrecognised);
        }

        int rbSustainFixLength = (int)(64 * song.resolution / SongConfig.STANDARD_BEAT_RESOLUTION);

        // Load all the notes
        for (int i = 0; i < track.Count; i++)
        {
            var text = track[i] as TextEvent;
            if (text != null)
            {
                if (i == 0)
                {
                    if (instrument == Song.Instrument.Unrecognised)
                    {
                        unrecognised.name = text.Text;
                    }
                    continue;           // We don't want the first event because that is the name of the track
                }

                var        tick       = (uint)text.AbsoluteTime;
                var        eventName  = text.Text.Trim(new char[] { '[', ']' });
                ChartEvent chartEvent = new ChartEvent(tick, eventName);

                if (instrument == Song.Instrument.Unrecognised)
                {
                    unrecognised.Add(chartEvent);
                }
                else
                {
                    song.GetChart(instrument, Song.Difficulty.Expert).Add(chartEvent);
                }
            }

            var note = track[i] as NoteOnEvent;
            if (note != null && note.OffEvent != null)
            {
                Song.Difficulty difficulty;

                var tick = (uint)note.AbsoluteTime;
                var sus  = (uint)(note.OffEvent.AbsoluteTime - tick);

                if (instrument == Song.Instrument.Unrecognised)
                {
                    int  rawNote = SelectRawNoteValue(note.NoteNumber);
                    Note newNote = new Note(tick, rawNote, sus);
                    //difficulty = SelectRawNoteDifficulty(note.NoteNumber);
                    unrecognised.Add(newNote);
                    continue;
                }

                // Check if starpower event
                if (note.NoteNumber == MidIOHelper.STARPOWER_NOTE)
                {
                    foreach (Song.Difficulty diff in EnumX <Song.Difficulty> .Values)
                    {
                        song.GetChart(instrument, diff).Add(new Starpower(tick, sus), false);
                    }

                    continue;
                }

                if (note.NoteNumber == MidIOHelper.SOLO_NOTE)
                {
                    foreach (Song.Difficulty diff in EnumX <Song.Difficulty> .Values)
                    {
                        Chart chart = song.GetChart(instrument, diff);
                        chart.Add(new ChartEvent(tick, MidIOHelper.SoloEventText));
                        chart.Add(new ChartEvent(tick + sus, MidIOHelper.SoloEndEventText));
                    }

                    continue;
                }

                if (gameMode == Chart.GameMode.Drums)
                {
                    Note.DrumPad dummy;
                    if (MidIOHelper.CYMBAL_TO_PAD_LOOKUP.TryGetValue(note.NoteNumber, out dummy))
                    {
                        // Cymbals toggles
                        proDrumsNotesList.Add(note);
                        continue;
                    }
                }

                // Determine which difficulty we are manipulating
                try
                {
                    if (gameMode == Chart.GameMode.GHLGuitar)
                    {
                        difficulty = SelectGHLNoteDifficulty(note.NoteNumber);
                    }
                    else
                    {
                        difficulty = SelectNoteDifficulty(note.NoteNumber);
                    }
                }
                catch
                {
                    continue;
                }

                // Check if we're reading a forcing event instead of a regular note
                if (gameMode != Chart.GameMode.Drums)
                {
                    switch (note.NoteNumber)
                    {
                    case 65:
                    case 66:
                    case 77:
                    case 78:
                    case 89:
                    case 90:
                    case 101:
                    case 102:
                        forceNotesList.Add(note);           // Store the event for later processing and continue
                        continue;

                    default:
                        break;
                    }
                }

                int fret;

                if (sus <= rbSustainFixLength)
                {
                    sus = 0;
                }

                Note.Flags flags = Note.Flags.None;

                if (gameMode == Chart.GameMode.Drums)
                {
                    fret = (int)GetDrumFretType(note.NoteNumber);

                    int cymbalToggleId;
                    if (MidIOHelper.PAD_TO_CYMBAL_LOOKUP.TryGetValue((Note.DrumPad)fret, out cymbalToggleId))
                    {
                        flags |= Note.Flags.ProDrums_Cymbal;
                    }
                }
                else if (gameMode == Chart.GameMode.GHLGuitar)
                {
                    fret = (int)GetGHLFretType(note.NoteNumber);
                }
                else
                {
                    fret = (int)GetStandardFretType(note.NoteNumber);
                }

                {
                    // Add the note to the correct chart
                    Note newNote = new Note(tick, fret, sus, flags);
                    song.GetChart(instrument, difficulty).Add(newNote, false);
                }
            }

            var sysexEvent = track[i] as SysexEvent;
            if (sysexEvent != null)
            {
                tapAndOpenEvents.Add(sysexEvent);
            }
        }

        // Update all chart arrays
        if (instrument != Song.Instrument.Unrecognised)
        {
            foreach (Song.Difficulty diff in EnumX <Song.Difficulty> .Values)
            {
                song.GetChart(instrument, diff).UpdateCache();
            }
        }
        else
        {
            unrecognised.UpdateCache();
        }

        // Apply tap and open note events
        Chart[] chartsOfInstrument;

        if (instrument == Song.Instrument.Unrecognised)
        {
            chartsOfInstrument = new Chart[] { unrecognised };
        }
        else
        {
            chartsOfInstrument = new Chart[EnumX <Song.Difficulty> .Count];

            int difficultyCount = 0;
            foreach (Song.Difficulty difficulty in EnumX <Song.Difficulty> .Values)
            {
                chartsOfInstrument[difficultyCount++] = song.GetChart(instrument, difficulty);
            }
        }

        for (int i = 0; i < tapAndOpenEvents.Count; ++i)
        {
            var    se1   = tapAndOpenEvents[i];
            byte[] bytes = se1.GetData();

            // Check for tap event
            if (bytes.Length == 8 && bytes[5] == 255 && bytes[7] == 1)
            {
                // Identified a tap section
                // 8 total bytes, 5th byte is FF, 7th is 1 to start, 0 to end
                uint tick   = (uint)se1.AbsoluteTime;
                uint endPos = 0;

                // Find the end of the tap section
                for (int j = i; j < tapAndOpenEvents.Count; ++j)
                {
                    var se2    = tapAndOpenEvents[j];
                    var bytes2 = se2.GetData();
                    /// Check for tap section end
                    if (bytes2.Length == 8 && bytes2[5] == 255 && bytes2[7] == 0)
                    {
                        endPos = (uint)(se2.AbsoluteTime - tick);

                        if (endPos > 0)
                        {
                            --endPos;
                        }

                        break;
                    }
                }

                // Apply tap property
                foreach (Chart chart in chartsOfInstrument)
                {
                    int index, length;
                    SongObjectHelper.GetRange(chart.notes, tick, tick + endPos, out index, out length);
                    for (int k = index; k < index + length; ++k)
                    {
                        chart.notes[k].SetType(Note.NoteType.Tap);
                    }
                }
            }

            // Check for open notes
            // 5th byte determines the difficulty to apply to
            else if (bytes.Length == 8 && bytes[5] >= 0 && bytes[5] < 4 && bytes[7] == 1)
            {
                uint            tick = (uint)se1.AbsoluteTime;
                Song.Difficulty difficulty;
                switch (bytes[5])
                {
                case 0: difficulty = Song.Difficulty.Easy; break;

                case 1: difficulty = Song.Difficulty.Medium; break;

                case 2: difficulty = Song.Difficulty.Hard; break;

                case 3: difficulty = Song.Difficulty.Expert; break;

                default: continue;
                }

                uint endPos = 0;
                for (int j = i; j < tapAndOpenEvents.Count; ++j)
                {
                    var se2 = tapAndOpenEvents[j] as SysexEvent;
                    if (se2 != null)
                    {
                        var b2 = se2.GetData();
                        if (b2.Length == 8 && b2[5] == bytes[5] && b2[7] == 0)
                        {
                            endPos = (uint)(se2.AbsoluteTime - tick);

                            if (endPos > 0)
                            {
                                --endPos;
                            }

                            break;
                        }
                    }
                }

                int index, length;
                SongObjectCache <Note> notes;
                if (instrument == Song.Instrument.Unrecognised)
                {
                    notes = unrecognised.notes;
                }
                else
                {
                    notes = song.GetChart(instrument, difficulty).notes;
                }
                SongObjectHelper.GetRange(notes, tick, tick + endPos, out index, out length);
                for (int k = index; k < index + length; ++k)
                {
                    notes[k].guitarFret = Note.GuitarFret.Open;

                    if (gameMode == Chart.GameMode.Drums)
                    {
                        notes[k].guitarFret = NoteFunctions.LoadDrumNoteToGuitarNote(notes[k].guitarFret);
                    }
                }
            }
        }

        // Apply forcing events
        foreach (NoteOnEvent flagEvent in forceNotesList)
        {
            uint tick   = (uint)flagEvent.AbsoluteTime;
            uint endPos = (uint)(flagEvent.OffEvent.AbsoluteTime - tick);

            Song.Difficulty difficulty;

            // Determine which difficulty we are manipulating
            try
            {
                difficulty = SelectNoteDifficulty(flagEvent.NoteNumber);
            }
            catch
            {
                continue;
            }

            Chart chart;
            if (instrument != Song.Instrument.Unrecognised)
            {
                chart = song.GetChart(instrument, difficulty);
            }
            else
            {
                chart = unrecognised;
            }

            int index, length;
            SongObjectHelper.GetRange(chart.notes, tick, tick + endPos, out index, out length);

            for (int i = index; i < index + length; ++i)
            {
                if ((chart.notes[i].flags & Note.Flags.Tap) != 0)
                {
                    continue;
                }

                // if NoteNumber is odd force hopo, if even force strum
                if (flagEvent.NoteNumber % 2 != 0)
                {
                    chart.notes[i].SetType(Note.NoteType.Hopo);
                }
                else
                {
                    chart.notes[i].SetType(Note.NoteType.Strum);
                }
            }
        }

        foreach (var flagEvent in proDrumsNotesList)
        {
            uint tick   = (uint)flagEvent.AbsoluteTime;
            uint endPos = (uint)(flagEvent.OffEvent.AbsoluteTime - tick);
            if (endPos > 0)
            {
                --endPos;
            }

            Debug.Assert(instrument == Song.Instrument.Drums);

            foreach (Song.Difficulty difficulty in EnumX <Song.Difficulty> .Values)
            {
                Chart chart = song.GetChart(instrument, difficulty);

                int index, length;
                SongObjectHelper.GetRange(chart.notes, tick, tick + endPos, out index, out length);

                Note.DrumPad drumPadForFlag;
                if (!MidIOHelper.CYMBAL_TO_PAD_LOOKUP.TryGetValue(flagEvent.NoteNumber, out drumPadForFlag))
                {
                    Debug.Assert(false, "Unknown note number flag " + flagEvent.NoteNumber);
                    continue;
                }

                for (int i = index; i < index + length; ++i)
                {
                    Note note = chart.notes[i];

                    if (note.drumPad == drumPadForFlag)
                    {
                        // Reverse cymbal flag
                        note.flags ^= Note.Flags.ProDrums_Cymbal;
                    }
                }
            }
        }
    }
コード例 #27
0
    string GetSaveString <T>(Song song, IList <T> list, ExportOptions exportOptions, ref string out_errorList, Song.Instrument instrument = Song.Instrument.Guitar) where T : SongObject
    {
        System.Text.StringBuilder saveString = new System.Text.StringBuilder();

        float resolutionScaleRatio = song.ResolutionScaleRatio(exportOptions.targetResolution);

        for (int i = 0; i < list.Count; ++i)
        {
            SongObject songObject = list[i];
            try
            {
                uint tick = (uint)Mathf.Round(songObject.tick * resolutionScaleRatio) + exportOptions.tickOffset;
                saveString.Append(Globals.TABSPACE + tick);

                switch ((SongObject.ID)songObject.classID)
                {
                case (SongObject.ID.BPM):
                    BPM bpm = songObject as BPM;
                    if (bpm.anchor != null)
                    {
                        uint anchorValue = (uint)((double)bpm.anchor * 1000000);
                        saveString.AppendFormat(s_anchorFormat, anchorValue, tick);
                    }

                    saveString.AppendFormat(s_bpmFormat, bpm.value);
                    break;

                case (SongObject.ID.TimeSignature):
                    TimeSignature ts = songObject as TimeSignature;

                    if (ts.denominator == 4)
                    {
                        saveString.AppendFormat(s_tsFormat, ts.numerator);
                    }
                    else
                    {
                        uint denominatorSaveVal = (uint)Mathf.Log(ts.denominator, 2);
                        saveString.AppendFormat(s_tsDenomFormat, ts.numerator, denominatorSaveVal);
                    }
                    break;

                case (SongObject.ID.Section):
                    Section section = songObject as Section;
                    saveString.AppendFormat(s_sectionFormat, section.title);
                    break;

                case (SongObject.ID.Event):
                    Event songEvent = songObject as Event;
                    saveString.AppendFormat(s_eventFormat, songEvent.title);
                    break;

                case (SongObject.ID.ChartEvent):
                    ChartEvent chartEvent = songObject as ChartEvent;
                    saveString.AppendFormat(s_chartEventFormat, chartEvent.eventName);
                    break;

                case (SongObject.ID.Starpower):
                    Starpower sp = songObject as Starpower;
                    saveString.AppendFormat(s_starpowerFormat, (uint)Mathf.Round(sp.length * resolutionScaleRatio));
                    break;

                case (SongObject.ID.Note):
                    Note note = songObject as Note;
                    int  fretNumber;

                    if (instrument != Song.Instrument.Unrecognised)
                    {
                        if (instrument == Song.Instrument.Drums)
                        {
                            fretNumber = GetDrumsSaveNoteNumber(note);
                        }

                        else if (instrument == Song.Instrument.GHLiveGuitar || instrument == Song.Instrument.GHLiveBass)
                        {
                            fretNumber = GetGHLSaveNoteNumber(note);
                        }

                        else
                        {
                            fretNumber = GetStandardSaveNoteNumber(note);
                        }
                    }
                    else
                    {
                        fretNumber = note.rawNote;
                    }

                    saveString.AppendFormat(s_noteFormat, fretNumber, (uint)Mathf.Round(note.length * resolutionScaleRatio));

                    // Only need to get the flags of one note of a chord
                    if (exportOptions.forced && (note.next == null || (note.next != null && note.next.tick != note.tick)))
                    {
                        if ((note.flags & Note.Flags.Forced) == Note.Flags.Forced)
                        {
                            saveString.AppendFormat(s_forcedNoteFormat, tick);
                        }

                        // Save taps line if not an open note, as open note taps cause weird artifacts under sp
                        if (!note.IsOpenNote() && (note.flags & Note.Flags.Tap) == Note.Flags.Tap)
                        {
                            saveString.AppendFormat(s_tapNoteFormat, tick);
                        }
                    }
                    continue;

                default:
                    continue;
                }
                saveString.Append(Globals.LINE_ENDING);

                //throw new System.Exception("Test error count: " + i);
            }
            catch (System.Exception e)
            {
                string error = Logger.LogException(e, "Error with saving object #" + i + " as " + songObject);
                out_errorList += error + Globals.LINE_ENDING;
            }
        }

        return(saveString.ToString());
    }
コード例 #28
0
 static void GetSoloBytes(ChartEvent solo, uint soloEndTick, out SortableBytes onEvent, out SortableBytes offEvent)
 {
     onEvent  = new SortableBytes(solo.tick, new byte[] { ON_EVENT, MidIOHelper.SOLO_NOTE, VELOCITY });
     offEvent = new SortableBytes(soloEndTick, new byte[] { OFF_EVENT, MidIOHelper.SOLO_NOTE, VELOCITY });
 }