|
|
|
09-20-2018, 07:14 PM
|
#1
|
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Why does jsfx not have a file write function?
What the title says. Obviously, writing to files would be really useful.
__________________
It's time to take a stand against the synthesizer.
|
|
|
09-21-2018, 07:40 AM
|
#3
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by preferred.nomenclature
|
Unfortunately not - it can only write to preset data in @serialize. There's no way to open a file in "write" mode, as far as I'm aware.
As for the original question "why": I'm not being sarcastic, but I think the answer is pretty much "Justin didn't add it in". There will always be a frontier of features that would be useful in some subset of situations, and it's a judgement call how far to push those boundaries, compared to the complexity (and effort) it introduces.
If you're motivated, there's a Feature Requests sub-forum, you could try and get support (or perhaps answers) there. Probably worth searching if it's already been suggested, so you can bump that with a +1.
Last edited by geraintluff; 09-21-2018 at 05:20 PM.
|
|
|
09-21-2018, 04:10 PM
|
#4
|
Administrator
Join Date: Jan 2005
Location: NYC
Posts: 15,721
|
The rationale is that JSFX should not be able to write to files! Outside the scope of what they should be permitted to do, as processors...
|
|
|
09-21-2018, 05:38 PM
|
#5
|
Human being with feelings
Join Date: Nov 2009
Location: mostly inside my own head
Posts: 346
|
Quote:
Originally Posted by Justin
The rationale is that JSFX should not be able to write to files! Outside the scope of what they should be permitted to do, as processors...
|
Um - so obviously you're the authority on this. But we already have some APIs like export_buffer_to_project() which are slightly outside the "pure state machine" model of an audio processor, but are still useful for creating certain types of audio effect.
This isn't to say that file-write should be included, just that the line isn't completely self-evident from the definition of a "processor".
JSFX is wonderful for writing effects, and I do appreciate that it doesn't cram every imaginable feature in, and focuses on what it's good at. So, I have faith in your judgement on this, and obviously appreciate you making it in the first place.
|
|
|
09-21-2018, 07:27 PM
|
#6
|
Human being with feelings
Join Date: Aug 2012
Posts: 271
|
This can be a good addition ("undocumented" - thoughtfully)
|
|
|
09-21-2018, 09:41 PM
|
#7
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
While I do agree that writing to files (and reading files other than for initialization) is a no-go for such a realtime processor building tool, there might be workarounds.
If gmem would be accessible not only for jsfxes, but also for ReaScripts, and file writing is enabled for those (which run in the environment of the GUI thread), appropriate software could be done. In fact a JSFX already can send out Midi data, theses can be routed by MidiToReaControlPath and received by a ReaScript. Seems to make sense for very small data amounts.
This said, in fact JSFXes already can write to files . A friend of mine uses this in a project he created. Just have the JSFX output an audio stream and then render. If rendering to lossless compressed FLAC, sending out a stream of constants does not take much place besides your useful data. Now you can use appropriate software to decode the data.
Moreover Midi data sent by a JSFX can be saved in the Reaper Project file.
-Michael
Last edited by mschnell; 09-21-2018 at 11:50 PM.
|
|
|
09-23-2018, 07:11 AM
|
#8
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
I wondered as well. I would be perfectly happy if I could send over information to/from ReaScripts, as mschnell pointed out.
Even if it were only by extstates. I have tons of great usecases waiting to be ready for such a thing.
In addition, the video-processor-plugin would benefit from such a thing as well. I could add text to textprocessor-plugins better, if I could add the text using extstates, instead of having to seek and replace code in the item/trackstatechunk.
|
|
|
09-23-2018, 12:22 PM
|
#9
|
Human being with feelings
Join Date: May 2017
Posts: 3,202
|
So... is the following text from the jsfx reference guide File I/O page incorrect?
file_mem(handle,offset, length)
Example:
amt=file_mem(handle,offset,len);
This reads (or writes) the block of local memory from(to) the current file. Returns the actual number of items read (or written).
Does "current file" not refer to a disk file? Am I taking something out of context? It is also not clear how to specify a write rather than a read.
I'm becoming quite accomplished at confusion because I practice it so much...
Last edited by Philbo King; 09-23-2018 at 12:36 PM.
|
|
|
09-24-2018, 11:31 AM
|
#10
|
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Another use case for file writing would be sampling (not sample playback) straight into a jsfx. Like old-school sampling, rather than first recording samples to a track, slicing, and dragging in each sample. Maybe with transient detection, so as not to have to do manual slicing. In other words, a more immediate workflow for sampling.
__________________
It's time to take a stand against the synthesizer.
Last edited by brainwreck; 09-24-2018 at 11:38 AM.
|
|
|
09-24-2018, 01:08 PM
|
#11
|
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
So then, the samples would be project dependent? That could work, but obviously it would be a bit kludgy to load the jsfx for other projects (open project that has the jsfx, copy it, paste it into a new project (if that would even work).
__________________
It's time to take a stand against the synthesizer.
|
|
|
09-24-2018, 01:08 PM
|
#12
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by Philbo King
So... is the following text from the jsfx reference guide File I/O page incorrect?
file_mem(handle,offset, length)
Example:
amt=file_mem(handle,offset,len);
This reads (or writes) the block of local memory from(to) the current file. Returns the actual number of items read (or written).
|
Some lines above it sais:
Quote:
File I/O and Serialization:
The following functions can be used in the @serialize section or in other sections.
Using with @serialize:
Pass 0 as a handle to various file_*() functions, but do not call file_open() or file_close(). Simple @serialize code will often appear the same for read and write, as file_var(0,x) will read/write x depending on the mode. If you want to have different logic per mode, you can check file_avail(0)>=0 to determine if it is in read mode.
Using in other sections:
file_open() and file_close() can be used to open files for reading in any section.
|
So AFAIU, writing to a file is only done when saving the project.
-Michael
|
|
|
09-24-2018, 01:10 PM
|
#13
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by brainwreck
Another use case for file writing would be sampling (not sample playback) straight into a jsfx.
|
You could store the samples in memory and in @serialize write them to a file when saving the project.
-Michael
|
|
|
09-24-2018, 01:12 PM
|
#14
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by brainwreck
So then, the samples would be project dependent?
|
What do you mean by "project" dependent ?
AFAIU, Just the time when writing to a file is restricted, not the location.
-Michael
|
|
|
09-24-2018, 01:12 PM
|
#15
|
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Edit: Nevermind. Must have been some post editing happening.
__________________
It's time to take a stand against the synthesizer.
|
|
|
09-24-2018, 01:15 PM
|
#16
|
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Quote:
Originally Posted by mschnell
What do you mean by "project" dependent ?
AFAIU, Just the time when writing to a file is restricted, not the location.
-Michael
|
Oh, I see. So files can be written (and to wherever) then?
Use case: I would want to sample some audio in a jsfx (and save the audio), manipulate it a bit in the jsfx (non-destructively), and save the jsfx state as a preset (where the file is loaded when the jsfx is loaded).
__________________
It's time to take a stand against the synthesizer.
Last edited by brainwreck; 09-24-2018 at 01:22 PM.
|
|
|
09-24-2018, 01:45 PM
|
#17
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by brainwreck
So files can be written (and to wherever) then?
|
I suppose so:
Quote:
handle = file_open(string);
|
"string" holding a usual OS file specification.
-Michael
|
|
|
09-24-2018, 01:47 PM
|
#18
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by brainwreck
Edit: Nevermind. Must have been some post editing happening.
|
Bad habit of mine: post a text and improve it afterwards
-Michael
|
|
|
09-25-2018, 05:01 PM
|
#19
|
Human being with feelings
Join Date: Jul 2006
Posts: 20,859
|
Quote:
Originally Posted by mschnell
Bad habit of mine: post a text and improve it afterwards
-Michael
|
I am probably worse than anyone at doing that. Funny how more precise we feel that we have to be in text than when speaking in person.
__________________
It's time to take a stand against the synthesizer.
|
|
|
06-09-2019, 09:58 AM
|
#20
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
Has anyone successfully managed to save a block of memory to a file and recall it later? The documentation seems to suggest that it can be done. However it also says that in @serialize you need to use a handle of 0 (file_mem(0,offset,length)), which seems to save it to the project file only, regardless of what file is open. Using a handle other that 0 in @serialize does nothing, as far as I can tell.
|
|
|
06-10-2019, 02:00 AM
|
#21
|
Human being with feelings
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,646
|
AFAIK you can't write to an external file.
|
|
|
06-11-2019, 01:54 AM
|
#22
|
Human being with feelings
Join Date: Aug 2009
Location: NL
Posts: 1,453
|
Quote:
Originally Posted by mschnell
This said, in fact JSFXes already can write to files . A friend of mine uses this in a project he created. Just have the JSFX output an audio stream and then render. If rendering to lossless compressed FLAC, sending out a stream of constants does not take much place besides your useful data. Now you can use appropriate software to decode the data.
Moreover Midi data sent by a JSFX can be saved in the Reaper Project file.
-Michael
|
Haha, this is a cool idea. It reminds me of the old tape days. Have to rewind the tape to load the settings
|
|
|
06-11-2019, 07:34 PM
|
#23
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
After posting my previous message, I realised that both presets and FX chains are methods of saving memory dumps. A preset file is a series of memory dumps. An FX chain is a single memory dump (you can save a single FX as an FX chain).
My need in this instance is to exchange recorded samples saved in indexed memory. The sender can save the current state as an FX chain. The receiver loads up the FX chain and has the option of saving it as a preset.
Last edited by Time Waster; 06-11-2019 at 07:41 PM.
|
|
|
06-11-2019, 09:48 PM
|
#24
|
Human being with feelings
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,690
|
Quote:
Originally Posted by Time Waster
The sender can save the current state as an FX chain. The receiver loads up the FX chain and has the option of saving it as a preset.
|
This is done by the @serialize feature. Correct ?
-Michael
|
|
|
06-11-2019, 10:05 PM
|
#25
|
Human being with feelings
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 1,638
|
You can save the current state in @serialize using file_mem(), but there is no convenient way that I know of to access it. It is stored in the project file, so you would need to share the whole project.
|
|
|
06-12-2019, 01:31 PM
|
#26
|
Human being with feelings
Join Date: May 2017
Location: Leipzig
Posts: 6,621
|
You can use gmem to transport the data to e.g. ReaScript. In Lua, you can reread it again and store it into a file.
This isn't convenient but should work.
Only problem to solve: gmem can hold only numbers, not strings, so you need to convert string2numbers2string, if you need them.
|
|
|
Thread Tools |
|
Display Modes |
Linear Mode
|
Posting Rules
|
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts
HTML code is Off
|
|
|
All times are GMT -7. The time now is 04:18 AM.
|