Hi,
On Mon, 7 Nov 2022 at 11:05, Hairi Vogel (airi) <
hairi...@gmail.com> wrote:
> How do I save data from a component to a file ?
> I am looking for something like saveTable() / loadTable() in Processing or
> any functioning example to hack.
What format do you want to save data as, and what is the input data?
In general you want to move file IO into a separate root graph (eg.
generic data patch).
The following component will save a PArray of PArray as CSV using
Processing's Table. Just copy and paste the text between the ~~~~
lines onto the data graph. You'll need to change the .file property to
a URI on your system.
~~~~~~~~~~~~~~~
#%praxis.version 5.4.0
@ ./table-save core:custom {
#%graph.x 0
#%graph.y 0
.code "import java.io.File;
import java.io.IOException;
@P(1) Optional<PResource> file;
@In(1) void in(PArray data) throws IOException \{
if (file.isEmpty()) \{
return;
\}
var destFile = new File(file.get().value());
if (data.isEmpty()) \{
throw new IllegalArgumentException(\"No data\");
\}
var table = new processing.data.Table();
var columns = PArray.from(data.get(0)).orElseThrow();
for (Value column : columns) \{
table.addColumn(column.toString());
\}
for (int r = 1; r < data.size(); r++) \{
var row = PArray.from(data.get(r)).orElseThrow();
var count = min(columns.size(), row.size());
var tableRow = table.addRow();
for (int i = 0; i < count; i++) \{
tableRow.setString(table.getColumnTitle(i),
row.get(i).toString());
\}
\}
table.save(destFile, \"csv\");
\}
"
.file file:/home/nsigma/test.csv
}
~~~~~~~~~~~~~~~
This can then be used from another component by doing something along
the lines of -
@T(1)
void trigger() {
var table = PArray.of(
array("Column1 Column2 {Column number three}"),
array("Data1 Data2 {}"),
array("1 2 3")
);
tell(ControlAddress.of("/data/
table-save.in"), table);
}
> How can I send OSC from PraxisLive ?
> Is it worth the while trying to use oscP5 the Processing library ?
> That would be a workaround for the lack of serial comm.
I would look at using a Java OSC library. PraxisLIVE actually has
NetUtil in it, but it's hidden. I need to have a think about this
one.
Again, if you do this, use a generic data patch and send data to a
component in that.
> I had just a short look at the audio part, but it is complete and there is no need for
> libraries like Minim at all. Just one thing:
> On my system it is not possible to do anything with audio with blocksize smaller than
> 512. Not with the incorporated Realtek audiodevice , not with the Tascam iXR USB interface I use normally.
> I have a AMD Ryzen 9 with 64GB of fast RAM (gaming style) and a Radeon 6050.
> It is amazing how your software performs compared to Processing and Isadora !!!
> Graphics and Shaders , super. Never a flaw. Impressive. It pays to have architecture made by artists.
>
> Thanks for the wonderful work
Thanks for the feedback!
Part of why performance might be better is that PraxisLIVE has a very
rigid concurrency model, sending messages between different graphs
(audio, video, data, etc.). By doing this we can ensure they don't
interfere with each other, and even run different graphs in different
processes. By default, the IDE, video and audio are running in
separate processes. You can configure this in each project's
properties -
https://docs.praxislive.org/projects/#hub-configuration
What OS are you on? For best audio performance, use the JACK backend
if you can.
The internal buffer size for audio in PraxisLIVE is 64 samples (by
default). This can be altered if necessary, as long as the external
buffer size is a direct multiplier of this value. Things should at
least sound the same, even if you have to increase external buffer
sizes.
Best wishes,
Neil