Hey guys.
I’m currently working on an import plugin for REX loops. The actual converter works now, but I’m stuck on the LUA side of things. The converter I wrote takes a REX file and exports the individual slices as 32bit, 96kHz mono PCM files without a header. The files are perfectly valid (tested with SOX), but I can’t open them as they are. I know that I can read them as binary streams using “io.open”, but I can’t figure out how to create samples from the individual slices. Renoise seemingly wants to know the number of frames to create a buffer, but I have no idea how to get the number of frames from the files in question. I tried to create a small buffer, hoping it would simply grow if I feed it more data, but this doesn’t seem to work:
local slice = io.open("slice_l0.raw", "rb")
renoise.song().selected_instrument:clear();
renoise.song().selected_instrument.samples[1].sample_buffer.create_sample_data(96000, 32, 1, 1);
renoise.song().selected_instrument.samples[1].sample_buffer.set_sample_data(0, 0, slice);
returns:
*** No matching overload found, candidates:
*** bool create_sample_data(SampleBuffer&,long,long,long,long)
*** stack traceback:
*** [C]: in function 'create_sample_data'
*** main.lua:72: in function 'import_rex_loop'
*** main.lua:18: in function <17><br>```
<br>
<br>
And there are two more things I don't get. First of all, shouldn't "samples[]" start at "0"? If I try that, it complains about an "[i]attempt to index field '?'[/i]". Also, in set_sample_data, what is the "frame_index" supposed to be? Do I have to fill the data frame by frame? Seems... slightly inconvenient. At least for my purposes <img src="https://files.renoise.com/forum/emoticons/default/smile.gif" class="bbc_emoticon" alt=":)"><br>
<br>
<br>
EDIT: Bundling SOX and using that to convert the files to regular WAV files before opening them seems to work (using "[i]sample_buffer:load_from()[/i]"). I'd prefer a native solution, though - I don't really feel like bundling several MBs worth of binaries, especially if there's a native solution.</17>