Ejemplo n.º 1
0
    // Use this for initialization
    void Start()
    {
        trans_cube = Cube.GetComponent <Transform> ();        //get the transform components

        karplus = GetComponent <FaustPlugin_karplus>();       //instead of declaring public FaustPlugin_karplus karplus;
        //x1 = 0;
        //x1 = 0f;
    }
 // @brief All instantiations have to be done in the OnEnable() method.
 private void OnEnable()
 {
     fJSON = "{	\"name\": \"KarplusStrong\",	\"inputs\": \"0\",	\"outputs\": \"2\",	\"meta\": [ 		{ \"name\": \"KarplusStrong\" },		{ \"description\": \"Simple call of the Karplus-Strong model for the Faust physical modeling library\" },		{ \"license\": \"MIT\" },		{ \"copyright\": \"(c)Romain Michon, CCRMA (Stanford University), GRAME\" },		{ \"signals.lib/name\": \"Faust Signal Routing Library\" },		{ \"signals.lib/version\": \"0.0\" },		{ \"basics.lib/name\": \"Faust Basic Element Library\" },		{ \"basics.lib/version\": \"0.0\" },		{ \"routes.lib/name\": \"Faust Signal Routing Library\" },		{ \"routes.lib/version\": \"0.0\" },		{ \"maths.lib/name\": \"Faust Math Library\" },		{ \"maths.lib/version\": \"2.1\" },		{ \"maths.lib/author\": \"GRAME\" },		{ \"maths.lib/copyright\": \"GRAME\" },		{ \"maths.lib/license\": \"LGPL with exception\" },		{ \"delays.lib/name\": \"Faust Delay Library\" },		{ \"delays.lib/version\": \"0.0\" }	],	\"ui\": [ 		{			\"type\": \"vgroup\",			\"label\": \"karplus\",			\"items\": [ 				{					\"type\": \"hgroup\",					\"label\": \"params\",						\"meta\": [							{ \"0\": \"\" }						],					\"items\": [ 						{							\"type\": \"hslider\",							\"label\": \"freq\",							\"address\": \"/karplus/params/freq\",							\"meta\": [								{ \"0\": \"\" },								{ \"style\": \"knob\" }							],							\"init\": \"440\",							\"min\": \"50\",							\"max\": \"1000\",							\"step\": \"0.01\"						},						{							\"type\": \"hslider\",							\"label\": \"bend\",							\"address\": \"/karplus/params/bend\",							\"meta\": [								{ \"1\": \"\" },								{ \"hidden\": \"1\" },								{ \"midi\": \"pitchwheel\" },								{ \"style\": \"knob\" }							],							\"init\": \"1\",							\"min\": \"0\",							\"max\": \"10\",							\"step\": \"0.01\"						},						{							\"type\": \"hslider\",							\"label\": \"damping\",							\"address\": \"/karplus/params/damping\",							\"meta\": [								{ \"1\": \"\" },								{ \"midi\": \"ctrl 1\" },								{ \"style\": \"knob\" }							],							\"init\": \"0.01\",							\"min\": \"0\",							\"max\": \"1\",							\"step\": \"0.01\"						},						{							\"type\": \"hslider\",							\"label\": \"gain\",							\"address\": \"/karplus/params/gain\",							\"meta\": [								{ \"2\": \"\" },								{ \"style\": \"knob\" }							],							\"init\": \"0.8\",							\"min\": \"0\",							\"max\": \"1\",							\"step\": \"0.01\"						},						{							\"type\": \"hslider\",							\"label\": \"sustain\",							\"address\": \"/karplus/params/sustain\",							\"meta\": [								{ \"3\": \"\" },								{ \"hidden\": \"1\" },								{ \"midi\": \"ctrl 64\" },								{ \"style\": \"knob\" }							],							\"init\": \"0\",							\"min\": \"0\",							\"max\": \"1\",							\"step\": \"1\"						}					]				},				{					\"type\": \"button\",					\"label\": \"gate\",					\"address\": \"/karplus/gate\",					\"meta\": [						{ \"1\": \"\" }					]				}			]		}	]}";
     if (!FaustUI.fJSONParser(ref fJSON, out fUI))               // Parses the JSON file
     {
         UnityEngine.Debug.LogError("Error JSON Parser");
     }
     param = fUI.getUI(0).setNumParams(param);               // Sets the parameter number
     _dsp  = (FaustPlugin_karplus)target;                    // Sets which component will be edited in the inspector
 }