heavy icon indicating copy to clipboard operation
heavy copied to clipboard

Unity > Heavy > PD >Heavy >Unity

Open storey89 opened this issue 8 years ago • 11 comments

Hi, I'm working on my 1st software communication project between Unity & PD. I found a tutorial on You Tube that I thought would be helpful. But the video is almost a year old and possibly dated. The video came with some sample code and how to get the code to function with unity. How ever the code that was supplied has various errors. one or two I solved but the rest I've no idea.

The 1st problem I have discovered with this code is on line 6 Hv_Test_1_LibWrapper HeavyScript; instead it should read Hv_Test_1_audioLib HeavyScript;.

Secondly after i solve this error HeavyScript.SendBangToReceiver ("onOff"); HeavyScript.SendBangToReceiver ("waveToggle");

These heavy scripts aren't recognised by the code supplied from heavy.

Can anyone help me please?

screen shot 2017-02-10 at 12 20 37

storey89 avatar Feb 10 '17 12:02 storey89

They there @storey89. Have you looked at our Unity documentation yet? It goes over how to create Unity plugins and hook them up to objects (for Audio Libraries).

mhroth avatar Feb 10 '17 13:02 mhroth

Hi, I have been looking through the documentation. To gain some knowledge of what the code does. However I've used the code from the heavy website and it returns an error to me. I want to expose and send an event. However when I run the code supplied. It states that send event has "no extension method" with in my hv_example_audiolib.

I've searched through hv_example_audiolib to see if i could find the corresponding code for send event. But I was unable. I thought that maybe sendevent may be incorrect and tried a title from the hv_example_audiolib that I though might work such as SendBandToReceiver, but this returned a similar error. I apologise as I am a newbie to this.

Also not that I'm no longer using the code from the above pic.

storey89 avatar Feb 11 '17 13:02 storey89

Hi, I think the problem I'm not understanding from the code for events & Parameters is script.SendEvent script.GetFloatParameter script.SetFloatParameter

In each of these cases they return an error related to the .type (If this is the correct term) Assets/Scripts/Pure_Data.cs(21,24): error CS1061: Type Hv_final_01_AudioLib' does not contain a definition for SendEvent' and no extension method SendEvent' of type Hv_final_01_AudioLib' could be found (are you missing a using directive or an assembly reference?)

Does this mean that in the File supplied from the Heavy site itself should have these types in its script or am I missing something in front of me??

storey89 avatar Feb 12 '17 14:02 storey89

Hi @storey89 to be to be clear are you exposing the parameters and events from within the Pd patch?

A Pd receiver object [r param1 @hv_param 0 1 0.5] will be exposed as a parameter in heavy, so you can use the Get/Set methods in the AudioLib.cs wrapper.

If you add [r event1 @hv_event] that receiver will be exposed as an event, and will be sent bang messages if you call SendEventor click on the relative button in the Unity Inspector interface for the script.

The docs here go into more detail: https://enzienaudio.com/docs/index.html#02.getting_started#exposing-parameters

diplojocus avatar Feb 12 '17 17:02 diplojocus

Hi diplojocus, I have my pd patch set like this (see attached). I've used the code that your site has provided from the getting started and getting started with Unity pages.

If I just use the code from the heavy download. When press play in Unity I can hear the test sound I created in PD. But when I try to expose the parameters or Events the code doesn't recognise the code form heavy.

Final_.01.zip

screen shot 2017-02-12 at 18 09 11

storey89 avatar Feb 12 '17 18:02 storey89

@storey89 I looked at your project but I wasn't sure which patch you were testing with. The _main.pd in the top-level directory throws an error when you compiling it in heavy --> Conflicting min/max/default values for 'freq' parameter. There are two instances of the [r freq @hv_param] object, where you usually only need one.

diplojocus avatar Feb 13 '17 05:02 diplojocus

Diplodocus, I've edited my PD patch so that there is only one event & freq receive object and uploaded it to my heavy folder. There doesn't seem to be any errors now. However when I return to Unity I have the same problem with the script / wrapper.

Also I'm wondering should I be able to see the effects from heavy in realtime within PD?

Final_.01.zip

storey89 avatar Feb 13 '17 08:02 storey89

Can you send me a link to your patch on the heavy site?

Are you sure you're replacing all the files you download from the site into your Unity project?

diplojocus avatar Feb 13 '17 09:02 diplojocus

Here it is https://enzienaudio.com/h/storey89/final_01/

I've been working with the unity osx64 zip and that I've brought the bundle files from the zip folder into my plugins folder within Unity. along with the hv_example_auidolib file

storey89 avatar Feb 13 '17 09:02 storey89

I've re-uploaded the files again to heavy and downloaded the updated version of the mac OS X. I seems to have done the trick. But I've another question. Every time I edit my PD patch. I will have to upload to heavy then download an updated version of the mac zip to be reimported to unity?

Thank you for your patience and help. Much appreciated.

storey89 avatar Feb 15 '17 20:02 storey89

But I've another question. Every time I edit my PD patch. I will have to upload to heavy then download an updated version of the mac zip to be reimported to unity?

Yes, you'll also have to restart Unity as it won't release the dll/bundle file after it's launched. The Fabric target negates that issue currently.

diplojocus avatar Feb 15 '17 20:02 diplojocus