From 3e4b264ddb771f7657d6c070599d7c8af3d90f15 Mon Sep 17 00:00:00 2001 From: Davide Morelli Date: Mon, 16 Jan 2006 16:48:18 +0000 Subject: checking in the second example: Counter svn path=/trunk/externals/clr/; revision=4425 --- external/Counter.cs | 52 ++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 52 insertions(+) create mode 100755 external/Counter.cs (limited to 'external/Counter.cs') diff --git a/external/Counter.cs b/external/Counter.cs new file mode 100755 index 0000000..7dc8289 --- /dev/null +++ b/external/Counter.cs @@ -0,0 +1,52 @@ +using System; + +namespace PureData +{ + /// + /// Descrizione di riepilogo per Counter. + /// + public class Counter + { + private IntPtr x; + + int curr = 0; + + public Counter() + { + curr = 0; + } + + public Counter(float f) + { + curr = (int) f; + } + + // this function MUST exist + public void SetUp() + { + pd.AddSelector(x, "init", new pd.DelegateFloat(Init)); + pd.AddSelector(x, new pd.DelegateWithoutArguments(SendOut)); + pd.AddSelector(x, new pd.DelegateFloat(Sum)); + pd.AddInlet(x, "init", ParametersType.Float); + pd.AddOutlet(x, ParametersType.Float); + + } + + public void Init(float f) + { + curr = (int) f; + } + + public void SendOut() + { + pd.SendToOutlet(x, 0, new Atom(curr)); + } + + public void Sum(float f) + { + curr += (int) f; + pd.SendToOutlet(x, 0, new Atom(curr)); + } + + } +} -- cgit v1.2.1