grame-cncm / faust

Functional programming language for signal processing and sound synthesis
http://faust.grame.fr
Other
2.58k stars 322 forks source link

Unity testing can someone guide me with correct way to interact with plugin? #316

Open cristianvogel opened 5 years ago

cristianvogel commented 5 years ago

Hi. I have succesfully managed to design a plug-in in FAUST and import it as plug-in and component in Unity on MacOS.

But I cannot seem to get a setparamater message from a script. Could someone guide me?

I am pasting just the setup script here, because anyway the NullReferenceException is thrown by Debug.Log(magicalSound.IsInstantiated());

Has anyone managed to control a plug in from a script yet?

using System.Collections.Generic;
using UnityEngine;

public class KeyListener : MonoBehaviour {
    public int counter;
    public int id;
    public float xPos;
    public float yPos;
    public Vector3 pos;
    Rigidbody rb;
    AudioSource aSource;

    FaustPlugin_magicalSound magicalSound;
    Object[] glassStrikes;
    int soundCount;

    // Use this for initialization
    void Start () {
        counter = 1;
        rb = GetComponent<Rigidbody>();
        magicalSound = GetComponent<FaustPlugin_magicalSound>();
        Debug.Log(magicalSound.IsInstantiated()); 

        glassStrikes = Resources.LoadAll("Audio/Glass");
        soundCount = glassStrikes.Length;
        print("sounds size=" + soundCount);
    }
cristianvogel commented 5 years ago

ok , I figured it out and got something working yay!

https://www.dropbox.com/s/qc2ffhs3hn75bc3/MagicalSoundEYe.zip?dl=0

So what is the best way to get parallel ( simultaneous ) voices in the Unity from a FAUST native DSP plugin?

I tried building with faust2unity -osx magicalSound.dsp -nvoices 8 but actually the whole thing broke then, the controls did not show in Unity. So i'm not sure if thats the right way. Is there any documentation on faust2unity?

sletz commented 5 years ago

Look at https://github.com/grame-cncm/faust/tree/master-dev/architecture/unity