-
Notifications
You must be signed in to change notification settings - Fork 133
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
43 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
//---------------------------------------------------------------------------- | ||
// name: r-if.ck ('r' is for "receiver") | ||
// desc: OpenSoundControl (OSC) receiver example; expects int and float data | ||
// note: launch with s.ck (that's the sender) | ||
//---------------------------------------------------------------------------- | ||
|
||
// the patch | ||
SinOsc s => JCRev r => dac; | ||
.5 => s.gain; | ||
.1 => r.mix; | ||
|
||
// create our OSC receiver | ||
OscIn oin; | ||
// create our OSC message | ||
OscMsg msg; | ||
// use port 6449 (or whatever) | ||
6449 => oin.port; | ||
// create an address in the receiver, expect an int and a float | ||
oin.addAddress( "/foo/notes, if" ); | ||
|
||
// infinite event loop | ||
while( true ) | ||
{ | ||
// wait for event to arrive | ||
oin => now; | ||
|
||
// grab the next message from the queue. | ||
while( oin.recv(msg) ) | ||
{ | ||
// expected datatypes | ||
// (note: as indicated by "if" in the address string above) | ||
int i; | ||
float f; | ||
|
||
// fetch the first data element as int | ||
msg.getInt(0) => i => Std.mtof => s.freq; | ||
// fetch the second data element as float | ||
msg.getFloat(1) => f => s.gain; | ||
|
||
<<< "got (via OSC):", i, f >>>; | ||
} | ||
} |