aboutsummaryrefslogtreecommitdiff
path: root/external
diff options
context:
space:
mode:
Diffstat (limited to 'external')
-rwxr-xr-xexternal/External.cs43
-rwxr-xr-xexternal/external.csproj12
-rwxr-xr-xexternal/pd.cs172
3 files changed, 38 insertions, 189 deletions
diff --git a/external/External.cs b/external/External.cs
index 820c7ca..ace63a3 100755
--- a/external/External.cs
+++ b/external/External.cs
@@ -1,11 +1,8 @@
using System;
-
namespace PureData
{
-
-
public class External
{
private IntPtr x;
@@ -15,8 +12,6 @@ namespace PureData
x = IntPtr.Zero;
}
-
-
// this function MUST exist
public void SetUp(IntPtr pdClass)
{
@@ -31,16 +26,36 @@ namespace PureData
pd.AddSelector(x, "selFloat", "SelFloat", ParametersType.Float);
pd.AddSelector(x, "selString", "SelString", ParametersType.Symbol);
pd.AddSelector(x, "selGenericList", "SelGenericList", ParametersType.List);
+
+ pd.AddSelector(x, "", "GetBang", ParametersType.Bang);
+ pd.AddSelector(x, "", "GetFloat", ParametersType.Float);
+ pd.AddSelector(x, "", "GetSymbol", ParametersType.Symbol);
+
Console.WriteLine("selectors set");
pd.AddOutlet(x, ParametersType.Float);
pd.AddInlet(x, "selFloat", ParametersType.Float);
}
+ public void GetBang()
+ {
+ pd.PostMessage("GetBang invoked!");
+ }
-
+ public void GetFloat(float f)
+ {
+ pd.PostMessage("GetFloat invoked with " + f);
+ }
+
+ public void GetSymbol(ref string s)
+ {
+ pd.PostMessage("GetSymbol invoked with " + s);
+ }
+
public void Sel1()
{
pd.PostMessage("Sel1 invoked!");
+ Atom [] a= new Atom[2];
+
}
public void Sel2()
@@ -48,10 +63,12 @@ namespace PureData
pd.PostMessage("Sel2 invoked!");
// testing outlets
- Atom[] atoms = new Atom[2];
- atoms[0] = new Atom("ciao");
- atoms[1] = new Atom(1.5f);
- pd.ToOutlet(x, 0, atoms.Length, atoms);
+ Atom[] atoms = new Atom[4];
+ atoms[0] = new Atom(1.5f);
+ atoms[1] = new Atom("ciao");
+ atoms[2] = new Atom(2.5f);
+ atoms[3] = new Atom("hello");
+ pd.SendToOutlet(x, 0, atoms);
}
@@ -69,6 +86,7 @@ namespace PureData
public void SelGenericList(Atom [] list)
{
+ Atom [] ret = new Atom[list.Length];
for (int i = 0; i<list.Length; i++)
{
Atom a = (Atom) list[i];
@@ -82,15 +100,18 @@ namespace PureData
case (AtomType.Float):
{
pd.PostMessage("" + a.float_value);
+ ret[i] = new Atom(a.float_value * 2);
break;
}
case (AtomType.Symbol):
{
+ ret[i] = new Atom(a.string_value + "-lo-giuro");
pd.PostMessage(a.string_value);
break;
}
}
- }
+ }
+ pd.SendToOutlet(x, 0, ret);
}
diff --git a/external/external.csproj b/external/external.csproj
index 417f6aa..536e73d 100755
--- a/external/external.csproj
+++ b/external/external.csproj
@@ -9,7 +9,7 @@
<Settings
ApplicationIcon = ""
AssemblyKeyContainerName = ""
- AssemblyName = "PureData"
+ AssemblyName = "External"
AssemblyOriginatorKeyFile = ""
DefaultClientScript = "JScript"
DefaultHTMLPageLayout = "Grid"
@@ -79,6 +79,11 @@
AssemblyName = "System.Xml"
HintPath = "..\..\..\..\..\WINDOWS\Microsoft.NET\Framework\v1.1.4322\System.XML.dll"
/>
+ <Reference
+ Name = "PureData"
+ AssemblyName = "PureData"
+ HintPath = "PureData.dll"
+ />
</References>
</Build>
<Files>
@@ -93,11 +98,6 @@
SubType = "Code"
BuildAction = "Compile"
/>
- <File
- RelPath = "pd.cs"
- SubType = "Code"
- BuildAction = "Compile"
- />
</Include>
</Files>
</CSHARP>
diff --git a/external/pd.cs b/external/pd.cs
deleted file mode 100755
index 87478ae..0000000
--- a/external/pd.cs
+++ /dev/null
@@ -1,172 +0,0 @@
-using System;
-using System.Runtime.CompilerServices; // for extern import
-using System.Runtime.InteropServices; // for structures
-
-
-namespace PureData
-{
- public enum ParametersType {None = 0, Float=1, Symbol=2, List=3};
-
- public class pd
- {
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern static void RegisterSelector (IntPtr x, string sel, string met, int type);
- // function called by the user
- public static void AddSelector(IntPtr x, string sel, string met, ParametersType type)
- {
- RegisterSelector (x, sel, met, (int) type);
- }
-
- // TODO
- // send stuff to an outlet
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void ToOutlet (IntPtr x, int outlet, int atoms_length, [In, Out] Atom [] atoms);
- public static void SendToOutlet (IntPtr x, int outlet, [In, Out] Atom [] atoms)
- {
- ToOutlet (x, outlet, atoms.Length, atoms);
- }
-
- // create an outlet
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern static void CreateOutlet (IntPtr x, int type);
- // function called by the user
- public static void AddOutlet(IntPtr x, ParametersType type)
- {
- CreateOutlet (x, (int) type);
- }
-
- // create an inlet
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- private extern static void CreateInlet (IntPtr x, string selector, int type);
- // function called by the user
- public static void AddInlet(IntPtr x, string selector, ParametersType type)
- {
- CreateInlet (x, selector, (int) type);
- }
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void PostMessage (string message);
-
- [MethodImplAttribute (MethodImplOptions.InternalCall)]
- public extern static void ErrorMessage (string message);
-
-
- /*
- // simplyfied atom
- typedef struct atom_simple atom_simple;
- typedef enum
- {
- A_S_NULL=0,
- A_S_FLOAT=1,
- A_S_SYMBOL=2,
- } t_atomtype_simple;
- typedef struct atom_simple
- {
- t_atomtype_simple a_type;
- union{
- float float_value;
- MonoString *string_value;
- } stuff;
- };
- */
- }
- public enum AtomType {Null = 0, Float=1, Symbol=2, List=3};
-
- //[StructLayout (LayoutKind.Explicit)]
- [StructLayout (LayoutKind.Sequential)]
- public struct Atom
- {
- public AtomType type;
- public float float_value;
- public string string_value;
- public Atom(float f)
- {
- this.type = AtomType.Float;
- this.float_value = f;
- this.string_value = "float";
- }
- public Atom(string s)
- {
- this.type = AtomType.Symbol;
- this.float_value = 0;
- this.string_value = s;
- }
- }
-
- /*
- typedef float t_floatarg;
-
- typedef struct _symbol
- {
- char *s_name;
- struct _class **s_thing;
- struct _symbol *s_next;
- } t_symbol;
-
- EXTERN_STRUCT _array;
- #define t_array struct _array
-
-
-
- #define GP_NONE 0
- #define GP_GLIST 1
- #define GP_ARRAY 2
-
- typedef struct _gstub
- {
- union
- {
- struct _glist *gs_glist;
- struct _array *gs_array;
- } gs_un;
- int gs_which;
- int gs_refcount;
- } t_gstub;
-
- typedef struct _gpointer
- {
- union
- {
- struct _scalar *gp_scalar;
- union word *gp_w;
- } gp_un;
- int gp_valid;
- t_gstub *gp_stub;
- } t_gpointer;
-
- typedef union word
- {
- t_float w_float;
- t_symbol *w_symbol;
- t_gpointer *w_gpointer;
- t_array *w_array;
- struct _glist *w_list;
- int w_index;
- } t_word;
-
- typedef enum
- {
- A_NULL,
- A_FLOAT,
- A_SYMBOL,
- A_POINTER,
- A_SEMI,
- A_COMMA,
- A_DEFFLOAT,
- A_DEFSYM,
- A_DOLLAR,
- A_DOLLSYM,
- A_GIMME,
- A_CANT
- } t_atomtype;
-
- #define A_DEFSYMBOL A_DEFSYM
-
- typedef struct _atom
- {
- t_atomtype a_type;
- union word a_w;
- } t_atom;
- */
-
-}