コード例 #1
0
ファイル: BpmEventDialog.cs プロジェクト: samnyan/techmania
 public void Show(BpmEvent currentEvent,
                  UnityAction <double?> confirmCallback)
 {
     this.confirmCallback = confirmCallback;
     if (currentEvent == null)
     {
         newBpm             = null;
         bpmInputField.text = "";
         UpdateRadioButtons();
     }
     else
     {
         newBpm             = currentEvent.bpm;
         bpmInputField.text = currentEvent.bpm.ToString();
         UpdateRadioButtons();
     }
     GetComponent <Dialog>().FadeIn();
 }
コード例 #2
0
    // Works for negative pulses too.
    public float PulseToTime(int pulse)
    {
        float referenceBpm   = (float)patternMetadata.initBpm;
        float referenceTime  = (float)patternMetadata.firstBeatOffset;
        int   referencePulse = 0;

        // Find the immediate BpmEvent before specified pulse.
        for (int i = bpmEvents.Count - 1; i >= 0; i--)
        {
            BpmEvent e = bpmEvents[i];
            if (e.pulse <= pulse)
            {
                referenceBpm   = (float)e.bpm;
                referenceTime  = e.time;
                referencePulse = e.pulse;
                break;
            }
        }

        float secondsPerPulse = 60f / (pulsesPerBeat * referenceBpm);

        return(referenceTime +
               secondsPerPulse * (pulse - referencePulse));
    }