Пример #1
0
        private void ProcessNoteOff(int curValidTrack, bool[] starPowerActive, Track.Event e)
        {
            int  myDiff;
            int  endLocation;
            bool isStarPower = false;

            if (e.param1 >= 96 && e.param1 <= 100)
            {
                // End Expert Note
                myDiff       = 3;
                endLocation  = 1 << (e.param1 - 96);
                isStarPower |= starPowerActive[3];
            }
            else if (e.param1 >= 84 && e.param1 <= 88)
            {
                // End Hard Note
                myDiff       = 2;
                endLocation  = 1 << (e.param1 - 84);
                isStarPower |= starPowerActive[2];
            }
            else if (e.param1 >= 72 && e.param1 <= 76)
            {
                // End Moderate Note
                myDiff       = 1;
                endLocation  = 1 << (e.param1 - 72);
                isStarPower |= starPowerActive[1];
            }
            else if (e.param1 >= 60 && e.param1 <= 64)
            {
                // End Beginner Note
                myDiff       = 0;
                endLocation  = 1 << (e.param1 - 60);
                isStarPower |= starPowerActive[0];
            }
            else if (e.param1 >= 65 && e.param1 <= 71)
            {
                // Beginner
                // 67 == End Star Power
                if (e.param1 == 67)
                {
                    starPowerActive[0] = false;
                }
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 77 && e.param1 <= 83)
            {
                // Moderate
                // 79 == End Star Power
                if (e.param1 == 79)
                {
                    starPowerActive[1] = false;
                }
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 89 && e.param1 <= 95)
            {
                // Hard
                // 91 == End Star Power
                if (e.param1 == 91)
                {
                    starPowerActive[2] = false;
                }
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 101 && e.param1 <= 107)
            {
                // Expert
                // 103 == End Star Power
                if (e.param1 == 103)
                {
                    starPowerActive[3] = false;
                }
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 40 && e.param1 <= 59)
            {
                // End antiquated note/chord
                myDiff      = -1;
                endLocation = 0;
            }
            // 40-107 already handled
            else if (e.param1 >= 12 && e.param1 <= 15)
            {
                // AAA
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 24 && e.param1 <= 27)
            {
                // BBB
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 36 && e.param1 <= 39)
            {
                // CCC
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 30 && e.param1 <= 31 || e.param1 == 34)
            {
                // Only on Advanced Harmony
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 108 && e.param1 <= 112)
            {
                // 110 precedes 1st star power note on Less Talk More Rokk (same time slot)
                // 111 is Bass Track only so far
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 == 116)
            {
                myDiff      = -1;
                endLocation = 0;
            }
            else if (e.param1 >= 120 && e.param1 <= 124)
            {
                // Bass track only
                myDiff      = -1;
                endLocation = 0;
            }
            else
            {
                myDiff      = -1;
                endLocation = 0;
            }

            if (myDiff != -1)
            {
                int lastIndex = allNotes[curValidTrack][myDiff].Count - 1;
                while (allNotes[curValidTrack][myDiff][lastIndex].type != (ulong)endLocation)
                {
                    lastIndex--;
                }
                allNotes[curValidTrack][myDiff][lastIndex].length   = (uint)e.absTimeMS - allNotes[curValidTrack][myDiff][lastIndex].time;
                allNotes[curValidTrack][myDiff][lastIndex].isBonus |= isStarPower;
            }
        }
Пример #2
0
        private void ProcessNoteOn(int curValidTrack, ref uint lastTime, ref NoteX lastNote, bool[] starPowerActive, Track.Event e)
        {
            int  noteLocation;
            int  difficulty;
            bool condenseNotes = false;
            bool isStarPower   = false;

            // Determine where to put the note given e.param1 (pitch), param2, e.channel and the current instrument
            //
            if (e.param2 == 0) // Signals an end note as a Note-On event
            {
                // End of the last note
                int myDiff;
                int endLocation;
                if (e.param1 >= 96 && e.param1 <= 100)
                {
                    // End Expert Note
                    myDiff       = 3;
                    endLocation  = 1 << (e.param1 - 96);
                    isStarPower |= starPowerActive[3];
                }
                else if (e.param1 >= 84 && e.param1 <= 88)
                {
                    // End Hard Note
                    myDiff       = 2;
                    endLocation  = 1 << (e.param1 - 84);
                    isStarPower |= starPowerActive[2];
                }
                else if (e.param1 >= 72 && e.param1 <= 76)
                {
                    // End Moderate Note
                    myDiff       = 1;
                    endLocation  = 1 << (e.param1 - 72);
                    isStarPower |= starPowerActive[1];
                }
                else if (e.param1 >= 60 && e.param1 <= 64)
                {
                    // End Beginner Note
                    myDiff       = 0;
                    endLocation  = 1 << (e.param1 - 60);
                    isStarPower |= starPowerActive[0];
                }
                else if (e.param1 >= 65 && e.param1 <= 71)
                {
                    // Beginner
                    // 67 == End Star Power
                    if (e.param1 == 67)
                    {
                        starPowerActive[0] = false;
                    }
                    endLocation = 0;
                    myDiff      = -1;
                }
                else if (e.param1 >= 77 && e.param1 <= 83)
                {
                    // Moderate
                    // 79 == End Star Power
                    if (e.param1 == 79)
                    {
                        starPowerActive[1] = false;
                    }
                    endLocation = 0;
                    myDiff      = -1;
                }
                else if (e.param1 >= 89 && e.param1 <= 95)
                {
                    // Hard
                    // 91 == End Star Power
                    if (e.param1 == 91)
                    {
                        starPowerActive[2] = false;
                    }
                    endLocation = 0;
                    myDiff      = -1;
                }
                else if (e.param1 >= 101 && e.param1 <= 107)
                {
                    // Expert
                    // 103 == End Star Power
                    if (e.param1 == 103)
                    {
                        starPowerActive[3] = false;
                    }
                    // This has usually triggered an identical response in the previous 3 else if's
                    // 106, then 105: Markers for saved riffs?
                    endLocation = 0;
                    myDiff      = -1;
                }
                else if (e.param1 >= 40 && e.param1 <= 59)
                {
                    // Antiquated markers for changing notes
                    myDiff      = -1;
                    endLocation = 0;
                }
                //
                // Handled 40 through 107
                else if (e.param1 >= 12 && e.param1 <= 15)
                {
                    // AAA
                    myDiff      = -1;
                    endLocation = 0;
                }
                else if (e.param1 >= 24 && e.param1 <= 27)
                {
                    // BBB
                    myDiff      = -1;
                    endLocation = 0;
                }
                else if (e.param1 >= 36 && e.param1 <= 39)
                {
                    // CCC
                    myDiff      = -1;
                    endLocation = 0;
                }
                else if (e.param1 >= 108 && e.param1 <= 112)
                {
                    // ???
                    myDiff      = -1;
                    endLocation = 0;
                }
                else if (e.param1 >= 116 && e.param1 <= 124)
                {
                    // ???
                    myDiff      = -1;
                    endLocation = 0;
                }
                else if (e.param1 >= 30 && e.param1 <= 31 || e.param1 == 34)
                {
                    // ???
                    myDiff      = -1;
                    endLocation = 0;
                }
                else
                {
                    myDiff      = -1;
                    endLocation = 0;
                }

                if (myDiff != -1)
                {
                    // Valid end of note event found
                    int lastIndex = allNotes[curValidTrack][myDiff].Count - 1;
                    while (allNotes[curValidTrack][myDiff][lastIndex].type != (ulong)endLocation)
                    {
                        lastIndex--;
                    }
                    allNotes[curValidTrack][myDiff][lastIndex].length   = (uint)e.absTimeMS - allNotes[curValidTrack][myDiff][lastIndex].time;
                    allNotes[curValidTrack][myDiff][lastIndex].isBonus |= isStarPower;
                }

                noteLocation = 0;
                difficulty   = -1;
            }
            // param2 != 0
            else if (e.param1 >= 96 && e.param1 <= 100)
            {
                // Start Expert Note
                noteLocation = 1 << (e.param1 - 96);
                difficulty   = 3;
                isStarPower |= starPowerActive[3];
            }
            else if (e.param1 >= 84 && e.param1 <= 88)
            {
                // Start Hard Note
                noteLocation = 1 << (e.param1 - 84);
                difficulty   = 2;
                isStarPower |= starPowerActive[2];
            }
            else if (e.param1 >= 72 && e.param1 <= 76)
            {
                // Start Moderate Note
                noteLocation = 1 << (e.param1 - 72);
                difficulty   = 1;
                isStarPower |= starPowerActive[1];
            }
            else if (e.param1 >= 60 && e.param1 <= 64)
            {
                // Start Beginner Note
                noteLocation = 1 << (e.param1 - 60);
                difficulty   = 0;
                isStarPower |= starPowerActive[0];
            }
            else if (e.param1 >= 65 && e.param1 <= 71)
            {
                // Beginner
                // 67 == Start Star Power
                if (e.param1 == 67)
                {
                    starPowerActive[0] = true;
                }
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 77 && e.param1 <= 83)
            {
                // Moderate
                // 79 == Start Star Power
                if (e.param1 == 79)
                {
                    starPowerActive[1] = true;
                }
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 89 && e.param1 <= 95)
            {
                // Hard
                // 91 == Start Star Power
                if (e.param1 == 91)
                {
                    starPowerActive[2] = true;
                }
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 101 && e.param1 <= 107)
            {
                // Expert
                // 103 == Start Star Power
                if (e.param1 == 103)
                {
                    starPowerActive[3] = true;
                }
                // This has usually triggered an identical response in the previous 3 else if's
                // 106, then 105: Sustained?
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 40 && e.param1 <= 59)
            {
                /* This is probably antiquated data that's a remnent of some step
                 * the Rock Band creators used to generate notes, these are being ignored*/
                // -------Notes-------
                // This seems to usually be the last in the time slot. Guesses:
                // American Woman, this comes first in time slot
                // Tappable for all notes at this time slot
                // 41 : Next note is tappable, or begin SP sequence on this note
                // 40 : Tappable, SP note
                // SP+tappable for note param1-40
                noteLocation = 0;
                difficulty   = -1;
            }
            // All events 40-107 have been handled
            else if (e.param1 >= 12 && e.param1 <= 15)
            {
                // AAA
                noteLocation = 0;
                difficulty   = -1;
            }
            else if ((e.param1 >= 24 && e.param1 <= 27))
            {
                // BBB
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 36 && e.param1 <= 39)
            {
                // CCC
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 30 && e.param1 <= 31 || e.param1 == 34)
            {
                // Only on (Advanced Harmony)
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 108 && e.param1 <= 112)
            {
                // ???
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 == 116)
            {
                // ???
                noteLocation = 0;
                difficulty   = -1;
            }
            else if (e.param1 >= 120 && e.param1 <= 124)
            {
                // Bass?
                noteLocation = 0;
                difficulty   = -1;
            }
            else
            {
                noteLocation = 0;
                difficulty   = -1;
            }

            if (noteLocation > 31 || noteLocation < 0)
            {
                throw new System.NotSupportedException();
            }

            if (condenseNotes && (e.absTimeMS == lastTime) && (lastNote != null))
            {
                lastNote.AddTo((ulong)noteLocation);
            }
            else
            {
                if (noteLocation != 0)
                {
                    lastTime          = (uint)e.absTimeMS;
                    lastNote          = new NoteX((uint)e.absTimeMS, (ulong)noteLocation);
                    lastNote.isBonus |= isStarPower;
                    allNotes[curValidTrack][difficulty].Add(lastNote);
                }
            }
        }
Пример #3
0
        private bool CalculateAbsTimes()
        {
            int[] curEventIndex = new int[totalTracks];
            for (int i = 0; i < totalTracks; i++)
            {
                curEventIndex[i] = 0;
            }

            long curTickCount = 0;
            long curTimeUS    = 0;
            long USperTick    = -1;

            if (ticksPerBeat != -1)
            {
            }
            else if (ticksPerFrame != -1)
            {
                if (timeCode == -1)
                {
                    return(false);
                }
            }
            else
            {
                return(false); // should never be called
            }
            bool continueLoop = true;
            long nextMarker   = 0;

            while (continueLoop)
            {
                int  earliestElement   = -1;
                long earliestTickCount = 0x7FFFFFFFFFFFFFFF;

                // Find the earliest event (must be in a valid track with more unhandled events)
                for (int i = 0; i < totalTracks; i++)
                {
                    if (curEventIndex[i] >= allTracks[i].allEvents.Count)
                    {
                        continue;
                    }
                    if (allTracks[i].allEvents[curEventIndex[i]].absTickCount < earliestTickCount)
                    {
                        earliestTickCount = allTracks[i].allEvents[curEventIndex[i]].absTickCount;
                        earliestElement   = i;
                    }
                }

                // Get a handle on the Event object, and increment the curEventIndex for the object's Track.
                Track.Event earliestEvent = allTracks[earliestElement].allEvents[curEventIndex[earliestElement]++];

                if (earliestTickCount <= nextMarker)
                {
                    markers.Add(curTimeUS + (nextMarker - curTickCount) * USperTick);
                    nextMarker += ticksPerBeat;
                }

                // Increase the absolute time upto the earliest event, converting from Ticks to MS
                long dT   = earliestTickCount - curTickCount;
                long dTms = dT * USperTick;
                curTickCount += dT;
                curTimeUS    += dTms;

                // Check for Set Tempo MetaEvent (command number 0x51)
                if (earliestEvent.eventType == Track.MetaCommandToEventType(0x51))
                {
                    long USperBeat = (earliestEvent.channel << 16) | (earliestEvent.param1 << 8) | (earliestEvent.param2);
                    USperTick = USperBeat / ticksPerBeat;
                }
                else if (USperTick == -1 && dT != 0)
                {
                    break;
                }

                earliestEvent.absTimeMS = curTimeUS / 1000;


                // Repeat loop while there is an outstanding event
                continueLoop = false;
                for (int i = 0; i < totalTracks; i++)
                {
                    if (allTracks[i].allEvents.Count > curEventIndex[i])
                    {
                        continueLoop = true;
                        break;
                    }
                }
            }
            return(true);
        }