Exemple #1
0
void Difficulty::GetPlayableData(VectorTN NotesOut,
    TimingData& BPS,
    TimingData& VerticalSpeeds,
    TimingData& Warps,
    float Drift, double SpeedConstant)
{
    /*
        We'd like to build the notes' position from 0 to infinity,
        however the real "zero" position would be the judgment line
        in other words since "up" is negative relative to 0
        and 0 is the judgment line
        position would actually be
        judgeline - positiveposition
        and positiveposition would just be
        measure * measuresize + fraction * fractionsize

        In practice, since we use a ms-based model rather than a beat one,
        we just do regular integration of
        position = sum(speed_i * duration_i) + speed_current * (time_current - speed_start_time)
    */

    assert(Data != nullptr);

    ProcessBPS(BPS, Drift);
    ProcessVSpeeds(BPS, VerticalSpeeds, SpeedConstant);

    if (!SpeedConstant) // If there is a speed constant having speed changes is not what we want
        ProcessSpeedVariations(BPS, VerticalSpeeds, Drift);

    if (SpeedConstant) Warps.clear();
    else Warps = Data->Warps;

    // From here on, we'll just copy the notes out. Otherwise, just leave the processed data.
    if (!NotesOut)
        return;

    for (int KeyIndex = 0; KeyIndex < Channels; KeyIndex++)
        NotesOut[KeyIndex].clear();

    /* For all channels of this difficulty */
    for (int KeyIndex = 0; KeyIndex < Channels; KeyIndex++)
    {
        int MIdx = 0;

        /* For each measure of this channel */
        for (auto Msr = Data->Measures.begin();
        Msr != Data->Measures.end();
            ++Msr)
        {
            /* For each note in the measure... */
            ptrdiff_t total_notes = Msr->Notes[KeyIndex].size();

            for (auto Note = 0; Note < total_notes; Note++)
            {
                /*
                    Calculate position. (Change this to TrackNote instead of processing?)
                    issue is not having the speed change data there.
                */
                NoteData &CurrentNote = (*Msr).Notes[KeyIndex][Note];
                TrackNote NewNote;

                NewNote.AssignNotedata(CurrentNote);

                NewNote.AddTime(Drift);

                float VerticalPosition = IntegrateToTime(VerticalSpeeds, NewNote.GetStartTime());
                float HoldEndPosition = IntegrateToTime(VerticalSpeeds, NewNote.GetTimeFinal());

                // if upscroll change minus for plus as well as matrix at screengameplay7k
                if (!CurrentNote.EndTime)
                    NewNote.AssignPosition(VerticalPosition);
                else
                    NewNote.AssignPosition(VerticalPosition, HoldEndPosition);

                // Okay, now we want to know what fraction of a beat we're dealing with
                // this way we can display colored (a la Stepmania) notes.
                // We should do this before changing time by drift.
                double cBeat = IntegrateToTime(BPS, NewNote.GetStartTime());
                double iBeat = floor(cBeat);
                double dBeat = (cBeat - iBeat);

                NewNote.AssignFraction(dBeat);

                double Wamt = -GetWarpAmountAtTime(CurrentNote.StartTime);
                NewNote.AddTime(Wamt);

                if (!SpeedConstant || (NewNote.IsJudgable() && !IsWarpingAt(CurrentNote.StartTime)))
                    NotesOut[KeyIndex].push_back(NewNote);
            }

            MIdx++;
        }

        // done with the channel - sort it
        std::stable_sort(NotesOut[KeyIndex].begin(), NotesOut[KeyIndex].end(),
            [](const TrackNote &A, const TrackNote &B) -> bool
        {
            return A.GetVertical() < B.GetVertical();
        });
    }
}
Exemple #2
0
void Song::Process(VSRG::Difficulty* Which, VectorTN NotesOut, float Drift, double SpeedConstant)
{
	/* 
		We'd like to build the notes' position from 0 to infinity, 
		however the real "zero" position would be the judgment line
		in other words since "up" is negative relative to 0
		and 0 is the judgment line
		position would actually be
		judgeline - positiveposition
		and positiveposition would just be
		measure * measuresize + fraction * fractionsize
	*/

	int ApplyDriftVirtual = Configuration::GetConfigf("UseAudioCompensationKeysounds");
	int ApplyDriftDecoder = Configuration::GetConfigf("UseAudioCompensationNonKeysounded");
	double rDrift = Drift - PreviousDrift;

	/* For all difficulties */
	for (std::vector<VSRG::Difficulty*>::iterator Diff = Difficulties.begin(); Diff != Difficulties.end(); Diff++)
	{
		if (!(*Diff)->Timing.size() || Which != *Diff)
			continue;

		if ( (!ApplyDriftVirtual && (*Diff)->IsVirtual) || (!ApplyDriftDecoder && !(*Diff)->IsVirtual) )
			Drift = 0;
		else
			Drift = rDrift;

		ProcessBPS(*Diff, Drift);
		ProcessVSpeeds(*Diff, SpeedConstant);

		if (!SpeedConstant) // If there is a speed constant having speed changes is not what we want
			ProcessSpeedVariations(*Diff, Drift);


		// From here on, we'll just copy the notes out. Otherwise, just leave the processed data.
		if (!NotesOut)
			return;

		for (int KeyIndex = 0; KeyIndex < (*Diff)->Channels; KeyIndex++)
			NotesOut[KeyIndex].clear();

		/* For all channels of this difficulty */
		for (int KeyIndex = 0; KeyIndex < (*Diff)->Channels; KeyIndex++)
		{
			int MIdx = 0;

			/* For each measure of this channel */
			for (std::vector<VSRG::Measure>::iterator Msr = (*Diff)->Measures.begin(); 
				Msr != (*Diff)->Measures.end();
				Msr++)
			{
				/* For each note in the measure... */
				size_t total_notes = Msr->MeasureNotes[KeyIndex].size();
				for (uint32 Note = 0; Note < total_notes; Note++)
				{
					/* 
					    Calculate position. (Change this to TrackNote instead of processing?)
					    issue is not having the speed change data there.
					*/
					NoteData &CurrentNote = (*Msr).MeasureNotes[KeyIndex][Note];
					TrackNote NewNote;

					NewNote.AssignNotedata(CurrentNote);
					NewNote.AddTime(Drift);

					Vec2 VerticalPosition( 0, IntegrateToTime((*Diff)->VerticalSpeeds, CurrentNote.StartTime + Drift) );
					Vec2 HoldEndPosition( 0, IntegrateToTime((*Diff)->VerticalSpeeds, CurrentNote.EndTime + Drift) );

					// if upscroll change minus for plus as well as matrix at screengameplay7k
					if (!CurrentNote.EndTime)
						NewNote.AssignPosition( -VerticalPosition);
					else
						NewNote.AssignPosition( -VerticalPosition, -HoldEndPosition);

					double cBeat = BeatAtTime((*Diff)->BPS, CurrentNote.StartTime, (*Diff)->Offset + Drift);
					double iBeat = floor(cBeat);
					double dBeat = cBeat - iBeat;

					NewNote.AssignFraction(dBeat);
					NotesOut[KeyIndex].push_back(NewNote);
				}

				std::sort(NotesOut[KeyIndex].begin(), NotesOut[KeyIndex].end(), nSort);
				MIdx++;
			}
		}
	}

	Processed = true;
	PreviousDrift = Drift;
}