aboutsummaryrefslogtreecommitdiff
path: root/external/Counter.cs
diff options
context:
space:
mode:
Diffstat (limited to 'external/Counter.cs')
-rwxr-xr-xexternal/Counter.cs52
1 files changed, 52 insertions, 0 deletions
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
+{
+ /// <summary>
+ /// Descrizione di riepilogo per Counter.
+ /// </summary>
+ 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));
+ }
+
+ }
+}