Old 11-29-2018, 02:29 PM   #1
inscript
Human being with feelings
 
Join Date: Aug 2018
Posts: 7
Default JSFX and IDE help

I would like to start experimenting with JSFX programming using the built in IDE and I'm wondering a few things:

After doing some searching, it seems like there is very little tutorial/beginner-oriented JSFX development content around. Am I missing sites or places on the forums?

I am under the impression that Lua can't interact directly with the audio engine, that's to say, we aren't able to program effects directly in Lua, correct?

Is there a way to increase the font size on the built-in IDE? I've tried some other solutions getting syntax highlighting to work in other editors (including the VSCode tools to no avail), but all I would really like to do is increase the font size. Additionally, is there a place someone can point me for themes for the IDE? Perhaps a larger font would be inside one of these themes?

Thanks in advance for responses
inscript is offline   Reply With Quote
Old 11-29-2018, 03:08 PM   #2
nofish
Human being with feelings
 
nofish's Avatar
 
Join Date: Oct 2007
Location: home is where the heart is
Posts: 8,232
Default

Hi,

for increasing font size in the built in IDE (didn't test this myself)

Quote:
Change Config-variable edit_fontsize or the reaper.ini entry [REAPER]->edit_fontsize to the fontsize you need.
(it's mespotine's current signature.)
nofish is offline   Reply With Quote
Old 11-29-2018, 03:44 PM   #3
Edgemeal
Human being with feelings
 
Edgemeal's Avatar
 
Join Date: Apr 2016
Location: USA
Posts: 765
Default

Quote:
Originally Posted by inscript View Post
Is there a way to increase the font size on the built-in IDE?
On Windows I just use Control key + Mousewheel.
Edgemeal is offline   Reply With Quote
Old 11-29-2018, 06:30 PM   #4
Xenakios
Human being with feelings
 
Xenakios's Avatar
 
Join Date: Feb 2007
Location: Oulu, Finland
Posts: 7,451
Default

Quote:
Originally Posted by inscript View Post
I am under the impression that Lua can't interact directly with the audio engine, that's to say, we aren't able to program effects directly in Lua, correct?
That's correct, at least with Lua in Reaper. But there's for example Protoplug that allows writing audio plugins with Lua (I don't know how well that works and is supported these days, though) :

http://www.osar.fr/protoplug/
__________________
For info on SWS Reaper extension plugin (including Xenakios' previous extension/actions) :
http://www.sws-extension.org/
https://github.com/Jeff0S/sws
--
Xenakios blog (about HourGlass, Paul(X)Stretch and λ) :
http://xenakios.wordpress.com/
Xenakios is online now   Reply With Quote
Old 11-29-2018, 10:13 PM   #5
inscript
Human being with feelings
 
Join Date: Aug 2018
Posts: 7
Default

Thanks for the responses. Funny enough, I have Protoplug installed on my machine and that documentation is as equally scarce as the JSFX reference. I actually just emailed the developer and asked him if the project is still alive. I'm surprised no one has written any tutorial content for JS. I'm not really at the point where I can open up a JS plugin like "very basic softclipper" and use it as a starting point. I don't even know where to begin with JS.I've checked out the useful code snippets sticky, but that deals with implementing algorithms more than anything directed at a beginner. I'm really curious how someone like Saike took the JSFX reference and turned it into a great plugin like Filther. How did you guys go from point A to point B?

Edit: Ctrl + mousewheel works great! Can I be really picky and ask if there's a way to change the font?

Last edited by inscript; 11-30-2018 at 12:25 AM.
inscript is offline   Reply With Quote
Old 12-04-2018, 06:32 AM   #6
sai'ke
Human being with feelings
 
sai'ke's Avatar
 
Join Date: Aug 2009
Location: Germoney
Posts: 155
Default

It's difficult to give solid advice, since we don't know what languages and DSP concepts you are familiar with. Are you familiar with C or some other language that's relatively close to the metal?

I think the lack of entry-level tutorials on jsfx is generally because DSP tends to have a fairly steep learning curve and people familiar with DSP tend to be used to programming in different languages. This makes it easier to familiarize with new languages.

A jsfx is a script where you define sections that get called on specific events (the @ sections). Events such as script initialization, slider modification, starting the next sample block, processing a sample (here you typically do the actual audio processing), updating the gfx. In each of these blocks you can stuff some code that gets evaluated when reaper calls these functions. Be warned though that some of these can be accessed concurrently (running at the same time)!

Variables can be stored and read just like you'd expect:
Code:
a=5; // a is now 5
But it can also be accessed in an address like manner (kind of like a pointer) like so:
Code:
blah = 10;  // blah is set to 10
blah[] = 5; // You can read [] as at. Now the memory at location 10 is set to 5.

blah = blah + 1; // You can also write blah += 1 for shorthand
// Blah is now set to 11, if we were to read blah[] we'd be looking at what is stored at address 11 now.
blah[] = 20; // Now the memory at address 10 contains 5 and the memory at address 11 contains 20.

blah -= 1; // blah is once again set to 10 after this command.
blah[] = 6; // Now the memory at address 10 contains 6 and the memory at address 11 still contains 20.
You also have loops, which can run a set number of times. What you'll often see in jsfx is pointers iterating over some array and reading/writing values from/to them.

JSFX has several built in variables that can be accessed (and sometimes modified). You should refer to the reference for these. For example, you can get the current sample on channel 0 with spl0 in the @sample block.

So let's say we want to invert the left channel, we can just go
Code:
spl0 = -spl0;
in @sample.

By default, variables are defined globally, but you can also define functions, which can be called on an instance of something, which can provide you with a smaller environment that is encapsulated and protected from the global namespace (this is generally a good idea when you want multiple of something, or just to avoid overwriting variables).
__________________
[Soundcloud] | [Tracker Plugin: Thread|Github|Reapack link] | [Machine UI Plugin: Thread|Github|Reapack link] | [Filther: Github]

Last edited by sai'ke; 12-04-2018 at 06:38 AM.
sai'ke is offline   Reply With Quote
Old 12-05-2018, 10:19 PM   #7
Time Waster
Human being with feelings
 
Time Waster's Avatar
 
Join Date: Aug 2013
Location: Bowral, Australia
Posts: 766
Default

There is this, which helped me to get started: https://wiki.cockos.com/wiki/index.p...onic_Tutorials
__________________
ReaRack JSFX Modular Synth - Mostly harmless: https://stash.reaper.fm/v/28403/ReaR...dularSynth.zip
The Wasters of Time: https://soundcloud.com/thewastersoftime
Time Waster is offline   Reply With Quote
Old 12-08-2018, 02:25 PM   #8
inscript
Human being with feelings
 
Join Date: Aug 2018
Posts: 7
Default Functions?

Thanks for chiming in all! TimeWaster, ReaRack is brilliant! This is a nice little primer. I'm coming from Max/Pure Data, and a little bit of Supercollider, but definitely have more of a background in mixing than development. So I'm not new to DSP but haven't really delved in deep yet. I think an analogy for the distinction between beginner and intermediate users doing DSP (excuse the lack of knowledge here) might be knowing how to implement an oscillator and send it to the speakers vs. knowing how to perform multiple implementations of an oscillator, and what their advantages/disadvantages are, for instance. I'm definitely in that former category. Doing some research and just getting the first few sounds from JSFX now. I apologize if I came off a little frustrated in the last post, and I will attempt to be more deliberate here in the future. Turning this into a "how I'm learning JSFX" thread. Feel free to chime in wherever you would like with help/answers. I'm sure I'll have questions, which I'll either post here or in a separate thread if I think it would be more useful. One of the things I'm doing as an exercise is making a copy of an effect (like Schwa's soft-clipper, or the Tone Generator) and going through line by line, commenting what each bit of code does. I've now gotten the jist of how a script is structured, and I'm writing a script that's as minimal as possible so I can figure out what is and isn't necessary for a given script. I've been looking to build a phasor function for the beginnings of an oscillator and I'm encountering a problem:


Code:
@init

function osc(freq, amp)
(
phase = phase+(freq/srate);
(phase >= 2.0*$pi) ? phase -= 2.0*$pi;
phase = phase * amp
);

@sample

osc1 = osc(400, 1);
osc2 = osc(600, 1);
out = osc1 + osc2;

spl0 = out + spl0;
spl1 = out + spl1;
Two phasors summed to the output, right? But it appears that the only output I get is the second instance of the osc function. The operation between the oscillators matters less right now than the fact that I don't think both are working. I must be missing something. I've seen in the cookdsp code a bunch of "this" and "do" in regards to functions but I'm not sure what those do, and the JSFX reference take a lot about namespace and such but I havent gotten that far. How do functions work in JSFX?
inscript is offline   Reply With Quote
Old 12-09-2018, 03:32 AM   #9
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: Holland
Posts: 2,906
Default

You could try this:

Code:
@init

function osc(freq, amp)
  instance(phase, out)
(
  phase = phase+(freq/srate);
  (phase >= 1.0) ? phase -= 1.0;
  out = (phase * 2 - 1) * amp;
);

@sample

osc1.osc(400, 0.25);
osc2.osc(600, 0.25);
out = osc1.out + osc2.out;

spl0 = out + spl0;
spl1 = out + spl1;
It makes the phase and output instance variables from the caller (osc1, osc2) instead of global variables.

Do note that this will produce a non-bandlimited (naive) saw, so it will alias pretty bad. Also, this code could be optimized...
Tale is offline   Reply With Quote
Reply

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump


All times are GMT -7. The time now is 11:25 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2018, vBulletin Solutions Inc.