New plugin code editor and external lib

Hello
I’d like to know if it’s easy to work with external c# lib with the new code editor …
I’d like to make a plugin to work with irrklang who is a soundengine for game,
there is a c# version of the lib . First i’d like to know if it’s possible to work directly in the code editor , and second what the best way to go , i think i need help for the start to have the basic hello world working , then i can probably manage to continue doing it myself.
I have quicly try to include file and dll in the folder of the plugin , but i’m still not exeprienced enough with c# to make it work.
I’m especially interrested in 3d sound engine with multichannel capabilities.

http://www.ambiera.com/irrklang/

here is a first exemple of the api:
C#

using System;
using IrrKlang;

namespace HelloWorld
{
  class Example
  {
   [STAThread](STAThread)
   static void Main(string[]() args)
   {
     // start up the engine
     ISoundEngine engine = new ISoundEngine();


     // play a sound file
     engine.play2D("../../media/ophelia.mp3");


     // wait until user presses ok to end application

     System.Windows.Forms.MessageBox.Show("Playing, press ok.");

   } // end main()

  } // end class

} // end namespace

http://www.ambiera.com/irrklang/docunet/index.html

hi sanch,
you’ll have to reference the irrklang assembly in your project file.
in order to do that i’d recommend doing the following:

  • add an environment variable called VVVV45 to your system pointing to your vvvv installation.
  • start vvvv, create your new plugin with ctrl+enter from template.
  • go to $(VVVVV45)/plugins/PLUGINNAME, create a new folder Dependencies and copy the irrklang assembly to that location.
  • open the project file (PLUGINNAME.csproj in vvvv/plugins/PLUGINNAME) with either an texteditor or a c# IDE (like sharpdevelop or visual studio) and add your irrklang assembly as reference to the project.
  • you can now either work with the codeeditor or if you need to debug your plugin you can work with your favorite IDE.

Thx for the help , i managed to got the stuff compiling , but didn’ t manage to ouput a sound yet…
here is my code who compile whitout error but don’ t get sound:

ps will be great to be able to include c# in the wiki …

i have try moving arround the ISoundEngine engine = new ISoundEngine(); before the loop with no sucess , and try adding and removing STAThread
but no luck ATM…

- region usings
using System;
using System.ComponentModel.Composition;
using IrrKlang;
using VVVV.PluginInterfaces.V1;
using VVVV.PluginInterfaces.V2;
using VVVV.Utils.VColor;
using VVVV.Utils.VMath;

using VVVV.Core.Logging;
- endregion usings

namespace VVVV.Nodes
{
	#region PluginInfo
	[PluginInfo(Name = "Irrklang", Category = "sound", Version = "1", Help = "Basic template with one value in/out", Tags = "")](PluginInfo(Name = "Irrklang", Category = "sound", Version = "1", Help = "Basic template with one value in/out", Tags = ""))
	#endregion PluginInfo
	public class Irrklang : IPluginEvaluate
	{
		#region fields & pins
		[Input("Input", DefaultString = "hello c#")](Input("Input", DefaultString = "hello c#"))
		ISpread<string> FInput;

		

		[Import()](Import())
		ILogger Flogger;
		#endregion fields & pins
		
        
		    
		//called each frame by vvvv
		public void Evaluate(int SpreadMax)
		{
		    ISoundEngine engine = new ISoundEngine(); 

		    engine.Play2D("C:\test.wav", true);

			
			Flogger.Log(LogType.Debug, "Logging to Renderer (TTY)");
		}
	}
}

this was just for joreg , to show him the code looks bad with the code button… because he don’t believe me ;)

i have attach the plugin file here

Irrklang.zip (2.8 MB)

Hi , with the help of the vvvvdev i manage to have some sound outputed , now i got few other c# newbie problem …

So i manage to have the lib working but now i guess it’s more a c# progrmming problem , i want to make an array of sound object but didn’ t manage to make the right initialisation …
I got the following error :" 08:25:08 ERR : Object reference not set to an instance of an object"
any help apreciated

here is the plugin:

Irrklang.zip (875.9 kB)

Ohhh forget about the last post i did research about c# array and managed it myself…

here is the last version.

It’s like the wave player node , but you got 3d positions in space , also you can play each sound many time it doesn’t stop the sound playing, just create a new one. You can loop , seek position , change speed , pause , change volume , change the distance from where you can hear the sound.
still need to add listenning position , dopler effect , effect , driver selection … but for that i need to create custom pin and to know a bit how it works … any help apreciated again…
thx

btw the update pin is not use atm…

Irrklang.zip (761.0 kB)

what do you mean exactly by custom pin?

well i’d like to create different node for the lib , like filestream > effect > engine …
so i guess i need to create some custom connection?
What is the best approch to do that?

also how can i create differrent node who use the same object?

here is a new version who should really work for you
You need to put the 3 irrklang dll from the plugin irrklang folder in the bin/managed/ folder
and a test file is in the plugin directori.

Irrklang.zip (760.7 kB)

cool, looking forward to try this when i’m back home… :)

Got an nice version with dopler effect
But the node start to be full of pin …
I added an small exemple with ex9 renderer of what can be done.
I would like to add all the effect and other option but thats just too much for one node…
sorry for the messy help patch …
if you use it don’t forget putting the 3 dll from irrklang folder into bin/managed/ folder

Irrklang.zip (835.2 kB)

Couple of quick ones for you:

To output position:
replace:

Flength[i](i) = (FSounds[i](i).PlayLength)/1000;
FCurrentPos[i](i) = (FSounds[i](i).PlayPosition)/1000;

by:

Flength[i](i) = (FSounds[i](i).PlayLength)/1000.0;
FCurrentPos[i](i) = (FSounds[i](i).PlayPosition)/1000.0;

To have the decimals as well :)

Then to create your stream:

ISound sound = FEngine.Play3D(FFile[i](i),(float)FPos[i](i).x,(float)FPos[i](i).y,(float)FPos[i](i).z,FLoop[i](i));
if (sound != null)
{
  FSounds.Add(i,sound);
}
else
{
   //Do something to handle error here
}

As if your engine fails to create the sounds it returns ISound as null,
so you shouldnt add it in your dictionary (You can add ISpread FMessage you notify for example).

Thx Vux
Here is a new version with vux change , tell me if it work on your machine
thx

Irrklang.zip (7.4 MB)

works here :)