Пример #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 void PlayHitsound(QNT_Timestamp time)
        {
            List <HitsoundEvent> previewHits = new List <HitsoundEvent>();

            AddHitsoundEvents(previewHits, time, time);
            for (int i = 0; i < previewHits.Count; ++i)
            {
                HitsoundEvent ev = previewHits[i];
                ev.waitSamples = 0;
                previewHits[i] = ev;
            }

            newPreviewHitsoundEvents = previewHits;
        }
Пример #3
0
        void PlayHitsounds(CopyContext ctx, List <HitsoundEvent> events)
        {
            kick.duckVolume       = 0.0f;
            snare.duckVolume      = 0.0f;
            percussion.duckVolume = 0.0f;
            chainStart.duckVolume = 0.0f;
            chainNote.duckVolume  = 0.0f;
            melee.duckVolume      = 0.0f;
            mine.duckVolume       = 0.0f;

            float oldSpeed = ctx.playbackSpeed;

            UInt64 waitSpeed = (UInt64)1 << ClipData.PrecisionShift;

            if (oldSpeed != 1.0f)
            {
                waitSpeed = (UInt64)(waitSpeed * oldSpeed);
            }

            //Always play hitsounds at full speed
            ctx.playbackSpeed = 1.0f;

            for (int i = events.Count - 1; i >= 0; i--)
            {
                HitsoundEvent ev    = events[i];
                bool          valid = true;

                if (ev.waitSamples > 0)
                {
                    if (waitSpeed > ev.waitSamples)
                    {
                        ev.waitSamples = 0;
                    }
                    else
                    {
                        ev.waitSamples -= waitSpeed;
                    }
                }
                else
                {
                    ctx.volume             = hitSoundVolume * ev.volume;
                    ev.sound.currentSample = ev.currentSample;
                    ev.sound.pan           = ev.pan;
                    ev.sound.CopySampleIntoBuffer(ctx);

                    ev.sound.duckVolume = Mathf.Clamp(ev.sound.duckVolume + 0.25f, 0.0f, 1.0f);

                    if (ev.sound.scaledCurrentSample > ev.sound.samples.Length)
                    {
                        events.RemoveAt(i);
                        valid = false;
                    }
                    else
                    {
                        ev.currentSample = ev.sound.currentSample;
                    }
                }

                //Update the pan:

                ev.pan = (ev.xPos - mainCameraX) / 7.15f;



                if (valid)
                {
                    events[i] = ev;
                }
            }

            ctx.playbackSpeed = 1.0f;
        }