enzienaudio / heavy

heavy public issue tracker and static dsp code releases
https://enzienaudio.com
ISC License
71 stars 4 forks source link

SendBangToReceiver definition not found - unity? #149

Open Latimark opened 7 years ago

Latimark commented 7 years ago

Hi, I'm just working on my first project in Unity and I've been looking up tutorials here and there. I was wondering under what circumstances it's possible to use the heavyscript.SendBangToReceiver("receivername"); ? Currently, I've set a float to change an osc frequency for an engine sound but since I forgot to add a t f b, the patch isn't updating the sound when the speed changes (despite the inspector on the unity plugin showing a change in frequency). When I click on the inspector's slider however, the sound updates (i'm assuming it sends a bang?). Anyways, how can I just get a simple bang to send in my update function.?

diplojocus commented 7 years ago

hi @Latimark which release are you testing with?

Have you looked at the @hv_event descriptor you can add to receivers for a bang interface to your patch? See these links for more info:

https://enzienaudio.com/docs/index.html#02.getting_started#exposing-events

https://enzienaudio.com/docs/index.html#05.unity#exposing-and-sending-events

Latimark commented 7 years ago

damn ok thanks. can i expose events as well as parameters on the same inlet ?

diplojocus commented 7 years ago

Hmmm interesting, I guess I purposely chose to create separate interfaces for these. With the current system I believe it will only let you have one (although I haven't tried).

You use @hv_param and add a [t b] to the receiver outlet to create bangs. You'll get a bang everytime the parameter changes.

diplojocus commented 7 years ago

Out of curiosity what's your use case?

Latimark commented 7 years ago

Hmm, what could be causing my patch to update a change in frequency only when i move the slider in the inspector with the mouse, but not when I change the parameter with a script? I've added t f b in my pd patch....it's for a typical engine sound script where i'm associating the speed of the player object to the frequency of an osc in a patch. I can share my code if you want, it's pretty basic.

Latimark commented 7 years ago

ok i noticed some more strange behavior. the sound actually updates when the value reaches either the min or the max (to the min and max) but then nothing the rest of the time.

Latimark commented 7 years ago

hm it seems i was using script.param = float rather than the script.SetParamater(Hv_script_Lib.parameter, float) and it works properly when i switched. (i saw this in a youtube tutorial oO)

Latimark commented 7 years ago

Hey alright so I have another question. I've created a script that I want to attach to a game object and rely on unity's built in 3d settings. But, I want to have many instances of this script, which rely on separate 3d positions. And they're be running simultaneously and I'll be sending different values to them also simultaneously. also, it needs to be cross platform.

My question is in regards to file management. What needs to be done/what's the best way of doing it? Do I need to copy paste the script and rename it for every instance? What files need to be renamed? What's the best way of setting up a project for OSX and Win64 simultaneously? I know that a lot of my scripts that reference heavy scripts have to have the heavy script dragged into the inspector...do I have to do this separately for OSX and Win? Would it be better to just duplicate my project ? hmm

diplojocus commented 7 years ago

@Latimark the SetParameter and GetParameter methods are the recommended way to access and modify exposed parameters from the patch.

My question is in regards to file management. What needs to be done/what's the best way of doing it? Do I need to copy paste the script and rename it for every instance? What files need to be renamed? What's the best way of setting up a project for OSX and Win64 simultaneously? I know that a lot of my scripts that reference heavy scripts have to have the heavy script dragged into the inspector...do I have to do this separately for OSX and Win? Would it be better to just duplicate my project ? hmm

Every instance of the Hv_*_AudioLib gameObject can be represented by the same C# script. You don't need to copy/paste/rename. Just drag it onto another gameObject in your scene.

For cross-platform projects you can download the platform specific binaries i.e. win, macos, etc... and place them in a Plugins folder. Sometimes you might need to tell Unity which platform each binary is used on.

Note: you only need one set of the C# files for each patch you're working with. The scripts generated by the Unity OSX and Unity Win 64bit targets will be identical.