Lua example for using the WAV-writer functions in the plugin :
Code:
function test_wav_write(outfn)
local writebufsize = 512
local numoutchans = 4
local arr = reaper.new_array(writebufsize*numoutchans+numoutchans) -- need some extra space because of how the indexing works for the arrays
local b = arr
local writer = reaper.Xen_AudioWriter_Create(outfn,numoutchans,44100)
if writer~=nil then
local phase = 0
for i=0,999 do -- write 1000 buffers to disk
-- fill interleaved buffer data, note that buffer data has to be written from index 1, not index 0
for j=1,writebufsize do
for k=0,numoutchans-1 do
arr[j*numoutchans+k]=0.5*math.sin(2*3.141593/44100.0*phase*(100.0+k*10.0))
end
phase=phase+1
end
-- offset 1 here tells writer the data starts at array index 1
local result = reaper.Xen_AudioWriter_Write(writer,writebufsize,arr,1)
if result == 0 then reaper.ShowConsoleMsg("Fail during writing\n") break end
end
reaper.Xen_AudioWriter_Destroy(writer) -- file is only finalized when the writer is destroyed
else
-- Can fail if file directory path does not exist, no write permissions, disk full...
reaper.ShowConsoleMsg("Could not create writer\n")
end
end
I have not tested the functions with Python and Eel yet. It would also be useful to have a test the writer works with buffers that come from Reaper's AudioAccessors.