Evaluate & copy

Is there a shortcut for Evaluate & copy the printed result in the post window?

This would be very neat for live-coding!

1 Like

Hello,

I am not good at live code, but the question is so fascinating that I write something.
If SC-IDE offered a shortcut for evaluating and copying the printed result in the post window, that would be useful.
But could you provide a specific example of when you require such cases?
I’m asking because we can reuse data using variables and because the Post window truncates output text when it gets too long.
I may be misinterpreting your question, but the examples you have to copy the outcome of the code evaluations intrigue me. In addition, other users who work with live codes might assist you if you list some cases.

Hi, thanks for your response!

I have created a dictionary which includes formatted SCTwits as strings. During the performance, I am accessing a SCTwit by evaluating the dictionary, e.g.

~scTwits[\rukano][0]

The index number corresponds to various SCTwits by the same composer.

Now, I have to go with the mouse to the post window, select the formatted SCTwit, copy it, and paste it into the editor which takes 2-5 seconds. If I could Evaluate and have the output directly copied to the clipboard, I could do that in less than a second, which would enable a more flexible and musical expression.

OK, I see.

How about this even though there are some problems?

~scTwits = Dictionary();
~scTwits.put(\composer1, List[])

~scTwits[\composer1].insert(0, "(Pbind('degree', Pseq((0..7), 1), 'dur', 0.1)).play")

~scTwits[\composer1][0].interpret
// works!


~scTwits[\composer1].insert(1, "(Pbind(\degree, Pseq((0..7), 1), \dur, 0.1)).play")

~scTwits[\composer1][1].interpret
// does not work!


~scTwits[\composer1].insert(2, "(Pbind(\\degree, Pseq((0..7), 1), \\dur, 0.1)).play")

~scTwits[\composer1][2].interpret
// works!


~scTwits[\composer1].insert(3, "(Pbind(\note, Pseq((0..7), 1), \dur, 0.1)).play")

~scTwits[\composer1][3].interpret
// does not work!


~scTwits[\composer1].insert(4, "(Pbind(\\note, Pseq((0..12), 1), \\dur, 0.1)).play")

~scTwits[\composer1][4].interpret
// works!


~scTwits[\composer1].insert(5, "(Pbind('note', Pseq((0..12), 1), 'dur', 0.1)).play")

~scTwits[\composer1][5].interpret
// works!

There is also the option of inserting the tweet into the current file using Document class. I forgot how to do it because i don’t use it but it could be a solution (i’m on vim and use different solution to insert text in current file)

Ah, there are also .load, .loadRelative and .relative.load.

"xxx.scd".load
"yyy.scd".loadRelative
"zzz.scd".resolveRelative.load

I think it would be helpful if you constructed folders with the composer’s names and put unique codes with unique names.
Then you can make a dictionary with the folders, and then you could make an array in each folder. Please refer to the following code:

and the following code as well:

Thanks for the hints, although I think my explanation wasn’t good enough…

The interpret and load methods work great if you want to have a kind of double evaluation (first evaluation outputs a string, second evaluation evaluate the string as code).

My goal is to have the SCTwit as code pasted in the editor as fast as possible. Then I can evaluate it when I want and play with the parameters in real-time.

For example:

~scTwit[\composer1][0]

would output:

(
Ndef(\testSCtwit, {
	SinOsc.ar(100!2) *
	LFPulse.kr(2)
} * -12.dbamp
).clock_(t).quant_(1).fadeTime_(1).play
)

I want that last text pasted on my editor so that I can live-code with it.

It seems that this is possible with the emacs editor:

Now I am considering to start using emacs for live-coding!

This can be done in NeoVim using SCNvim.luaEval method

here’s a method for example which puts an object as String in register d for pasting

+Object {
	registerD {
           SCNvim.luaeval(
	          "vim.fn.setreg('d',{\"%\"})".format(this.asString) // register 'd' for Durs
	       );
	  "% yanked to register d".format(this.asString).postln
	}
}

Its straighforward to insert into document also

1 Like

OK!

You can do it as follows:

(
~scTwit = Dictionary[];
~scTwit.put(\composer1, List[]);
~scTwit[\composer1].insert(0, "(
Ndef(\testSCtwit, {
SinOsc.ar(100!2) *
LFPulse.kr(2)
} * -12.dbamp
).clock_(t).quant_(1).fadeTime_(1).play
)")
)

x = Document.current;

x.insertText("\n\n"++~scTwit[\composer1][0], x.text.size)

That’s amazing, thank you so much!

1 Like