aboutsummaryrefslogtreecommitdiff
path: root/src/java/com/cycling74/msp/MSPSignal.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/java/com/cycling74/msp/MSPSignal.java')
-rw-r--r--src/java/com/cycling74/msp/MSPSignal.java70
1 files changed, 70 insertions, 0 deletions
diff --git a/src/java/com/cycling74/msp/MSPSignal.java b/src/java/com/cycling74/msp/MSPSignal.java
new file mode 100644
index 0000000..0fb9635
--- /dev/null
+++ b/src/java/com/cycling74/msp/MSPSignal.java
@@ -0,0 +1,70 @@
+package com.cycling74.msp;
+
+/**
+ * Signals representation; signals inlets will copy signal data to this
+ * object.
+ */
+public class MSPSignal {
+
+ /**
+ * Tells the number of time this signal is connected. This is always
+ * 1 in pure-data.
+ */
+ public short cc = 1;
+
+ /**
+ * Tells if this signal is connected. This is always true in pure-data.
+ */
+ public boolean connected = true;
+
+ /**
+ * Number of sample in vector.
+ */
+ public int n;
+
+ /**
+ * The sampling rate.
+ */
+ public double sr;
+
+ /**
+ * The current sample data.
+ */
+ public float[] vec;
+
+ MSPSignal() {
+ }
+
+ public MSPSignal(float vec[], double sr, int n, short cc) {
+ this.vec = vec;
+ this.sr = sr;
+ this.n = n;
+ this.cc = cc;
+ }
+
+ /**
+ * Returns a copy of this signal but with the same sample buffer.
+ * @return the new signal with the same buffer
+ */
+ public MSPSignal alias() {
+ return new MSPSignal(vec, sr, n, cc);
+ }
+
+ /**
+ * Returns the a duplicated signal object. Also copies the array.
+ * @return the new signal with the same value
+ */
+ public MSPSignal dup() {
+ return new MSPSignal((float [])vec.clone(), sr, n, cc);
+ }
+
+ /**
+ * Returns the a duplicated signal object, but the sample vector is
+ * re-initialized.
+ * @return the new signal with empty value (silence)
+ */
+ public MSPSignal dupclean() {
+ return new MSPSignal(new float [vec.length], sr, n, cc);
+ }
+
+}