Exemple #1
0
    public static void Draw(AudioNode node)
    {
        UndoHandler.CheckUndo(new UnityEngine.Object[] { node, node.NodeData }, "Random Data Node Change");
        node.Name = EditorGUILayout.TextField("Name", node.Name);
        NodeTypeDataDrawer.Draw(node);
        EditorGUILayout.Separator();

        if (node.NodeData.SelectedArea == 0)
        {
            EditorGUILayout.BeginVertical();

            EditorGUILayout.LabelField("Weights");

            for (int i = 0; i < node.Children.Count; ++i)
            {
                var child   = node.Children[i];
                var weights = (node.NodeData as RandomData).weights;
                EditorGUILayout.BeginHorizontal();

                weights[i] = EditorGUILayout.IntSlider(child.Name, weights[i], 0, 100);

                EditorGUILayout.EndHorizontal();
            }

            EditorGUILayout.EndVertical();
        }
        UndoHandler.CheckGUIChange();
    }
Exemple #2
0
    private void initAudioGraph(AudioNode first)
    {
        AudioNode curr;

        hashMap.Add(first.location, first);
        ArrayList neighbors, _toClear = new ArrayList();

        queue.Enqueue(first);

        while (queue.Count > 0)
        {
            curr = queue.Dequeue();

            _toClear.Add(curr);

            if (curr.visited == false)
            {
                neighbors      = curr.addNeighbors(hashMap);
                curr.neighbors = neighbors;
                curr.visited   = true;

                foreach (AudioNode node in neighbors)
                {
                    if (node != null && node.visited == false)
                    {
                        queue.Enqueue(node);
                    }
                }
            }
        }
        queue.Clear();
        clearNodes(_toClear);
    }
Exemple #3
0
    private float PlayScheduled(AudioNode startNode, AudioNode currentNode, double playAtDSPTime, out float volume)
    {
        var   audioData = currentNode.NodeData as AudioData;
        float length    = 0;

        volume = 1;
        if (audioData.Clip != null)
        {
            length = audioData.Clip.samples / (float)audioData.Clip.frequency;

            Current.clip    = audioData.Clip;
            Current.volume  = RuntimeHelper.ApplyVolume(startNode, currentNode);
            volume          = Current.volume;
            Current.volume *= busVolume;

            Current.pitch = RuntimeHelper.ApplyPitch(startNode, currentNode);
            RuntimeHelper.ApplyAttentuation(startNode, currentNode, Current);

            length = RuntimeHelper.LengthFromPitch(length, Current.pitch);
            endTimes[currentIndex] = playAtDSPTime + length;


            Current.PlayScheduled(playAtDSPTime);
        }

        return(length);
    }
 private static void OnRandomNode(AudioNode parent)
 {
     if (parent.Type == AudioNodeType.Random)
     {
         (parent.NodeData as RandomData).weights.Add(50);
     }
 }
Exemple #5
0
    void OnSceneGUI()
    {
        AudioNode ourTarget = (AudioNode)target;

        ourTarget.rangeStop = Handles.RadiusHandle(Quaternion.identity, ourTarget.transform.position, ourTarget.rangeStop);
        if (ourTarget.rangeStop < ourTarget.rangeStart)
        {
            ourTarget.rangeStart = ourTarget.rangeStop;
        }
        ourTarget.rangeStart = Handles.RadiusHandle(Quaternion.identity, ourTarget.transform.position, ourTarget.rangeStart);
        if (ourTarget.rangeStart > ourTarget.rangeStop)
        {
            ourTarget.rangeStop = ourTarget.rangeStart;
        }
        if (ourTarget.rangeStart < 0)
        {
            ourTarget.rangeStart = 0;
        }
        if (ourTarget.rangeStop < 0)
        {
            ourTarget.rangeStop = 0;
        }

        if (GUI.changed)
        {
            EditorUtility.SetDirty(target);
        }
    }
Exemple #6
0
 private void StopAndCleanup()
 {
     Stop();
     spawnedFrom.ReleaseObject(gameObject);
     beloningToNode.Bus.GetRuntimePlayers().Remove(this);
     beloningToNode = null;
 }
        public static void AddDataClass(AudioNode node)
        {
            switch (node.Type)
            {
            case AudioNodeType.Audio:
                node.NodeData = node.gameObject.AddComponent <AudioData>();
                break;

            case AudioNodeType.Random:
                node.NodeData = node.gameObject.AddComponent <RandomData>();
                for (int i = 0; i < node.Children.Count; ++i)
                {
                    (node.NodeData as RandomData).weights.Add(50);
                }
                break;

            case AudioNodeType.Sequence:
                node.NodeData = node.gameObject.AddComponent <SequenceData>();
                break;

            case AudioNodeType.Multi:
                node.NodeData = node.gameObject.AddComponent <MultiData>();
                break;
            }
        }
Exemple #8
0
        public static void SetNewBank(AudioNode node, AudioBankLink newBankLink)
        {
            MoveBetweenBanks(node, GetParentBank(node), newBankLink);

            node.BankLink = newBankLink;
            SetNewBankLink(node, newBankLink);
        }
Exemple #9
0
 public static void Draw(AudioNode node)
 {
     UndoHandler.CheckUndo(new UnityEngine.Object[] { node, node.NodeData });
     node.Name = EditorGUILayout.TextField("Name", node.Name);
     NodeTypeDataDrawer.Draw(node);
     UndoHandler.CheckGUIChange();
 }
Exemple #10
0
    //声音渐变迭代器//
    IEnumerator AudioSourceVolume(AudioNode audioNode)
    {
        float initVolume = audioNode.audioSource.volume;
        float preTime    = 1.0f / audioNode.durationTime;

        if (!audioNode.audioSource.isPlaying)
        {
            audioNode.audioSource.Play();
        }
        while (true)
        {
            initVolume += audioNode.volumeAdd * Time.deltaTime * preTime;
            if (initVolume > 1 || initVolume < 0)
            {
                initVolume = Mathf.Clamp01(initVolume);
                audioNode.audioSource.volume = initVolume;
                if (initVolume == 0)
                {
                    audioNode.audioSource.Stop();
                }
                break;
            }
            else
            {
                audioNode.audioSource.volume = initVolume;
            }
            yield return(1);
        }
    }
Exemple #11
0
        public override void Init()
        {
            // ShadowMappingComponent smc;
            // RenderManager.AddComponent(smc = new ShadowMappingComponent(cam, Environment));
            // smc.RenderMode = ShadowMappingComponent.ShadowRenderMode.Forward;



            Geometry floor = new Geometry(MeshFactory.CreateCube(new Math.Vector3f(-5f, -0.5f, -5f), new Math.Vector3f(5, 0.5f, 5f)));

            rootNode.AddChild(floor);
            PhysicsWorld.AddObject(floor, 0.0f);



            Node test = (Node)AssetManager.LoadModel(AssetManager.GetAppPath() + "\\models\\sphere16.obj");

            test.SetLocalTranslation(new Math.Vector3f(0, 25, 0));
            rootNode.AddChild(test);

            PhysicsWorld.AddObject(test, 5.0f);


            Sound     cat = (Sound)AssetManager.Load(AssetManager.GetAppPath() + "\\sounds\\cat.wav");
            AudioNode an  = new AudioNode(cat);

            test.AddChild(an);

            InputManager.AddKeyboardEvent(new Input.KeyboardEvent(Input.InputManager.KeyboardKey.Space, () => { an.Play(); }));
        }
Exemple #12
0
    // Use this for initialization
    void Start()
    {
        audioNodes = new AudioNode[4];
        for (int c=0; c<audioNodes.Length; c++) {
            audioNodes [c] = new AudioNode ();
        }

        audioNodes[0].audio = song1;
        audioNodes[1].audio = song2;
        audioNodes[2].audio = song3;
        audioNodes[3].audio = song4;

        for (int k=0; k<audioNodes.Length; k++) {
            audioNodes[k].reverbFilter = new AudioReverbFilter();
            audioNodes[k].distortionFilter = new AudioDistortionFilter();
            audioNodes[k].loPass = new AudioLowPassFilter();
            audioNodes[k].hiPass = new AudioHighPassFilter();

            /*
            audioNodes[k].reverbFilter.audio= audioNodes[k].audio;
            audioNodes[k].distortionFilter.audio = audioNodes[k].audio;
            audioNodes[k].loPass.audio = audioNodes[k].audio;
            audioNodes[k].hiPass.audio = audioNodes[k].audio;
            */
        }
        i = 0;
        j = 0;
        trackList = new string[] {song1.audio.name, song2.audio.name, song3.audio.name, song4.audio.name};
        effectList = new string[] {"Reverb Filter", "Hi-Pass", "Lo-Pass", "Distortion Filter"};
    }
        public static AudioNode CreateNode(GameObject go, AudioNode parent, AudioNodeType type)
        {
            var newNode = CreateNode(go, parent, GUIDCreator.Create(), type);

            newNode.Name = "Name";
            AddDataClass(newNode);
            return(newNode);
        }
 public static AudioNode Duplicate(AudioNode audioNode)
 {
     return(NodeWorker.DuplicateHierarchy(audioNode, (@oldNode, newNode) =>
     {
         newNode.NodeData = audioNode.gameObject.AddComponent(newNode.NodeData.GetType()) as NodeTypeData;
         EditorUtility.CopySerialized(oldNode.NodeData, newNode.NodeData);
     }));
 }
Exemple #15
0
    public static void createWindow(AudioNode target)
    {
        loadAllClips();
        findUsedClips();
        SoundBaseSearchWindow window = (SoundBaseSearchWindow)EditorWindow.GetWindow(typeof(SoundBaseSearchWindow));

        window.targetNode = target;
    }
Exemple #16
0
 public static void AssignToNodes(AudioNode node, Action <AudioNode> assignFunc)
 {
     assignFunc(node);
     for (int i = 0; i < node.Children.Count; ++i)
     {
         AssignToNodes(node.Children[i], assignFunc);
     }
 }
Exemple #17
0
        private static BankTuple CreateTuple(AudioNode node, AudioClip clip)
        {
            BankTuple tuple = new BankTuple();

            tuple.Node = node;
            tuple.Clip = clip;
            return(tuple);
        }
Exemple #18
0
 public void connectToSoundTrackAudioNode(AudioNode soundTrackAudioNode)
 {
     EventHorizonBlazorInterop.Func <CachedEntity>(
         new object[]
     {
         new string[] { this.___guid, "connectToSoundTrackAudioNode" }, soundTrackAudioNode
     }
         );
 }
Exemple #19
0
 public void connectAudioNodes(AudioNode inputAudioNode, AudioNode outputAudioNode)
 {
     EventHorizonBlazorInterop.Func <CachedEntity>(
         new object[]
     {
         new string[] { this.___guid, "connectAudioNodes" }, inputAudioNode, outputAudioNode
     }
         );
 }
        public static float ApplyPitch(AudioNode root, AudioNode current)
        {
            if (current == root)
            {
                return(current.NodeData.MinPitch);
            }

            return(current.NodeData.MinPitch + ApplyPitch(root, current.Parent) - 1);
        }
 public static AudioRolloffMode ApplyAttentuation(AudioNode root, AudioNode current, AudioSource workOn)
 {
     if (current == root || current.NodeData.OverrideAttenuation)
     {
         return(ApplyRolloffData(current, workOn));
     }
     else
     {
         return(ApplyAttentuation(root, current.Parent, workOn));
     }
 }
 public static AudioBus GetBus(AudioNode currentNode)
 {
     if (currentNode.OverrideParentBus || currentNode.IsRoot)
     {
         return(currentNode.Bus);
     }
     else
     {
         return(GetBus(currentNode.Parent));
     }
 }
        public static AudioNode CreateNode(GameObject go, AudioNode parent, int guid, AudioNodeType type)
        {
            var node = go.AddComponent <AudioNode>();

            node.GUID = guid;
            node.Type = type;
            node.Bus  = parent.Bus;
            NodeWorker.AssignParent(node, parent);

            return(node);
        }
    /// <summary>
    /// 聲音漸變
    /// </summary>
    /// <param name="audioNode"></param>
    /// <returns></returns>
    IEnumerator AudioSourceVolume(AudioNode audioNode, float maxValue, float minValue)
    {
        float initVolume = audioNode.audioSource.volume;
        float preTime    = 1.0f / audioNode.durationTime;

        if (!audioNode.audioSource.isPlaying)
        {
            audioNode.audioSource.Play();
        }
        while (true)
        {
            initVolume += audioNode.volumeAdd * Time.deltaTime * preTime;
            if (audioNode.volumeAdd == -1)
            {
                if (initVolume < minValue)
                {
                    initVolume = Mathf.Clamp01(initVolume);

                    audioNode.audioSource.volume = initVolume;
                    if (initVolume == 0)
                    {
                        audioNode.audioSource.Stop();
                    }
                    break;
                }
                else
                {
                    Debug.Log(initVolume);
                    audioNode.audioSource.volume = initVolume;
                }
            }

            if (audioNode.volumeAdd == 1)
            {
                if (initVolume > maxValue)
                {
                    initVolume = Mathf.Clamp01(initVolume);

                    audioNode.audioSource.volume = initVolume;
                    if (initVolume == 0)
                    {
                        audioNode.audioSource.Stop();
                    }
                    break;
                }
                else
                {
                    Debug.Log(initVolume);
                    audioNode.audioSource.volume = initVolume;
                }
            }
            yield return(1);
        }
    }
        public static void ConvertNodeType(AudioNode node, AudioNodeType newType)
        {
            if (newType == node.Type)
            {
                return;
            }

            Object.DestroyImmediate(node.NodeData, true);
            node.Type = newType;
            AddDataClass(node);
        }
Exemple #26
0
 /// <summary>
 /// Find the audio block for the given audio node.
 /// </summary>
 public AudioBlock FindBlock(AudioNode node)
 {
     foreach (Control c in this.trackLayout.Controls)
     {
         if (c is AudioBlock && ((AudioBlock)c).Node == node)
         {
             return((AudioBlock)c);
         }
     }
     return(null);
 }
Exemple #27
0
 /**
  * Stops any animations or playback on any nodes in the group, regardless
  * of whether they were started by this helper or not.
  */
 public void stopAll()
 {
     foreach (GameObject node in getRealTargets())
     {
         AudioNode audioNode = node.GetComponent <AudioNode>();
         if (audioNode == null)
         {
             audioNode.play = false;
         }
         node.GetComponent <Animation>().Stop();
     }
 }
Exemple #28
0
    public void PlayAtPosition(GameObject go, AudioNode audioNode, Vector3 position)
    {
        var poolObject = pool.GetObject();

        poolObject.transform.position = position;
        if (player == null)
        {
            player = poolObject.GetComponent <RuntimePlayer>();
        }
        GetValue(GOAudioNodes, go).Add(new RuntimeTuple(audioNode, player));
        player.Play(audioNode);
    }
Exemple #29
0
    public void Play(AudioNode node)
    {
        currentIndex  = 0;
        attachedToBus = RuntimeHelper.GetBus(node);
        busVolume     = attachedToBus.RuntimeVolume;

        //This is to queue the next playing node, as the first clip will not yield a waitforseconds
        firstClip = true;

        //Play this node 40 ms(depending on framerate) in the future
        StartCoroutine(StartPlay(node, node, new DSPTime(AudioSettings.dspTime + 0.1)));
    }
Exemple #30
0
        private delegate void SetAudioDelegate(urakawa.media.data.audio.AudioMediaData audio); // delegate for Invoke()


        /// <summary>
        /// Create an empty audio block. (Normally this is used by the designer.)
        /// </summary>
        public AudioBlock()
        {
            InitializeComponent();
            DoubleBuffered            = true;
            this.node                 = null;
            this.selection            = null;
            this.baseSize             = Size;
            this.baseMargin           = Margin.Left;
            this.zoom                 = 1.0;
            this.audioScale           = AUDIO_SCALE;
            this.cursorBar.BaseHeight = this.cursorBar.Height;
            this.playing              = false;
        }
Exemple #31
0
    public void Play(GameObject controllingObject, AudioNode audioNode, GameObject attachedTo)
    {
        var poolObject = pool.GetObject();

        poolObject.transform.parent        = attachedTo.transform;
        poolObject.transform.localPosition = new Vector3();
        if (player == null)
        {
            player = poolObject.GetComponent <RuntimePlayer>();
        }
        GetValue(GOAudioNodes, controllingObject).Add(new RuntimeTuple(audioNode, player));
        player.Play(audioNode);
    }