rorywalsh / csoundunity Goto Github PK
View Code? Open in Web Editor NEWLicense: GNU Lesser General Public License v2.1
License: GNU Lesser General Public License v2.1
Currently the WebGL platform audio implementation doesn't support the OnAudioFilterRead callback, so the current implementation of CsoundUnity cannot work on WebGL. Investigate a possible solution for this, since we have Csound running great on the web!
This breaks the Unity VRTK Plugin.
System.Environment.SetEnvironmentVariable("Path", Application.streamingAssetsPath);
We should Append the assets path to the current System.Environment.GetEnvironmentVariable("Path")
Hey there. Sorry for bombarding you all with questions haha. I was messing around and figured a good way to potentially optimize csounds in Unity is to allow varying levels of sample rates so objects which don't necessarily require maximum quality can be reduced but I noticed that in the profiler, when I decrease ksmps and sr in my .CSD file I see that the DSP CPU consumption actually goes up instead of down. I'm assuming that something is set within the CsoundsUnity initialization that hooks into Unity's AudioSource object that may force the sample rate to match Unity's?
I know this is probably beyond the initial scope of this project so I'm mostly looking to be pointed in the right direction as I don't mind mucking around with the source to get this working if it is currently not possible.
Tested in Unity 2021.2.18f1 (Windows 10). Created a fresh project and went through all release versions from 3.0+. Starting at version 3.2.0, launching play mode on the BasicTest example scenes causes the Unity Editor to crash to desktop
Csound has opcodes that can handle spatialization and 3D audio.
Develop a plugin for Unity that takes advantage of that, using native audio code.
https://docs.unity3d.com/Manual/AudioMixerNativeAudioPlugin.html
When importing the package from the master branch, the docs folder causes lots of errors in the console.
These can be ignored and don't cause any issue, but we should get rid of them.
When playing a scene with a CsoundUnity component, the Toolbar disappears.
It can be restored by stopping the scene (CTRL+P) and playing it again.
Already raised a Unity issue.
Hey there. Was just curious, am currently trying to pass an array of strings to a csound string channel from Unity and was curious if this is possible? I see that there are chnget and chnset opcodes that support arrays but don't see anything in the Csound6.NativeMethods portion of the code. Was curious if this is currently possible or if there is a way to simply pass each individual element and reliably update on the csounds side. Was attempting to check if an S variable had changed and if it had to add the new value to an array on the csound side, but this is proving more difficult than I had as anticipated. Not sure if the changed opcode is very reliable for strings and can't find much information online. Any insight you have would be greatly appreciated. Thanks!
After playing a scene with a CsoundUnity instance, drag&drop in the Unity Editor stops working.
Restarting the Editor fixes it.
Not reproduced on MacOS (any version).
Reproduced with all Unity versions on Windows with Csound v6.18 and v6.17
Unity only recieves audio correctly on the left channel from Csounds audio buffer. The right channel is distorted. There is no increase in amplitude on the right channel.
If I set Unitys Audio Settings from STEREO to MONO no distortion occurs as I am only listening to the left channel.
I tried the csd-file I'm using with a mono and a stereo output. The ksmps value is set to 32.
I'm using the latest development version of Csound Unity.
It would be nice being able to morph between two (or more) presets
https://github.com/rorywalsh/CsoundUnity/blob/master/CsoundUnityScripts/CsoundUnity.cs#L80-L86
I'm not sure what is supposed to be here but I saw this looking through the source code for the project.
UIElements are more performant than IMGUI, with the current Editor implementation there is a high CPU usage when using a csd with lots of Cabbage widgets.
Rewrite the CsoundUnity editor to use the UIElements, instead of IMGUI
Hi, i'm trying to use the opcode ftgen to open a wav file in the directory CsoundFiles locate in the scripts folder, if i try to run the script without Unity it works fine, but when i run it on unity Csound log tells me that he can't open the wave file.
Thank you
Hello,
Just tried installing the latest (3.3.0) in Unity 2020.3.32 on Windows 10 and I get this error: Library\PackageCache\com.csound.csoundunity@058320a\Editor\CsoundUnityEditor.cs(403,27): error CS0117: 'EditorGUI' does not contain a definition for 'LinkButton'
Thank you for this package, I can not wait to get started with it.
Nathan
On windows, I get this error with csound unity installed:
Library\PackageCache\com.csound.csoundunity@876b530\Editor\CsoundUnityPostProcessBuild.cs(5,19): error CS0234: The type or namespace name 'iOS' does not exist in the namespace 'UnityEditor' (are you missing an assembly reference?)
I am guessing it needs a macro to check if Unity has IOS build support installed as it does not seem this is included in Unity's windows build support.
Hey, I've been trying to get a wav file as an output from my CsoundUnity class. I've been using this example:
-o output.wav ;Example by Alex Hofmann instr 1 aSin poscil 0dbfs/4, 440 out aSin endin i 1 0 1Sadly, an audio file never appears in any environment folder.
Could you help me?
In Unity 2021.2 click and drag support of any assets ceases to work after csound unity is run. It is resolved with a restart of the editor.
Greetings. So I'm running into an occasional issue when exiting play mode where the audio being outputted by csounds will "stutter" (repeat the last probably 0.5 a second, similar to CD skipping essentially) when exiting play mode. I'm assuming this is due to something not being cleaned up properly. My initial thought was to edit CsoundUnity and to add a SetChannel call to trigger an instrument that looks like so:
instr DISABLE_ALL_INSTRUMENTS
prints "DISABLE ALL INSTRUMENTS TRIGGER ENABLED"
kDisableAll chnget "TURNOFFALL"
if changed(kDisableAll)==1 then
kindx = 1
while kindx < 7 do
turnoff2 kindx, 0, 0
kindx += 1
od
endif
endin
and this is the call being made from the Unity side:
private void OnApplicationQuit()
{
if (LoggingCoroutine != null)
StopCoroutine(LoggingCoroutine);
if (csound != null)
{
csound.SetChannel("TURNOFFALL", 1.0);
csound.OnApplicationQuit();
}
}
There are 6 instruments total (named 1-6) so it calls turnoff2 on each of them. This didn't seem to resolve the issue but I'm guessing I may need a way to verify that each instrument has actually been disabled on the Unity side before executing the csound.OnApplicationQuit() line? I'm dynamically creating these instruments and passing them their desired output channels (which route to run another) at init/runtime so I'm guessing that something that's expected to exist is being cleared out mid processing (as I think this would explain the audio stutter/skipping on exit).
Any thoughts/insights you have would be greatly appreciated. Thanks so much.
Hi,
A heads-up that Unity crashes on play with the v3.4.0 package. I'm on Windows 10 and tested with Unity 2019.4.35 and Unity 2022.3.10. I tried installing the package from disk and by directly loading from Git in the package manager with the same result. The package v3.3.1 is working correctly for me (installing from disk).
@all-contributors please add ceberman for Code
Csound unity is causing Unity to crash on start when on Windows. I think this is a somewhat new development as a version I have from about a month ago seems to work fine.
Obtained 34 stack frames
0x00007ffbe0aa6d0c (csound64) csoundGetLibrarySymbol
0x00007ffbe095801c (csound64) csoundReset
0x00007ffbe0956d72 (csound64) csoundCreate
0x000001cfba46874a (Mono JIT Code) (wrapper managed-to-native) csoundcsharp.Csound6/NativeMethods:csoundCreate (intptr)
0x000001cfba467aab (Mono JIT Code) [CsoundUnityBridge.cs:136] CsoundUnityBridge:.ctor (string,System.Collections.Generic.List`1)
0x000001cfba46559b (Mono JIT Code) [CsoundUnity.cs:492] CsoundUnity:Awake ()
0x000001d0a1469c08 (Mono JIT Code) (wrapper runtime-invoke) object:runtime_invoke_void__this__ (object,intptr,intptr,intptr)
0x00007ffbde34e034 (mono-2.0-bdwgc) [mini-runtime.c:3445] mono_jit_runtime_invoke
0x00007ffbde28e724 (mono-2.0-bdwgc) [object.c:3064] do_runtime_invoke
0x00007ffbde28e8bc (mono-2.0-bdwgc) [object.c:3111] mono_runtime_invoke
0x00007ff71cc45b04 (Unity) scripting_method_invoke
0x00007ff71cc40724 (Unity) ScriptingInvocation::Invoke
0x00007ff71cc4080e (Unity) ScriptingInvocation::InvokeChecked
0x00007ff71ccb9c46 (Unity) SerializableManagedRef::CallMethod
0x00007ff71cc0df34 (Unity) MonoBehaviour::CallAwake
0x00007ff71cc0c7f5 (Unity) MonoBehaviour::AddToManager
0x00007ff71cc0d171 (Unity) MonoBehaviour::AwakeFromLoad
0x00007ff71ccfac5f (Unity) AwakeFromLoadQueue::InvokePersistentManagerAwake
0x00007ff71ccfb6cc (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007ff71ccfb833 (Unity) AwakeFromLoadQueue::PersistentManagerAwakeFromLoad
0x00007ff71c94e528 (Unity) LoadSceneOperation::CompleteAwakeSequence
0x00007ff71c94ef92 (Unity) LoadSceneOperation::CompletePreloadManagerLoadSceneEditor
0x00007ff71c94fb3b (Unity) LoadSceneOperation::IntegrateMainThread
0x00007ff71c953731 (Unity) PreloadManager::UpdatePreloadingSingleStep
0x00007ff71c953d0f (Unity) PreloadManager::WaitForAllAsyncOperationsToComplete
0x00007ff71db10202 (Unity) EditorSceneManager::RestoreSceneBackups
0x00007ff71d82d085 (Unity) PlayerLoopController::EnterPlayMode
0x00007ff71d83c3fa (Unity) PlayerLoopController::SetIsPlaying
0x00007ff71d83f71d (Unity) Application::TickTimer
0x00007ff71dc7cf2a (Unity) MainMessageLoop
0x00007ff71dc817fb (Unity) WinMain
0x00007ff71ef9398e (Unity) __scrt_common_main_seh
0x00007ffc72835550 (KERNEL32) BaseThreadInitThunk
0x00007ffc73a4485b (ntdll) RtlUserThreadStart
Hi!
When using Unity 2018.2.14f1 and calling the setInputSample()
method (which in turn calls setCsoundInputSample()
), Unity can no longer find the CsoundUnityNativePlugin.dll with the relative path specified. I assume this was a change in some version, but the solution is to take out the path and simply qualify that .dll file the same way you qualify the csound64.dll file, just with it's name.
internal const string _dllVersionCsUnity = "CsoundUnityNativePlugin.dll";
Related with #47
Hello, I am very excited by the possibility of using Csound in my Unity3D projects. Recently I have run into an issue where Unity3D crashes when I issue the first event call to Csound. I have been successful at putting Csound into a couple of other projects but in this case drastic things happen whenever I try to use Csound. The event call issued is:
csoundUnity.sendScoreEvent ("i 2 0 3600");
This is after a couple of setChannel calls:
csoundUnity.setChannel("kcents", pitchInCents);
csoundUnity.setChannel ("amplitude", 1.0f * volumeFactor);
I removed the sendScoreEvent call and Unity still crashed. I have removed the CsoundUnity
Most of the time there is no crash log, although once I did receive it and noticed that a pointer was being freed that was uninitialized.
I am using Unity 5.6.1f1 on a Mac running 10.12.6
I am including the csound file. Please let me know if there is anything I can do further to help get at the problem.
Thank you!
The skew is what controls how much the curve of the slider is linear / exponential.
Currently the editor sliders always behave in a linear way, not taking into account the skew value set in the Cabbage widget.
Unity Crashes every time I try to run the scene with the csoundunity component. Is there a version of Unity that might work better?
The Csound MacOS bundle is currently 64bit only, this means that building a CsoundUnity project for Intel 64 bit+ Apple Silicon won't copy the bundle in the exported app.
The Csound bundle will work on an Intel Unity editor; building for Intel 64 bit only will produce a MacOS .app with the Csound bundle in the Plugins folder, and this app will work on Silicon Macs too.
This limitation will be in place until a version of Csound for Apple Silicon processors is built.
Investigate a good and easy to use implementation to set the channels of a CsoundUnity instance on a Unity Timeline track.
Using the TimelinePlayableWizard found in the Default Playables package it's easy to create the needed classes.
See this pull request #32
This is a nice feature that we should support, but still there are some little issues in the pull request to be resolved.
Hi.
Thanks for this package
I would like to be able to access the package through openUPM. This takes the release from the GitHub repo and makes them available through a scoped registry - thus making dependency management and version control easier.
There is only one requirement - the tag included in the package has to be semver compliant and they are not at the moment - i.e v3.0.0 or v3.0.1 as opposed to v3.0.
Would it be possible to create a v3.0.1 release in GH and to use semver tags going forward?
In both Unity 5.3.4 on Windows and Unity 5.3.5 on Mac I'm having issues with having audio only playing on one channel, the left side only. I downloaded and imported the 2.0 packages for each operating system respectively.
I'm not sure if it is printing both channels to mono and playing only on the left side or if it is stereo minus the right channel. I tried changing the Unity Audio Source's spatial blend to 3D to no avail.
Testing the csound file in Cabbage it works completely fine with audio on both channels.
It would be nice being able to apply a Csound based effect to an existing AudioSource.
It requires the development of a native plugin.
Effects to be implemented could include:
https://docs.unity3d.com/Manual/AudioMixerNativeAudioPlugin.html
I want to control aspects of my .csd file through Csounds channel system in realtime.
However, Unity keeps telling me that there is a NullReferenceException either in the CsoundUnity.cs file or in my PlayerController.cs script.
Unity refers to the following lines of code in the CsoundUnity.cs file (from line 690):
public void SetChannel(string channel, MYFLT val)
{
csound.SetChannel(channel, val);
}
If Unity doesn't refer to that, it refers to the my following code in my Awake() function of my PlayerController.cs script:
private void Awake()
{
[...] // player controller script
csound = GetComponent<CsoundUnity>();
csound.SetChannel("notelength", notelength);
}
This results in not being able to move my player.
If I remove my attempts of sending data to Csound I can move my player and everything is fine.
My .csd file and my PlayerController.cs script are attached to my player.
Any idea how to fix this?
The increment is what controls the minimum increase/decrease when moving the slider, meaning that it will snap to values multiple of the increment.
Related with #37
Ableton Link isn't supported out of the box so how do I add it to CsoundUnity?
https://github.com/csound/plugins
Hi everyone,
whenever I attach a Csound Unity (Script) and an Audio Source component on an object in Unity I get an extremely distorted and loud sound when I start Play Mode. Added to that I get the following message in the console:
could not open library 'C:/Users/[...]/[...]/Assets/StreamingAssets\CsoundUnityNative.dll' (-1)
The Csound file itself plays fine in CsoundQt.
Any ideas how to fix this?
I tried different audio settings and different unity versions, but nothing here solves my problem.
Release is a process that involves several actions that can be possibly automated:
hi i'm trying to use the sendscoreevent function, but it doesn't work, i try to send an event in score every time i there is a collision, but csound log tell me that Score finished in csoundPerformKsmps() and i don't listen anything.
I've also noticed that when I instantiate an object with a sound attached to it, after a few seconds a distorted high pitched sound occurs, what can i do?
Thank you
Related with #46
CsoundUnity is missing an easy to use sample player that allows for time and frequency-independent scaling.
this is more than likely a user error on my part, but i cannot get sound out of the CsoundUnity project demos on my mac running Unity 5.5.1. first error that comes up:
DllNotFoundException: /Assets/StreamingAssets/CsoundLib64.framework/CsoundLib64
CsoundUnityBridge..ctor (System.String csoundDir, System.String csdFile) (at Assets/Scripts/CsoundUnityScripts/CsoundUnityBridge.cs:49)
CsoundUnity.Awake () (at Assets/Scripts/CsoundUnityScripts/CsoundUnity.cs:105)
path appears to be correct. DLL is residing at Assets/StreamingAssets/CSoundLib64.framework
any clues? seem like a path issue, really. would love to try out CSound in Unity. thanks!
This is more of a question than an issue, but is it possible to import the Csound Plugin Opcodes available here to use with the Csound Unity package or would this require some extensive modification to get working? I saw on a forum thread that you were considering including this in Csound 7.0 release but would like to use sooner if possible.
Thanks in advance :D
@all-contributors please add @NPatch for code
Workaround for now is setting the Doppler Level to 0, but that disables the effect completely.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.