示例#1
0
        public void PlayPreview(QNT_Timestamp time, Relative_QNT previewDuration)
        {
            float midTime  = timeline.TimestampToSeconds(time);
            float duration = (float)Conversion.FromQNT(new Relative_QNT(Math.Abs(previewDuration.tick)), timeline.GetTempoForTime(time).microsecondsPerQuarterNote);

            duration = Math.Min(duration, 0.1f);

            UInt64 sampleStart = (UInt64)((midTime - duration / 2) * song.frequency);
            UInt64 sampleEnd   = (UInt64)((midTime + duration / 2) * song.frequency);

            preview.currentSample       = sampleStart << ClipData.PrecisionShift;
            currentPreviewSongSampleEnd = sampleEnd << ClipData.PrecisionShift;
            playPreview = true;
            source.Play();

            List <HitsoundEvent> previewHits = new List <HitsoundEvent>();

            AddHitsoundEvents(previewHits, time, previewDuration.tick > 0 ? timeline.ShiftTick(time, duration) : time);
            for (int i = 0; i < previewHits.Count; ++i)
            {
                HitsoundEvent ev = previewHits[i];
                ev.waitSamples = 0;
                previewHits[i] = ev;
            }

            newPreviewHitsoundEvents = previewHits;
        }
示例#2
0
 public static double FromQNT(Relative_QNT duration, UInt64 microsecondsPerQuarterNote)
 {
     return((duration.tick * (long)microsecondsPerQuarterNote) / ((double)Constants.SecondsToMicroseconds * Constants.PulsesPerQuarterNote));
 }
示例#3
0
 public int CompareTo(Relative_QNT other)
 {
     return(tick.CompareTo(other.tick));
 }