Go Back   Cockos Incorporated Forums > REAPER Forums > REAPER General Discussion Forum

Reply
 
Thread Tools Display Modes
Old 02-08-2018, 03:36 PM   #1
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default JSFX tutorial for the total Newbie - guide

So I wrote a MIDI Note to CC plugin recently, and I thought I'd write a guide to how it's done.

I cover everything from basic MIDI concepts, to JSFX basics, to programming basics etc... I assume that the only thing you know is what Reaper is, how to create a text file and how to type.

There's no ads or anything on my site. So this is totally free unless you feel obliged to donate. (or become a patreon)

If you have any comments, questions or just want to berate me then I'm welcome to hear it. Thanks!

http://admiralbumblebee.com/music/20...m-scratch.html

p.s. I posted it here rather than the JSFX&ReaScript forum so that people _not_ generally interested in scripting already can see it.

EDIT - I don't even assume you know how to create a text file any more. The Tutorial is now 33% easier! (I'm sure that math works out)

Last edited by Robert Randolph; 02-08-2018 at 09:25 PM.
Robert Randolph is offline   Reply With Quote
Old 02-08-2018, 04:11 PM   #2
domzy
Human being with feelings
 
Join Date: Feb 2017
Posts: 4,823
Default

cheers! i'll check it out.
domzy is offline   Reply With Quote
Old 02-08-2018, 06:51 PM   #3
Melvin J.
Human being with feelings
 
Melvin J.'s Avatar
 
Join Date: Apr 2010
Location: South West Michigan
Posts: 256
Default

Dude, you are the shit! I'm definitely going to dive into this as I've been wondering for a while now on how to program a JS. Thanks!
__________________
ADK Laptop Intel i7 2860QM, 8 GB RAM, Avid MBOX Pro 3 (BLA Modified), Novation Remote SL37, DSI Mopho, DSI Tempest, Trilian, Aether 1.5.1, Valhalla, Nerve, Komplete 7
Melvin J. is offline   Reply With Quote
Old 02-08-2018, 07:35 PM   #4
Justin
Administrator
 
Justin's Avatar
 
Join Date: Jan 2005
Location: NYC
Posts: 15,721
Default

Awesome, thank you! Reading now...

Some comments:
  • you can create a new JSFX from the FX browser (avoiding having to use an external text editor).
  • this was undocumented (oops, fixed), but rather than using
    Code:
    ccValue = slider1;
    You can do:
    Code:
    slider1:ccValue=0<0,127,1>CC to send
    (supported in REAPER 5.0+)
  • You can also debug JSFX by using Ctrl/Cmd+K on a symbol to read its value (or if it points to memory, it will show you the value at that point in memory).
  • JSFX can't actually be used to write video processors, but the language is the same for video processors (as well as EEL ReaScripts).
  • I might ask you to ditch that askjf link if I get enough noise...

Last edited by Justin; 02-08-2018 at 08:09 PM.
Justin is offline   Reply With Quote
Old 02-08-2018, 09:22 PM   #5
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by Justin View Post
Awesome, thank you! Reading now...

Some comments:
  • you can create a new JSFX from the FX browser (avoiding having to use an external text editor).
  • this was undocumented (oops, fixed), but rather than using
    Code:
    ccValue = slider1;
    You can do:
    Code:
    slider1:ccValue=0<0,127,1>CC to send
    (supported in REAPER 5.0+)
  • You can also debug JSFX by using Ctrl/Cmd+K on a symbol to read its value (or if it points to memory, it will show you the value at that point in memory).
  • JSFX can't actually be used to write video processors, but the language is the same for video processors (as well as EEL ReaScripts).
  • I might ask you to ditch that askjf link if I get enough noise...

Awesome. I updated everything you listed and switched the askjf link.

Thank you very much for reading and the corrections! I feel annointed by the Holy Reaper Seer now.
Robert Randolph is offline   Reply With Quote
Old 02-08-2018, 11:30 PM   #6
lolilol1975
Human being with feelings
 
Join Date: Dec 2015
Posts: 1,739
Default

Quote:
Originally Posted by Robert Randolph View Post
So I wrote a MIDI Note to CC plugin recently, and I thought I'd write a guide to how it's done.

I cover everything from basic MIDI concepts, to JSFX basics, to programming basics etc... I assume that the only thing you know is what Reaper is, how to create a text file and how to type.

There's no ads or anything on my site. So this is totally free unless you feel obliged to donate. (or become a patreon)

If you have any comments, questions or just want to berate me then I'm welcome to hear it. Thanks!

http://admiralbumblebee.com/music/20...m-scratch.html

p.s. I posted it here rather than the JSFX&ReaScript forum so that people _not_ generally interested in scripting already can see it.

EDIT - I don't even assume you know how to create a text file any more. The Tutorial is now 33% easier! (I'm sure that math works out)
You rock, man ! Awesome blog btw.
lolilol1975 is offline   Reply With Quote
Old 02-09-2018, 12:25 AM   #7
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Cool!

A very minor nitpick, but it might be worth mentioning anyway: You can also write hex numbers as e.g. 0x90 instead of $x90. This is more in line with other programming languages e.g. C/C++, JavaScript, etc. This does require REAPER v4.25+.
Tale is offline   Reply With Quote
Old 02-09-2018, 01:11 AM   #8
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Very nice !

I hope it will help users to make their own modes :P

What's next step ?
Audio Processing ?
GFX ? :P
X-Raym is offline   Reply With Quote
Old 02-09-2018, 09:28 AM   #9
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by Tale View Post
Cool!

A very minor nitpick, but it might be worth mentioning anyway: You can also write hex numbers as e.g. 0x90 instead of $x90. This is more in line with other programming languages e.g. C/C++, JavaScript, etc. This does require REAPER v4.25+.
Thanks. I wasn't aware of that.

I picked up the $x notation (and most of the JSFX syntax) by reading through other scripts.

Unfortunately I don't think I can fully correct the $x usage, since there's so many screenshots that use the $x notation. I will update the post to mention it though.
Robert Randolph is offline   Reply With Quote
Old 02-11-2018, 04:03 AM   #10
Tale
Human being with feelings
 
Tale's Avatar
 
Join Date: Jul 2008
Location: The Netherlands
Posts: 3,645
Default

Quote:
Originally Posted by Robert Randolph View Post
Unfortunately I don't think I can fully correct the $x usage, since there's so many screenshots that use the $x notation.
Of course! I guess in the end it's more of a personal preference anyway.

Quote:
Originally Posted by Robert Randolph View Post
I will update the post to mention it though.
Cool. Do note however that is should be 0x0F, not just x0F.
Tale is offline   Reply With Quote
Old 02-11-2018, 05:56 AM   #11
martifingers
Human being with feelings
 
Join Date: May 2011
Posts: 2,694
Default

As pretty much your target audience I think it was very generous of you to share your time and expertise. As to the content, the best compliment I can pay you would be to say you may be the Kenny of the JSFX world!
martifingers is offline   Reply With Quote
Old 02-11-2018, 07:17 AM   #12
JHughes
Banned
 
Join Date: Aug 2007
Location: Too close to Charlotte, NC
Posts: 3,554
Default

Thank you, your work is very much appreciated Mr. Randolph.
JHughes is offline   Reply With Quote
Old 02-11-2018, 03:24 PM   #13
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,688
Default

Robert,
To me you are a genius to have crafted this in just eight hours !

I'd just like to provide some nitpicking:

I think it should be mentioned that variable names are case insensitive.

"output CC value 128". This is nechnically not correct and might be confusing.

"the rule is from right to left" IMHO this is not correct.

"MIDI is processed in blocks too. I think it is worth mentioning that Misdi uses the same (i.e. the audio-) blocks and does not have it's own blocking.

"3 word messages": All midi messages are 3 words. Only the very special SysEx messages use another count.

"The first data byte is B0". This should be noted as hexadecimal and OTOH the Midi channel can be arbitrary.


"abs(ccMsg - 127)". for me this is a rather funny way to do the "inversion". More obvious would be just "127 - ccMsg".

BTW.: Itthis might be horribly old school, but I'd like to be able to d/l such documents as PDF.

Thanks for listen (and of course the great work).
-Michael
mschnell is online now   Reply With Quote
Old 02-11-2018, 09:15 PM   #14
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by mschnell View Post
Robert,
To me you are a genius to have crafted this in just eight hours !

I'd just like to provide some nitpicking:

I think it should be mentioned that variable names are case insensitive.

"output CC value 128". This is nechnically not correct and might be confusing.

"the rule is from right to left" IMHO this is not correct.

"MIDI is processed in blocks too. I think it is worth mentioning that Misdi uses the same (i.e. the audio-) blocks and does not have it's own blocking.

"3 word messages": All midi messages are 3 words. Only the very special SysEx messages use another count.

"The first data byte is B0". This should be noted as hexadecimal and OTOH the Midi channel can be arbitrary.
I intentionally used CC from 1-128 and 0-127 in different places. I originally had the whole article as 0-127 and two of my proofreaders found that confusing. I'll double check this again and see if I can add clarity.

Regarding right to left, I can see how this can be confusing (totally incorrect) regarding operator associativity and execution order. The example was given to help people navigate parenthesis... I will rewrite that section. In hindsight it's definitely not optimal.

No mention of audio in this

Regarding the 3 word messages, is this the line that you're referring to "In this tutorial we are going to deal with 3 ‘word’ messages"? I specifically used this wording since system messages (opposed to channel messages) can have more or less than 2 bytes. I will adjust the wording to be more clear.

I don't use hexadecimal notation anywhere except in code. I choose this because I thought the extra notation would be potentially confusing outside the context of code. If I realized that jsfx allows 0x notation instead of $x then I would have used 0x everywhere. I'm not sure about changing this now?

Quote:
Originally Posted by mschnell View Post

"abs(ccMsg - 127)". for me this is a rather funny way to do the "inversion". More obvious would be just "127 - ccMsg".
I just want to point out that this one is intentional. I wanted to introduce the ideal of using a math function somewhere, and it was a contrived example.

Quote:
Originally Posted by mschnell View Post
BTW.: Itthis might be horribly old school, but I'd like to be able to d/l such documents as PDF.

Thanks for listen (and of course the great work).
-Michael
Your browser should be able to save as PDF?

I'll investigate if there's an easy way to convert the content though.

Thank you for the feedback. I will adjust a number of these things.

edit: It'll all be fixed when tomorrow's post goes up. Thank you again!

Last edited by Robert Randolph; 02-11-2018 at 09:20 PM.
Robert Randolph is offline   Reply With Quote
Old 02-12-2018, 01:07 AM   #15
mschnell
Human being with feelings
 
mschnell's Avatar
 
Join Date: Jun 2013
Location: Krefeld, Germany
Posts: 14,688
Default

Quote:
Originally Posted by Robert Randolph View Post
Your browser should be able to save as PDF?
I'll investigate if there's an easy way to convert the content though.
"Printing" in a Browser (e.g. to PDF) mostly results in horrible outcome, so I did not even try. I selected your text, pasted into LibreOffice writer, and saved it as PDF. This worked perfectly.

"No mention of audio in this" Maybe it is enough to say something like this: "Midi messages are managed in the same blocks".

Thanks for listeng !

BTW, as you might know I maintain the current version of the "LiveConfigs" user guide. I'd like to link to your tutorial there. Is the given url the final destination it will reside in ?

Thanks again,
-Michael

Last edited by mschnell; 02-12-2018 at 03:36 AM.
mschnell is online now   Reply With Quote
Old 02-12-2018, 06:32 AM   #16
X-Raym
Human being with feelings
 
X-Raym's Avatar
 
Join Date: Apr 2013
Location: France
Posts: 9,875
Default

Quote:
I'll investigate if there's an easy way to convert the content though.
PDFCreator may do the trick.
X-Raym is offline   Reply With Quote
Old 02-12-2018, 09:28 AM   #17
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by mschnell View Post
BTW, as you might know I maintain the current version of the "LiveConfigs" user guide. I'd like to link to your tutorial there. Is the given url the final destination it will reside in ?

Thanks again,
-Michael
Yes, that's the URL it will be. It won't change.
Robert Randolph is offline   Reply With Quote
Old 02-12-2018, 01:21 PM   #18
pbattersby
Human being with feelings
 
pbattersby's Avatar
 
Join Date: Jun 2012
Posts: 348
Default

Quote:
Originally Posted by Robert Randolph View Post
So I wrote a MIDI Note to CC plugin recently, and I thought I'd write a guide to how it's done.
Well done. I imagine creating that tutorial was a lot of work. If/when I decide I want to write a plugin, I'll be back to work through the tutorial in detail.

Note, the link in this text near the top of the tutorial:

"This tutorial really isn’t for you, but maybe you can skip to results to see what happened."

... needs to target the anchor #result (singular) rather than the anchor #results (plural) which doesn't exist.

Despite having clicked that link, the tutorial is for me (even though I'm an experienced programmer), I was curious to skip to the end then come back or the beginning.
__________________
Paul Battersby
Virtual Playing Orchestra - free sample library @ http://virtualplaying.com
pbattersby is offline   Reply With Quote
Old 02-12-2018, 06:59 PM   #19
pipelineaudio
Mortal
 
pipelineaudio's Avatar
 
Join Date: Jan 2006
Location: Wickenburg, Arizona
Posts: 14,047
Default

Thank you for this, this is awesome!
pipelineaudio is offline   Reply With Quote
Old 02-12-2018, 08:16 PM   #20
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by pbattersby View Post
Well done. I imagine creating that tutorial was a lot of work. If/when I decide I want to write a plugin, I'll be back to work through the tutorial in detail.

Note, the link in this text near the top of the tutorial:

"This tutorial really isn’t for you, but maybe you can skip to results to see what happened."

... needs to target the anchor #result (singular) rather than the anchor #results (plural) which doesn't exist.

Despite having clicked that link, the tutorial is for me (even though I'm an experienced programmer), I was curious to skip to the end then come back or the beginning.
Great catch on that anchor mistake.

I'm fixing it now!
Robert Randolph is offline   Reply With Quote
Old 02-12-2018, 10:02 PM   #21
michaeltonight
Human being with feelings
 
michaeltonight's Avatar
 
Join Date: Jun 2010
Location: Texas
Posts: 357
Default

Whoa! Thank you so much for this! Exactly what I needed, exactly when I needed it!
michaeltonight is offline   Reply With Quote
Old 02-13-2018, 12:33 PM   #22
cyrilfb
Human being with feelings
 
cyrilfb's Avatar
 
Join Date: Apr 2012
Location: Denver, CO
Posts: 249
Default Great Work!

Thanks for this. The level of detail will help many of us.
__________________
Cy Ball
Reaper + inspiration = music.
soundcloud.com/cyball or cyball.bandcamp.com/ or cyrilfb.com
cyrilfb is offline   Reply With Quote
Old 02-14-2018, 09:43 AM   #23
Robert Randolph
Human being with feelings
 
Robert Randolph's Avatar
 
Join Date: Apr 2017
Location: St. Petersburg, FL
Posts: 880
Default

Quote:
Originally Posted by mschnell View Post
"Printing" in a Browser (e.g. to PDF) mostly results in horrible outcome, so I did not even try. I selected your text, pasted into LibreOffice writer, and saved it as PDF. This worked perfectly.

"No mention of audio in this" Maybe it is enough to say something like this: "Midi messages are managed in the same blocks".

Thanks for listeng !

Thanks again,
-Michael
I've spent an inordinate amount of time trying to get PDF rendering to work on my side.

Sadly it doesn't appear that it can happen currently due to various factors.

I'll have it in the back of my mind. Maybe I'll randomly come up with a solution while baking some potatoes or something. That happens a lot.
Robert Randolph is offline   Reply With Quote
Old 12-03-2020, 06:16 AM   #24
wadewatts
Human being with feelings
 
Join Date: Nov 2020
Location: depends
Posts: 23
Default <3

Robert Randolph

thanks you very much for this, man!
wadewatts 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 03:56 PM.


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