Permalink
Browse files

Added headerInfo example.

  • Loading branch information...
1 parent 8bb426e commit 9bb4d959df41bfb8e8045b47d6426135d4907637 @jacobjoaquin committed Aug 18, 2010
@@ -10,15 +10,15 @@ void setup() {
cs = new Csoundo(this, "data/synth.csd");
cs.run();
- cs.tableSetTest(1, 2048, -1.0);
+ cs.tableSet(1, 2048, -1.0);
}
void draw() {
if (frameCount % 9 == 0) {
cs.event("i 2 0 0.3 0.5 " + (random(440.0) + 440));
}
- println(cs.tableLengthTest(1));
+ println(cs.tableLength(1));
if (frameCount % 5 == 0) {
cs.setChn("amp", random(1.0));
Binary file not shown.
@@ -0,0 +1,31 @@
+<CsoundSynthesizer>
+<CsInstruments>
+sr = 44100
+kr = 1470
+ksmps = 30
+nchnls = 1
+0dbfs = 1
+
+gi_sin ftgen 1, 0, 8192, 10, 1
+
+instr 1
+ ; Keep Csound running
+endin
+
+instr 2
+ idur = p3
+ iamp = p4
+ ifreq = p5
+
+ k1 line iamp, idur, 0
+ a1 oscil k1, ifreq, gi_sin
+
+ out a1
+endin
+
+</CsInstruments>
+<CsScore>
+i 1 0 [60 * 60 * 24]
+i 2 0 4 0.5 262
+</CsScore>
+</CsoundSynthesizer>
@@ -0,0 +1,53 @@
+<CsoundSynthesizer>
+<CsOptions>
+-d -odac /Users/clu/Documents/workspace/Csoundo/examples/devScratchPad/data/temp.csd
+</CsOptions>
+<CsInstruments>
+sr = 44100
+kr = 1470
+ksmps = 30
+nchnls = 1
+0dbfs = 1
+
+gi_sin ftgen 1, 0, 8192, 10, 1
+;gi_foo ftgen 20, 0, 8192, 10, 1
+
+instr 1
+ ; Keep Csound running
+endin
+
+instr 2
+ idur = p3
+ iamp = p4
+ ifreq = p5
+
+ k1 line iamp, idur, 0
+ a1 oscil k1, ifreq, gi_sin
+
+ out a1
+endin
+
+instr 3
+ turnoff2 4, 0, 0
+ turnoff
+endin
+
+instr 4
+ idur = p3
+ iamp = p4
+ ifreq = p5
+
+ a1 foscil iamp, ifreq, 1, 2, 1, gi_sin
+
+ out a1
+endin
+
+
+</CsInstruments>
+<CsScore>
+i 1 0 [60 * 60 * 24]
+i 2 0 4 0.5 262
+
+
+</CsScore>
+</CsoundSynthesizer>
@@ -0,0 +1,25 @@
+import csoundo.*;
+
+Csoundo cs;
+PFont font;
+
+void setup() {
+ size(720, 480);
+ background(0);
+ noLoop();
+
+ font = loadFont("Courier-24.vlw");
+ textFont(font);
+
+ cs = new Csoundo(this, "data/synth.csd");
+ cs.run();
+}
+
+void draw() {
+ translate(30, height - 150);
+ text("Sample rate: " + cs.sr(), 0, 0);
+ text("Control rate: " + cs.kr(), 0, 30);
+ text("Ksmps: " + cs.ksmps(), 0, 60);
+ text("Channels: " + cs.nchnls(), 0, 90);
+ text("0dBfs: " + cs.get0dBFS(), 0, 120);
+}
@@ -0,0 +1,35 @@
+<CsoundSynthesizer>
+<CsOptions>
+-d -odac /Users/clu/Documents/workspace/Csoundo/examples/headerInfo/temp.csd
+</CsOptions>
+<CsInstruments>
+sr = 44100
+kr = 1470
+ksmps = 30
+nchnls = 1
+0dbfs = 1
+
+gi_sin ftgen 1, 0, 8192, 10, 1
+
+instr 1
+ ; Keep Csound running
+endin
+
+instr 2
+ idur = p3
+ iamp = p4
+ ifreq = p5
+
+ k1 line iamp, idur, 0
+ a1 oscil k1, ifreq, gi_sin
+
+ out a1
+endin
+
+</CsInstruments>
+<CsScore>
+i 1 0 [60 * 60 * 24]
+i 2 0 4 0.5 262
+
+</CsScore>
+</CsoundSynthesizer>
@@ -3,7 +3,7 @@ import csoundo.*;
Csoundo cs;
void setup() {
- size(1600, 1200);
+ size(740, 480);
frameRate(30);
smooth();
background(0);
View
@@ -72,6 +72,11 @@ public Csoundo(PApplet theParent, String _csd) {
public void dispose() {
System.out.println("Csound dispose");
// TODO: Shut down Csound properly.
+
+ csound.Stop();
+ csnd.csoundDestroy(csound_p);
+ csound.Cleanup();
+
}
public void pre() { }
@@ -182,9 +187,9 @@ public void run() {
isRunning = engine.isRunning;
}
- /**
- * Sets the value of the specified chn bus.
- */
+ /**
+ * Sets the value of the specified chn bus.
+ */
public void setChn(String chn, float value) {
if (isRunning) {
if (useThreads) {
@@ -197,6 +202,23 @@ public void setChn(String chn, float value) {
}
}
+ /**
+ * Sets the string of the specified chn bus.
+ */
+ public void setChn(String chn, String sValue) {
+ // TODO: Untested. Need to figure out how to get a string.
+ if (isRunning) {
+ if (useThreads) {
+ csnd.csoundLockMutex(mutex);
+ csound.SetChannel(chn, sValue);
+ csnd.csoundUnlockMutex(mutex);
+ } else {
+ csound.SetChannel(chn, sValue);
+ }
+ }
+ }
+
+ /* TODO: Try to get this working, even if unnecessary.
public void setChnTest(String chn, float value) {
if (isRunning) {
CsoundMYFLTArray myflt = new CsoundMYFLTArray(4);
@@ -209,7 +231,8 @@ public void setChnTest(String chn, float value) {
}
}
}
-
+ */
+
/**
* Return the samplerate.
*
@@ -266,22 +289,6 @@ public int tableLength(int t) {
return 0;
}
- public int tableLengthTest(int t) {
- if (isRunning) {
- if (useThreads) {
- csnd.csoundLockMutex(mutex);
- int value = csnd.csoundTableLength(csound_p, t);
- csnd.csoundUnlockMutex(mutex);
- return value;
- } else {
- return csnd.csoundTableLength(csound_p, t);
- }
- }
-
- return 0;
- }
-
-
/**
* Sets the value of a Csound table at a specif index.
*
@@ -301,16 +308,12 @@ public void tableSet(int t, int i, float v) {
}
}
- public void tableSetTest(int t, int i, float v) {
+ public float get0dBFS() {
if (isRunning) {
- if (useThreads) {
- csnd.csoundLockMutex(mutex);
- csnd.csoundTableSet(csound_p, t, i, v);
- csnd.csoundUnlockMutex(mutex);
- } else {
- csnd.csoundTableSet(csound_p, t, i, v);
- }
+ return csound.Get0dBFS();
}
+
+ return 0;
}
}

0 comments on commit 9bb4d95

Please sign in to comment.