( //settings 1

~text = "supercollider"; //some short text... put whatever you want

~inx !? {~inx.resetScore(true)};

~inx = Iannix.new;

//making a soundfile from ~text

~path = Document.current.dir;

~path = "sounds"; //wont work if your sound folder is write-protected...

~file = ~path++"\/"++~text++".aiff";

~file.postln;

("say" + "-o" + ~file + "\"" ++~text++"\"").unixCmd;

{

"waiting to be sure the soundfile is created...".inform;

2.wait;

s = Server.local.waitForBoot ({

SynthDef(\grain, { arg out = 0, bufnum=0, location=0, pan=0, tune=0, trate= 50, dur=4;

trate = LFNoise2.kr(1).range(trate, trate*2);

dur = 4/trate;

Out.ar(out,

TGrains.ar(2, Impulse.ar(trate), bufnum, 1 * tune.midiratio, Lag.kr(location * BufDur.kr(bufnum), 0.1), dur, pan, 0.1, 2);

);

}).add;

s.sendMsg(\b_allocRead, 0, ~file); //feeding a buffer with the generated text soundFile

~inx.createSynthGroup;

("rm" + ~file).unixCmd; //and removing the text soundfile from disk (now that the buffer is filled)

});

}.fork;

)

( // settings 2: create a Iannix.app score

// from ~text (important: please start from an empty score in Iannix.app !)

~xPos = 0;

~nbCursors = 5;

~curve = ~inx.curve.fromText(~text, 0.04, "Arial").position_(~xPos).width_(1).color_(Color.rand);

~nbCursors.do {

~inx.cursor(~curve)

.mapping_(inputBondaries: [0, 1, ~text.size, 0])

.speed_(rrand(8, 10))

.color_(Color.rand)

.offset_(20.0.rand,0.001, "end")

.messages_(["cursor_value_x", "cursor_value_y"])}; //the messages Iannix.app will send back to us (or forward to any other app)

~inx.zoom(200).center(x:3);

~grains = (); //will be filled from listening from cursors (one new synth for each unknown id)

//global function for cursors movements

~inx.globalActions[\cursors] = {|args|

var cursor_id, cursor_value_x, cursor_value_y, pan, grain;

#cursor_id, cursor_value_x, cursor_value_y = args;

pan = cursor_value_x * 2 - 1;

grain = ~grains[ cursor_id - ~inx.idOffsets[\cursors] ];

grain ?? {~grains[ cursor_id - ~inx.idOffsets[\cursors] ] = Synth(\grain, target: ~inx.synthGroup) };

grain.set(\location, cursor_value_x, \pan, pan, \tune, cursor_value_y, \trate, 30, \dur, 2 );

};

)

( //play

~inx.listen(\cursors);

~inx.play;

)

~inx.fadeTime_(out: 1); //must be sent afterward, synth must already be created for this to operate on them

//////////////////////////////////////////

//some last commands

~inx.stop;

//~inx.synthGroup.free;

~inx.resetScore(true); //are you sure?? (remove objects in Iannix.app )