예제 #1
0
 public DotSoundPlayer(DotSoundConfig dotSoundConfig)
 {
     // TODO make this variable per world
     _dotSoundConfig = dotSoundConfig;
     _dotSoundPatch  = UnityPD.OpenPatch("simpleSynth.pd");
     _dotSoundConfig.SendValues();
 }
예제 #2
0
파일: PDTest.cs 프로젝트: fdch/UnityPd
    IEnumerator Start()
    {
        yield return(new WaitForSeconds(1f));

        UnityPD.Init();
        yield return(new WaitForSeconds(2f));

        dotSoundPlayer = new DotSoundPlayer(dotSoundConfig);
    }
예제 #3
0
 public void SwitchToPatch(string patch)
 {
     if (_dotSoundPatch >= 0)
     {
         UnityPD.ClosePatch(_dotSoundPatch);
     }
     _dotSoundPatch = UnityPD.OpenPatch(patch);
     _dotSoundConfig.SendValues();
 }
예제 #4
0
    /// <summary>
    /// Plays the dot connect sound of the 1-index based number of dots in connection
    /// </summary>
    /// <param name="dotsInConnection">Dots in connection.</param>
    public void PlayDotConnectedSound(int dotsInConnection)
    {
        #if UNITY_EDITOR
        _dotSoundConfig.SendValues();
        #endif

        dotsInConnection = PingPongInt(dotsInConnection, _MAX_DOT_SOUND_NOTE);
        int   octaves     = (dotsInConnection - 1) / dotProgressionScale.Length;
        float octaveStart = _DOT_START_FREQ * Mathf.Pow(2, octaves);
        int   scaleNote   = (dotsInConnection - 1) % dotProgressionScale.Length;
        Debug.Log(octaveStart + " " + scaleNote);
        float freq = octaveStart * dotProgressionScale[scaleNote];
        UnityPD.SendFloat("playNote", freq);
    }
예제 #5
0
    public void SendValues()
    {
        UnityPD.SendFloat("setAttack", attack);
        UnityPD.SendFloat("setSustain", sustain);
        UnityPD.SendFloat("setDecay", decay);

        UnityPD.SendFloat("adder-1-vol", adder1Vol);
        UnityPD.SendFloat("adder-1-control-freq-multiply", adder1FreqMultiply);
        UnityPD.SendFloat("adder-1-freq-mod-freq", adder1ModFreq);
        UnityPD.SendFloat("adder-1-freq-mod-amount", adder1ModAmount);

        UnityPD.SendFloat("adder-2-vol", adder2Vol);
        UnityPD.SendFloat("adder-2-control-freq-multiply", adder2FreqMultiply);
        UnityPD.SendFloat("adder-2-freq-mod-freq", adder2ModFreq);
        UnityPD.SendFloat("adder-2-freq-mod-amount", adder2ModAmount);

        UnityPD.SendFloat("lop-cutoff", lopCutoff);
    }
예제 #6
0
    public static void Init()
    {
        if (!_instance)
        {
            _instance = FindObjectOfType <UnityPD>();
            if (!_instance)
            {
                _instance = new GameObject("UnityPD").AddComponent <UnityPD>();
            }
        }

        Logger.Log("Initializing...");
        UnityPd_EnableAudio();

#if UNITY_ANDROID && !UNITY_EDITOR
        CopyPdResourcesToPersistentPath();
#endif

        AddToSearchPath(PdPatchDirectory);
        Logger.Log("...Initialized!");
    }
예제 #7
0
파일: PDTest.cs 프로젝트: fdch/UnityPd
 void OnApplicationQuit()
 {
     UnityPD.Deinit();
 }