コード例 #1
0
 public void KeyOff()
 {
     if (handle != 0)
     {
         Synthesizer.KeyOff(handle);
         handle = 0;
     }
 }
コード例 #2
0
 public bool Activate(ActivationParams ap)
 {
     if (lastHandle != ap.handle || !Application.isPlaying)
     {
         lastHandle = ap.handle;
         return(Synthesizer.Activate(this, ap));
     }
     return(false);
 }
コード例 #3
0
 protected virtual void OnInit()
 {
     if ((_trigger = FindTrigger(this)) == null)
     {
         RegisterWithParentZone();
     }
     hash   = (int)Synthesizer.GetNextHandle();
     inited = true;
 }
コード例 #4
0
        protected void OnDestroy()
        {
            Sequencer.Reset();
            Synthesizer.Reset();

            if (hierarchyTransform == transform)
            {
                hierarchyTransform = null;
            }
        }
コード例 #5
0
ファイル: Sequencer.cs プロジェクト: nedma/BookOfTheDead_Env
        public static uint CueIn(AudioEmitter e, int i)
        {
            var c = new Cue {
                emitter = e, index = i, cueHandle = Synthesizer.GetNextHandle()
            };

            if (!c.KeyOn())
            {
                return(0);
            }
            activeCues0.Add(c);
            return(c.cueHandle);
        }
コード例 #6
0
ファイル: Sequencer.cs プロジェクト: nedma/BookOfTheDead_Env
        public void KeyOff(float release, EnvelopeMode mode)
        {
#if SEQUENCER_PARANOIA
            Debug.LogFormat(
                Time.frameCount.ToString("X4") +
                " Sequencer.KeyOff: {0} {1} : {2} {3}",
                emitter.name, emitter.patches[index] ? emitter.patches[index].name : "???",
                release, mode);
#endif
            if (keyHandle != 0)
            {
                Synthesizer.KeyOff(keyHandle, release, mode);
            }
            Reset();
        }
コード例 #7
0
ファイル: Sequencer.cs プロジェクト: nedma/BookOfTheDead_Env
        public bool KeyOn()
        {
#if SEQUENCER_PARANOIA
            Debug.LogFormat(
                Time.frameCount.ToString("X4") +
                " Sequencer.KeyOn: {0} {1}",
                emitter.name, emitter.patches[index] ? emitter.patches[index].name : "???");
#endif
            if (Randomizer.zeroToOne <= emitter.randomization.chance)
            {
                if (emitter.auxiliary.source)
                {
                    if (!emitter.patches[index].hasTimings)
                    {
                        Synthesizer.KeyOn(emitter.patches[index], emitter.auxiliary.source, 0f, emitter.volume);
                    }
                }
                else
                {
                    var t =
                        emitter.attachment.useListenerTransform ? Heartbeat.listenerTransform :
                        emitter.attachment.transform ? emitter.attachment.transform :
                        emitter.transform;
                    float r = emitter.randomization.distance.GetRandomValue();
                    var   p = Vector3.zero;
                    if (!Mathf.Approximately(r, 0f))
                    {
                        float a = Randomizer.plusMinusOne * Mathf.PI * 2f;
                        r  *= emitter.zone.radius;
                        p.x = Mathf.Sin(a) * r;
                        p.z = Mathf.Cos(a) * r;
                    }
                    float v;
                    UpdateModVolume(out v, 1000f);
                    keyHandle = Synthesizer.KeyOn(
                        out looping, emitter.patches[index], t, p, 0f, emitter.volume, v);
                }
            }
            return(emitter.patches[index].GetCueInfo(out totalTime, out repeatCount) || looping);
        }
コード例 #8
0
ファイル: Sequencer.cs プロジェクト: nedma/BookOfTheDead_Env
        public CueStatus Update(float dt)
        {
            var s = CueStatus.Playing;

            if (lastFrame == Time.frameCount)
            {
                return(s);
            }
            lastFrame = Time.frameCount;
            if (!emitter.paused)
            {
                currentTime += dt;
                if (totalTime > 0f && currentTime >= totalTime)
                {
                    s = CueStatus.Stopped;
                    if (repeatCount < 0 || ++repeatIndex < repeatCount)
                    {
                        s = CueStatus.Repeating;
                    }
#if SEQUENCER_PARANOIA
                    Debug.LogFormat(
                        Time.frameCount.ToString("X4") +
                        " Cue.Update: {0} {1} {2} {3}/{4} {5}/{6}",
                        emitter.name, emitter.patches[index] ? emitter.patches[index].name : "???",
                        s, currentTime, totalTime, repeatIndex, repeatCount);
#endif
                }

                float v;
                if (UpdateModVolume(out v, dt))
                {
                    if (keyHandle != 0)
                    {
                        Synthesizer.SetModVolume(keyHandle, v);
                    }
                }
            }
            return(s);
        }
コード例 #9
0
        public bool Activate(
            ActivationParams ap
#if UNITY_EDITOR
            , Patch patch
#endif
            )
        {
            bool delayed = !Mathf.Approximately(ap.delay, 0f);

            if (delayed || (!randomize && !increment) ||
                lastFrame != Time.frameCount || !Application.isPlaying)
            {
                if (!delayed)
                {
                    lastFrame = Time.frameCount;
                }
                return(Synthesizer.Activate(this, ap
#if UNITY_EDITOR
                                            , patch
#endif
                                            ));
            }
            return(false);
        }
コード例 #10
0
        public void KeyOn(Animator a)
        {
            bool looping;

            handle = Synthesizer.KeyOn(out looping, patch, a.transform, offset, delay);
        }