See renoise.song().selected_sample:save_as() which is documented in Renoise.Song.API.lua
-- Export sample data to a file. Possible errors are shown to the user,
-- otherwise success is returned. Valid export types are 'wav' or 'flac'.
renoise.song().instruments[].samples[].sample_buffer:save_as(filename, format)
-> [boolean - success]
it is, then! Thanks. I unfortunately don’t currently know how to set a dialog window to ask for a filename and then pass that into the save_as(“portion”).
With an inputbox?
Try the gui_examples in the tools menu that Takti provided, i sometimes still browse these lua sources to get some info that i forgot. (In generic i’m a big copy/paste cat)
This is so sick. Especially “Available controls”, I’ve never seen such cool sliders and various.
The BatchBuildingViews is the most promising for me… Especially if I can just get down to, instead of building views in batches, just get a row going and get all the buttons to do something specific - launch a specific function and all
To the folder where the user submits it.
If you want to make it yourself the most easy, use the MyPathvar = renoise.app().prompt_for_path(“Title”) function https://code.google…ication.API.lua
This is about how far I get. Maybe I’m doing something wrong:
function savesamplefoldertestTwo()
local MyPathvar = nil
local myFile = nil
MyPathvar = renoise.app():prompt_for_path("Where to Save Your Sample?")
myFile = renoise.app():prompt_for_filename_to_write("wav", "What Your File?")
do renoise.song().selected_sample.sample_buffer.save_as(MyPathvar/myFile, "wav")
end
end
both MyPath var and myFile are done, i.e., they are displayed nicely. I guess I’m not supposed to do MyPathvar/myFile since it thinks it’s an arithmetic calculation.
*** main.lua:459: attempt to perform arithmetic on local 'MyPathvar' (a string value)
*** stack traceback:
*** main.lua:459: in function 'savesamplefoldertestTwo'
*** main.lua:485: in function <485><br>
<br>```
<br>
<br>
When I changed it to (MyPathvar,myFile,"wav") I got another type of error:<br>
```lua<br><br>
<br>
*** No matching overload found, candidates:<br>
*** bool save_as(SampleBuffer&,custom [class String] const&,custom [class String] const&)<br>
*** stack traceback:<br>
*** [C]: in function 'save_as'<br>
*** main.lua:459: in function 'savesamplefoldertestTwo'<br>
*** main.lua:485: in function <485><br>
<br>```
<br>
<br>
Now,<br>
```lua<br><br>
rprint (renoise.app():prompt_for_filename_to_write("wav", "What Your File?"))<br>
/Users/esaruoho/Music/samples/able2logic/se yks/gjgjgj/rllrlr.wav<br>
<br>```
<br>
<br>
makes total sense - it seems that this is a way to get the required result. Yet<br>
<br>
```lua<br><br>
rprint (renoise.song().selected_sample.sample_buffer.save_as("myFile", "wav"))<br>
*** No matching overload found, candidates:<br>
*** bool save_as(SampleBuffer&,custom [class String] const&,custom [class String] const&)<br>
*** stack traceback:<br>
*** [C]: in function 'save_as'<br>
*** [string "rprint (renoise.song().selected_sample.samp..."]:1: in main chunk<br>
<br>```
<br>
<br>
<br>
<br>
----<br>
It just doesn't seem to work.<br>
```lua<br><br>
local MyPathvar = nil<br>
local myFile = nil<br>
<br>
MyPathvar = renoise.app():prompt_for_path("Where to Save Your Sample?")<br>
myFile = renoise.app():prompt_for_filename_to_write("wav", "What Your File?")<br>
do renoise.song().selected_sample.sample_buffer.save_as("myFile", "wav")<br>
<br>```
<br>
<br>
This, in my mind, should save a myFile -named file somewhere, but it just gives a:<br>
```lua<br><br>
<br>
*** No matching overload found, candidates:<br>
*** bool save_as(SampleBuffer&,custom [class String] const&,custom [class String] const&)<br>
*** stack traceback:<br>
*** [C]: in function 'save_as'<br>
*** main.lua:459: in function 'savesamplefoldertestTwo'<br>
*** main.lua:486: in function <486><br>
<br>```
</486></485></485>
Phew, after some mucking about finally got a result:
function savesamplefoldertestTwo()
local MYFILE = nil
MYFILE = renoise.app():prompt_for_filename_to_write("wav", "What Your File?")
renoise.song().selected_sample.sample_buffer:save_as(MYFILE, "wav")
renoise.app():show_status("Sample saved to:" .. MYFILE)
end
Okay, tried to do the logical conclusion:
function savesampleinfolder()
local MYFILE = nil
MYFILE = renoise.app():prompt_for_filename_to_write("wav", "What Your File?")
if ( MYFILE == nil ) then exit() else
renoise.song().selected_sample.sample_buffer:save_as(MYFILE, "wav")
renoise.app():show_status("Sample saved to: " .. MYFILE)
end
end
However, MYFILE reports ‘.’ if I press esc in the prompt_for_filename_to_write. I tried ‘.’ “.” . and nil and none of them worked. What am I doing wrong?
(edit)
Ok, a friend suggested “” and hey presto, it worked!
function savesampleinfolder()
local MYFILE = nil
MYFILE = renoise.app():prompt_for_filename_to_write("wav", "What Your File?")
if ( MYFILE == "" ) then return
else
renoise.song().selected_sample.sample_buffer:save_as(MYFILE, "wav")
renoise.app():show_status("Sample saved to: " .. MYFILE)
end
end
If you compare your file to nil you can better do something like:
if MYFILE ~= nil then
dostuff
end
In that case your routine is only executed if your variable is something other than nil.
The reason why this isn’t accepted:
renoise.song().selected_sample.sample_buffer.save_as(MyPathvar/myFile, “wav”)
Is because you have to do these things this way:
renoise.song().selected_sample.sample_buffer.save_as(MyPathvar…“/”…myFile, “wav”)
As the path separator is still a string character that you have to concatenate in between your two variables, as so should it be treated like that.
I tried this as a replcaement, and said “else return” and it just wouldn’t work. I got the prompt, but when pressed esc, got the same " “.” " error. Confusing! So sticking to the one that was already there.
As always, thanks for your help and advice, I’m so glad that these things are slowly starting to work in scripts.
Okay, it’s functional and working on it’s brother, the load.
-- save sample in folder, functional
function savesampleinfolder()
local MYFILE = nil
local patheo = renoise.song().selected_track.available_devices
MYFILE = renoise.app():prompt_for_filename_to_write("wav", "Choose where to save your sample")
if ( MYFILE == "" ) then return false
else
renoise.song().selected_sample.sample_buffer:save_as(MYFILE, "wav")
renoise.app():show_status("Sample saved to: " .. MYFILE)
end
end
Currently disfunctional loader, but I’ll get down to this when it’s time to do more of this type stuff for the GUI
function loadsampleinfolder()
local MYFILE = nil
MYFILE = renoise.app():prompt_for_filename_to_read({"wav"}, "Pick Your Filename")
if ( MYFILE == "" ) then return false
else
renoise.song().selected_sample.sample_buffer:load_from(MYFILE, "wav")
renoise.app():show_status("Sample Loaded: " .. MYFILE)
end
end