Example #1
0
    public void AddOscilator(Oscilator parent, string parentName)
    {
        Oscilator oscilator;

        oscilator = new Oscilator();

        if (parent == null)
        {
            wave.master.Add(oscilator);
        }
        else
        {
            parent.modulators.Add(oscilator);
        }

        GameObject tab;

        tab = Instantiate(prefab);
        int index;

        if (parent == null)
        {
            index = wave.master.Count;
        }
        else
        {
            index = parent.modulators.Count;
        }
        tab.name = parentName + " < Osc " + index;
        handler.AddTab(tab);

        AddOsc    add    = tab.GetComponentInChildren <AddOsc>();
        RemoveOsc remove = tab.GetComponentInChildren <RemoveOsc>();
        NameUI    name   = tab.GetComponentInChildren <NameUI>();

        AmplitudeSlider amplitude = tab.GetComponentInChildren <AmplitudeSlider>();
        FrequencySlider frequency = tab.GetComponentInChildren <FrequencySlider>();
        PhaseSlider     phase     = tab.GetComponentInChildren <PhaseSlider>();

        if (add != null)
        {
            add.Set(tab.name, oscilator, this);
        }
        if (remove != null)
        {
            remove.Set(this, wave, parent, oscilator, tab, handler);
        }
        if (name != null)
        {
            name.SetName(tab.name);
        }

        phase.Set(this, oscilator);
        amplitude.Set(this, oscilator, amplitudeMinMax);
        frequency.Set(this, oscilator, frequencyMinMax);
    }
Example #2
0
    public void Set(MasterUI master, Oscilator oscilator, MinMax minMax)
    {
        this.master    = master;
        this.oscilator = oscilator;
        Slider slider = GetComponent <Slider>();

        slider.onValueChanged.AddListener(Slide);
        slider.minValue = minMax.min;
        slider.maxValue = minMax.max;
    }
Example #3
0
    public void Set(MasterUI master, Oscilator oscilator)
    {
        this.master    = master;
        this.oscilator = oscilator;
        Slider slider = GetComponent <Slider>();

        slider.onValueChanged.AddListener(Slide);
        slider.minValue = 0f;
        slider.maxValue = 2 * (float)Math.PI;
    }
Example #4
0
    public void Set(string name, Oscilator osc, MasterUI controller)
    {
        this.name       = name;
        this.osc        = osc;
        this.controller = controller;

        Button button;

        button = GetComponent <Button>();
        button.onClick.AddListener(Add);
    }
Example #5
0
    public void Set(MasterUI master, SynthWave wave, Oscilator parent, Oscilator osc, GameObject tab, TabsUI handler)
    {
        this.master  = master;
        this.parent  = parent;
        this.osc     = osc;
        this.tab     = tab;
        this.handler = handler;

        Button button;

        button = GetComponent <Button>();
        button.onClick.AddListener(Remove);
    }
Example #6
0
    private float FmSytnh(Oscilator oscilator, float time)
    {
        float frequency = oscilator.frequency;

        if (oscilator.modulators != null)
        {
            foreach (Oscilator modulator in oscilator.modulators)
            {
                frequency += FmSytnh(modulator, time);
            }
        }
        return(oscilator.amplitude * Mathf.Sin(2 * Mathf.PI * frequency * time + oscilator.phase));
    }
Example #7
0
    // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
    override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
    {
        animator.ResetTrigger("nextState");
        _states = new List <int>(4);
        List <int> myArr = new List <int>()
        {
            1, 2, 3, 4
        };

        for (int i = 0; i < statesQtd; i++)
        {
            int index = Random.Range(0, myArr.Count - 1);
            _states.Add(myArr[index]);
            myArr.RemoveAt(index);
            Debug.Log(_states[i]);
        }
        oscilator = AudioManager.Instance.oscilator1;
    }
Example #8
0
 // OnStateEnter is called when a transition starts and the state machine starts to evaluate this state
 override public void OnStateEnter(Animator animator, AnimatorStateInfo stateInfo, int layerIndex)
 {
     animator.ResetTrigger("nextState");
     o1           = AudioManager.Instance.oscilator1;
     o2           = AudioManager.Instance.oscilator2;
     o3           = AudioManager.Instance.oscilator3;
     o1.gain      = 0.2f;
     o2.gain      = 0.2f;
     o3.gain      = 0.8f;
     o3.frequency = 440.0f;
     do
     {
         pot1Goal = Random.Range(0, 255);
     } while (Mathf.Abs(pot1Goal - animator.GetInteger("pot1")) < minStartDifference);
     do
     {
         pot2Goal = Random.Range(0, 255);
     } while (Mathf.Abs(pot2Goal - animator.GetInteger("pot2")) < minStartDifference);
 }