Permalink
Browse files

Comments and documentation

  • Loading branch information...
jacobjoaquin committed Aug 11, 2010
1 parent 8beeada commit 76a0eb7c6ad663f6a0c87c9ed2c5c7364380a03c
Showing with 94 additions and 44 deletions.
  1. +94 −44 src/csoundo/Csoundo.java
View
@@ -1,5 +1,5 @@
/**
- * you can put a one sentence description of your library here.
+ * A Csound interface library for Processing.
*
* ##copyright##
*
@@ -28,20 +28,12 @@
import processing.core.*;
import csnd.*;
+
/**
- * This is a template class and can be used to start a new processing library or tool.
- * Make sure you rename this class as well as the name of the example package 'template'
- * to your own lobrary or tool naming convention.
- *
- *
- * (the tag @example followed by the name of an example included in folder 'examples' will
- * automatically include the example in the javadoc.)
- *
- *
+ * @example chnInOut
*/
-
public class Csoundo {
PApplet myParent;
public final static String VERSION = "##version##";
@@ -50,13 +42,12 @@
private String csd;
public boolean isRunning = false;
- public CsoundPerformanceThread cpThread;
+ public CsoundPerformanceThread perfThread;
/**
- * a Constructor, usually called in the setup() method in your sketch to
- * initialize and start the library.
+ * The Csoundo onstructor, usually called in the setup() method in your
+ * sketch to initialize and start the library.
*
- * @example Hello
* @param theParent
*/
public Csoundo(PApplet theParent) {
@@ -67,6 +58,13 @@ public Csoundo(PApplet theParent) {
myParent.registerPost(this);
}
+ /**
+ * The Csoundo onstructor, usually called in the setup() method in your
+ * sketch to initialize and start the library.
+ *
+ * @param theParent The PApplet. Usually pass 'this'
+ * @param f The Csound file to run. Requires full absolute path.
+ */
public Csoundo(PApplet theParent, String f) {
myParent = theParent;
welcome();
@@ -97,10 +95,8 @@ public void post() {
private void welcome() {
System.out.println("##name## ##version## by ##author##");
-
}
-
/**
* return the version of the library.
*
@@ -110,10 +106,6 @@ public static String version() {
return VERSION;
}
- public void run() {
- csoundPerformanceThread();
- }
-
private void csoundPerformanceThread() {
if (csound == null) {
csnd.csoundInitialize(null, null,
@@ -124,20 +116,30 @@ private void csoundPerformanceThread() {
if (compile == 0) {
isRunning = true;
- cpThread = new CsoundPerformanceThread(csound);
- cpThread.Play();
+ perfThread = new CsoundPerformanceThread(csound);
+ perfThread.Play();
}
}
}
+ /**
+ * Creates a Csound score event.
+ *
+ * @param s The score event. ie "i 1 0 1 0.707 440"
+ */
public void event(String s) {
if (isRunning) {
- cpThread.InputMessage(s);
- cpThread.FlushMessageQueue();
+ perfThread.InputMessage(s);
+ perfThread.FlushMessageQueue();
}
}
+ /**
+ * Returns the value of the specified chn bus.
+ *
+ * @return chn bus value
+ */
public float getChn(String chn) {
if (isRunning) {
return csound.GetChannel(chn);
@@ -146,35 +148,66 @@ public float getChn(String chn) {
return 0;
}
- public void setChn(String chn, float value) {
+ /**
+ * Return the control rate.
+ *
+ * @return krate
+ */
+ public float kr() {
if (isRunning) {
- csound.SetChannel(chn, value);
+ return csound.GetKr();
}
+
+ return 0;
}
- public float tableGet(int t, int i) {
+ /**
+ * Return the ksmps, samples per k-block
+ *
+ * @return ksmps
+ */
+ public float ksmps() {
if (isRunning) {
- return csound.TableGet(t, i);
+ return csound.GetKsmps();
}
- return 0;
+ return 0;
}
- public int tableLength(int t) {
+ /**
+ * Return the number or audio output channels.
+ *
+ * @return number of output channels
+ */
+ public float nchnls() {
if (isRunning) {
- return csound.TableLength(t);
+ return csound.GetNchnls();
}
return 0;
}
+ /**
+ * starts the Csound engine.
+ */
+ public void run() {
+ csoundPerformanceThread();
+ }
- public void tableSet(int t, int i, float v) {
+ /**
+ * Sets the value of the specified chn bus.
+ */
+ public void setChn(String chn, float value) {
if (isRunning) {
- csound.TableSet(t, i, v);
+ csound.SetChannel(chn, value);
}
}
+ /**
+ * Return the samplerate.
+ *
+ * @return samplerate
+ */
public float sr() {
if (isRunning) {
return csound.GetSr();
@@ -183,30 +216,47 @@ public float sr() {
return 0;
}
- public float kr() {
+ /**
+ * Return a value from a Csound table.
+ *
+ * @param t Table number
+ * @param i Index
+ * @return Csound table value
+ */
+ public float tableGet(int t, int i) {
if (isRunning) {
- return csound.GetKr();
+ return csound.TableGet(t, i);
}
- return 0;
+ return 0;
}
- public float ksmps() {
+ /**
+ * Return the length of a Csound table.
+ *
+ * @param t Table number
+ * @return Csound table length
+ */
+ public int tableLength(int t) {
if (isRunning) {
- return csound.GetKsmps();
+ return csound.TableLength(t);
}
return 0;
}
- public float nchnls() {
+ /**
+ * Sets the value of a Csound table at a specif index.
+ *
+ * @param t Table number
+ * @param i Index
+ * @param v Value
+ */
+ public void tableSet(int t, int i, float v) {
if (isRunning) {
- return csound.GetNchnls();
+ csound.TableSet(t, i, v);
}
-
- return 0;
}
-
}

0 comments on commit 76a0eb7

Please sign in to comment.