Getting Started/es and Js programming: Difference between pages

From Reaper Accessibility Wiki
(Difference between pages)
Jump to navigation Jump to search
(Created page with "REAPER tiene soporte en todas las versiones de Windows, desde XP hasta 10, y todas las versiones de macOS, desde la 10.5 hasta la 10.12. REAPER puede descargarse gratis y usarse hasta por 60 días antes de que sea necesario comprar una licencia. Esto te dará el tiempo suficiente para aprender el programa. El costo de una licencia de REAPER es muchísimo menor que el de otras Estaciones de Trabajo de Audio Digitales (DAWs). Más información sobre la adquisición de una...")
 
 
Line 1: Line 1:
¡Hola! Esta página te guiará a través de la instalación de Reaper y las extensiones que lo hacen lo más accesible posible, te mostrará cómo probar que todo se haya instalado correctamente, luego te impulsará hacia otras páginas que probablemente resulten de utilidad.
=js Programming=


Si no te animas tanto a leer texto , [https://theglobalvoice.info/reaper puedes ir al proyecto de reaper made easy para tutoriales de audio en inglés].  
== Introduction ==
js plugins are Reaper's own plugin format similar in many ways to VST plugins.  A js plugin can process and generate audio and midi data and expose parameters to the user which can be automated.


<span id="Downloading_and_installing_Reaper"></span>
js plugins have a number of advantages such as easy to start writing, all parameters are exposed and these parameters are easy to interact with via a keyboard either directly in the user interface or by the OSARA parameter dialogue.  They also support graphics making them good for sighted users and it is also possible to add keyboard support though this is almost vanishingly rare.  Disadvantages are around limited to non-existent file handling.
== Descargando e instalando REAPER ==


REAPER tiene soporte en todas las versiones de Windows, desde XP hasta 10, y todas las versiones de macOS, desde la 10.5 hasta la 10.12. REAPER puede descargarse gratis y usarse hasta por 60 días antes de que sea necesario comprar una licencia. Esto te dará el tiempo suficiente para aprender el programa. El costo de una licencia de REAPER es muchísimo menor que el de otras Estaciones de Trabajo de Audio Digitales (DAWs). Más información sobre la adquisición de una licencia se puede encontrar en la [http://reaper.fm/purchase.php  página web oficial de REAPER].
== View and existing js plugin ==
js plugins are written in plain text files and there are plenty to take a look at.  From the Reaper Help Options menu select Resource path.  In here is a folder called "Effects" in which are all the js plugins that come with Reaper.


Al abrir el siguiente enlace debes descargar el archivo apropiado dependiendo del sistema operativo que uses: Windows o Mac, 32 o 64 bits. REAPER existe en ambas versiones. Muchos computadores hoy en día vienen con sistemas operativos de 64 bits instalados, así que puedes descargar sin problema la versión de 64 bits que aprovecha el poder de procesamiento extra de tu computador.
Typically a js plugin either has no file extension or an extension of jsfx.  Use your favourite plain text editor to open up any of the files to see what they look like.
[https://www.reaper.fm/download.php  Descargar REAPER] (sitio externo).


<div lang="en" dir="ltr" class="mw-content-ltr">
It is useful to turn the vebosity of your screen reader so it speaks all characters.  It is important to capture all the code when programming.  For example, a semicolon is required at the end of each command and most people dont set their screen reader to announce these.
Launch the installer file that you have downloaded and follow the relevant setup instructions, [[chapter 1: Setting Up and Getting Started#1.4 The Install Options (Windows only)|and optionally configure the installation to your liking (windows only)]]. After you finish the installation, you are ready  to move on to installing Osara.
</div>


In NVDA, the verbosity can be cycled with NVDA+P.


<div lang="en" dir="ltr" class="mw-content-ltr">
== Structure of a plugin ==
== downloading and installing OSARA ==
A js plugin is made up of a header and then a series of sections which have a predefined named and purpose.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
OSARA is a REAPER extension which aims to make REAPER accessible to screen reader users. It runs on both Windows and Mac. It is built to work with the [https://www.nvaccess.org/ free NVDA screenreader] on Windows and VoiceOver on the Mac, however there are also people successfully using it with [http://www.freedomscientific.com/Products/Blindness/JAWS JAWS screenreader] on Windows. If you are using JAWS, you may wish to [https://snowmanradio.com/reaper download Snowman's Reaper Jaws Scripts here].
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The header can be as short as a declaration of the name of the plugin but can also hold much more information such as the author, date, version, release notes, instructions on usage and other information that helps with reaPack integration.
Dolphin SuperNova now also offers support for Reaper with OSARA.  Map and script data can be obtained via SuperNova's online updating  feature.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
[https://osara.reaperaccessibility.com/snapshots/ Download either the Mac or Windows version of the OSARA installer from this link.]
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The header is followed by definition of the plugin parameters which is done by defining a slider for each parameter.  A slider has a min value, a max value, an increment value and a default value.  These are seen by the user in the plugin user interface as a slider and edit box for each parameter.
As always, make sure reaper is also up to date so you can take full advantage of osara's functionality. You can also follow [https://github.com/jcsteh/osara/commits/master what's new in osara,] be sure to check this from time to time.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Basic installation instructions below, however, for additional instructions and information on Osara, see the main osara page at https://osara.reaperaccessibility.com/
</div>


The @init block is run when the plugin first starts which is typically when it is first loaded onto an FX chain and when play starts. It is used to initialise variables to default values.  Note that the js plugin language does not require variables to be declared before they are used so this section does not need to include initialisation of all variables if this is done elsewhere.  Also, the default initialisation of a variable is to set it to zero.


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Windows Osara Installation ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The @slider block is run whenever a parameter is changed either through automation or by the user.  For example, a parameter might be presented to the user as a percentage from 0 to 100 but the code needs this rescaling from -1 to 1.
Open the OSARA installer, leaving all the options to their default values, (keep clicking next).
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
At the end, reaper and osara should be set up and configured to work together with each other. By leaving the options at the defaults, you will have also installed the Osara key map.
*note: You can decide not to install the key map during the set up process, by toggling a checkbox. This is useful in situations when osara is updated or you already have a favorite set of hotkeys assigned. The osara key map will still be copied in case you wish to integrate the shortcuts from it later on into an existing key map.
</div>


The @block code is run as a new block of samples arrives.  The block size as defined in Reaper preferences in the devices section dictates how many sampless.  This is an area of code commonly used to process MIDI as all the MIDI notes and events coming up in the next block of samples can be processed and action taken accordingly.  Also, MIDI notes and events can be inserted so they are played once the block enters Reaper's play buffer.


<div lang="en" dir="ltr" class="mw-content-ltr">
=== Mac OSARA Installation ===
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The@sample block is run every sample.  So yes, many thousands of times a second.  Commonly used to process audio as there is easy access to the value of the audio in each channel.
Currently the method of installing Osara on the Mac is a bit different from other Mac applications. There is no standard install package, because OSARA is an extension, not an app.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Download the DMG and open.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
The @gfx block is used to draw graphics and process keyboard input.  I'm not sure when it is run.
Use VO+Shift+M to Open the "Install OSARA.command" file. This runs in Terminal.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
== First Audio Plugin ==
When VoiceOver informs you that Terminal has launched in the background, use Command+Tab to switch to it, and follow the installation prompts.
Let's dive in with a very simple js plugin that includes a volume control for audio.  Open up a plain text editor and copy and paste the following code into it.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Note that sometimes, you might need to use VoiceOver's Window Chooser feature in Terminal to bring the installation prompts into focus. Window Chooser is accessed by hitting VO+F2 twice quickly.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Desc: My first audio plugin
If Mac OS complains about OSARA being an unknown extension when you open reaper, allow it to run in the Security and Privacy pane of System Preferences.
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
== SWS Extension (optional but recommended) ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
slider:100<0,100,1>Volume
the [http://www.sws-extension.org/ sws extenssion] is a plug-in that adds a large number of actions, in other words, it extends the functionality of Reaper substantially.  and is free. It is highly recommended as Osara takes advantage of some of the added actions. When installing the SWS extension, follow the relevant instructions for your operating system as described on the Standing Water Studios (SWS) website. There are no actual setup options on the installer, so installing it by leaving everything in their defaults should get you up and running.
</div>




<div lang="en" dir="ltr" class="mw-content-ltr">
@slider
== testing it all together ==
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
scaler = slider1/100;
To make sure that osara is installed and working, first launch reaper from the shortcut that has been created on your desktop (Windows), or from the Applications folder (Mac). The shortcut name for reaper 32 bit is just simply reaper, whereas for systems that use 64 bit reaper the name of the shortcut will be reaper (x64).
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Once you have launched reaper, you will come across a dialog that states that reaper is not free, and asks you if you would like to buy the software or evaluate it. At this time, you should move through the dialog to the button called "still evaluating". This screen does not appear again until the next day you run the program, even if you close and open it again, or until you eventually buy a license. If you have tabbed and cannot find the still evaluating button, wait a few seconds and try tabbing again, since the dialog is designed to show you the message for a few seconds to remind you to buy the program. Once you open reaper, you will hear the program name, the version number, and some other information, like such, (editors note: how is this actually heard on the mac?)
:
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
@sample
REAPER v5.50/x64 - (not registered)
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
spl0 *= scaler;
or,
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
spl1 *= scaler;
REAPER v5.50/x64 - Registered to Jhon Doe (Licensed for personal/small business  use)
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
in this case, this means that you have a blank project file already open. To test that osara is working properly, you should press either down or up arrow, which are the keyboard shortcuts to move to next and previous track respectively. At this point, you should hear your screen reader say, "no tracks".
</div>


<div lang="en" dir="ltr" class="mw-content-ltr">
Save this in the Reaper resources Effects folder, ideally in a new subfolder to contain all your plugins.  Start up Reaper and it should do a rescan and make your new js plugin available to use.
So now that you are ready, its time to learn a few basics (exactly which ones? see discussion page), plus a few specific [[Special:MyLanguage/Keyboard Shortcuts|Keyboard Shortcuts]] so we will start out with "create page" which will help you understand how reaper exactly works.
 
</div>
 
Create a track and add some audio to it for example recording yourself speaking, by inserting an audio file or selecting something from media explorer.  Hit F on the track to bring up the FX chain dialogue and use the Add button to add your plugin.  Type in "first" as this is text included in the first line of the code copied into the plugin and is the name given to the plugin.  Arrow down and you should find the plugin.  Hit enter and it will get loaded onto the FX chain for the track.  Press tab to work your way through the plugin and you will come to the slider and edit controls for the volume parameter.
 
 
Press space to play the audio and then adjust the volume with either the slider or entering a new value in the edit field.  The volume changes.  Your first plugin.
 
== First MIDI Plugin ==
Here is a simple plugin that has a slider to change the pitch of any incoming MIDI notes.  The minimum code for MIDI is a little more than for audio.
 
 
Desc: My first MIDI js plugin
 
 
slider:0<-24,24,1>Semitone shift
 
 
@slider
 
shift = slider1;
 
 
@block
 
while( midirecv( offset, msg1, msg2, msg3 ) )
 
(
 
  msg1 & 0xF0 = 0x90 ?
 
  (
 
   midisend( offset, msg1, msg2 + shift, msg3 );
 
  )
 
  :
 
  (
 
   midisend( offset, msg1, msg2, msg3 );
 
  );
 
);
 
 
In the same way as with the audio plugin, copy this code into a plain text file and save it in the Effects subfolder in the Reaper resource path ideally in your own subfolder holding all your plugins. Start up Reaper so it does a rescan and then insert reaSynth onto a track as as a VSTi.  Test you can play notes.  Now add your first MIDI plugin onto this track as well.  Before it has any effect thugh yu need to move reaSynth so it is below your first MIDI plugin since the plugin needs to update the MIDI data between it being played and it arriving at reaSynth.  Do this by either cutting and pasting reaSynth so it is second in the chain, or using the action bound to control-shift alt page down (Windows).
 
 
Tab to the Semitone shift slider in your new plugin. Play a note and then change the slider.  The pitch of notes is shifted.
 
== Tools to help write plugins ==
The most basic tool is your plain text editor of choice.  Reaper does have an inbult editor but it is not easily accessible.  So writing code in a plain text editor is the next best thing.  If you make a change to your code and save it though, you will need to return to Reaper and the FX chain , press contrl R on your plugin and replace the plugin with a new instance of itself to for the changes take effect.
 
 
It is possible to view all the variables used in a plugin along with their values.  This can be done with NVDA object navigation by tabbing to the edit button in the FX dialogue, hitting enter , and uing object navigation to move right until a list control is reached.  Gone down and you can then review each variable.
 
 
Debugging is difficult though in js plugins.  There is no option to display a message box or output diagnostic info to a file. And some variables will change their value with every sample or every block making them impossible to track.  You cannot step through the code one line at a time reviewing variable values like you can in more complex IDE's.
 
==Resources ==
 
There are not a whole bunch of great resources for writing js plugins.  Probably the most comprehensive source of information are all the plugins that come with Reaper and found in the Effects folder.  But these can be complex and difficult to work out how they work.
 
There is a good tutorial made by [https://www.admiralbumblebee.com/music/2018/02/08/Write-a-Reaper-MIDI-JSFX-from-scratch.html Admiral Bumblebeee] which goes through a modestly complex project to write a MIDI plugin.  There is also other useful content on this web site.
 
[https://www.reaper.fm/sdk/js/basiccode.php#js_basic The JSFX Programming Reference - Language Essentials] is on Reaper's web site.  It is a reference manual though and not a tutorial but if you get into JSFX programming you will come to appreciate this resource.
 
The Reaper community are a helpful bunch.  [https://forum.cockos.com/forumdisplay.php?f=3 The JSFX forum]. Use the search feature or search with something like Google putting reaper jsfx forum in as part of your search.  Sign up to post a question. 

Revision as of 19:45, 7 November 2023

js Programming

Introduction

js plugins are Reaper's own plugin format similar in many ways to VST plugins.  A js plugin can process and generate audio and midi data and expose parameters to the user which can be automated.

js plugins have a number of advantages such as easy to start writing, all parameters are exposed and these parameters are easy to interact with via a keyboard either directly in the user interface or by the OSARA parameter dialogue.  They also support graphics making them good for sighted users and it is also possible to add keyboard support though this is almost vanishingly rare.  Disadvantages are around limited to non-existent file handling.

View and existing js plugin

js plugins are written in plain text files and there are plenty to take a look at.  From the Reaper Help Options menu select Resource path.  In here is a folder called "Effects" in which are all the js plugins that come with Reaper.

Typically a js plugin either has no file extension or an extension of jsfx.  Use your favourite plain text editor to open up any of the files to see what they look like.

It is useful to turn the vebosity of your screen reader so it speaks all characters.  It is important to capture all the code when programming.  For example, a semicolon is required at the end of each command and most people dont set their screen reader to announce these.

In NVDA, the verbosity can be cycled with NVDA+P.

Structure of a plugin

A js plugin is made up of a header and then a series of sections which have a predefined named and purpose.


The header can be as short as a declaration of the name of the plugin but can also hold much more information such as the author, date, version, release notes, instructions on usage and other information that helps with reaPack integration.


The header is followed by definition of the plugin parameters which is done by defining a slider for each parameter.  A slider has a min value, a max value, an increment value and a default value.  These are seen by the user in the plugin user interface as a slider and edit box for each parameter.


The @init block is run when the plugin first starts which is typically when it is first loaded onto an FX chain and when play starts. It is used to initialise variables to default values.  Note that the js plugin language does not require variables to be declared before they are used so this section does not need to include initialisation of all variables if this is done elsewhere.  Also, the default initialisation of a variable is to set it to zero.


The @slider block is run whenever a parameter is changed either through automation or by the user.  For example, a parameter might be presented to the user as a percentage from 0 to 100 but the code needs this rescaling from -1 to 1.


The @block code is run as a new block of samples arrives.  The block size as defined in Reaper preferences in the devices section dictates how many sampless.  This is an area of code commonly used to process MIDI as all the MIDI notes and events coming up in the next block of samples can be processed and action taken accordingly.  Also, MIDI notes and events can be inserted so they are played once the block enters Reaper's play buffer.


The@sample block is run every sample.  So yes, many thousands of times a second.  Commonly used to process audio as there is easy access to the value of the audio in each channel.


The @gfx block is used to draw graphics and process keyboard input.  I'm not sure when it is run.

First Audio Plugin

Let's dive in with a very simple js plugin that includes a volume control for audio.  Open up a plain text editor and copy and paste the following code into it.


Desc: My first audio plugin


slider:100<0,100,1>Volume


@slider

scaler = slider1/100;


@sample

spl0 *= scaler;

spl1 *= scaler;


Save this in the Reaper resources Effects folder, ideally in a new subfolder to contain all your plugins.  Start up Reaper and it should do a rescan and make your new js plugin available to use.


Create a track and add some audio to it for example recording yourself speaking, by inserting an audio file or selecting something from media explorer.  Hit F on the track to bring up the FX chain dialogue and use the Add button to add your plugin.  Type in "first" as this is text included in the first line of the code copied into the plugin and is the name given to the plugin.  Arrow down and you should find the plugin.  Hit enter and it will get loaded onto the FX chain for the track.  Press tab to work your way through the plugin and you will come to the slider and edit controls for the volume parameter.


Press space to play the audio and then adjust the volume with either the slider or entering a new value in the edit field.  The volume changes.  Your first plugin.

First MIDI Plugin

Here is a simple plugin that has a slider to change the pitch of any incoming MIDI notes.  The minimum code for MIDI is a little more than for audio.


Desc: My first MIDI js plugin


slider:0<-24,24,1>Semitone shift


@slider

shift = slider1;


@block

while( midirecv( offset, msg1, msg2, msg3 ) )

(

  msg1 & 0xF0 = 0x90 ?

  (

   midisend( offset, msg1, msg2 + shift, msg3 );

  )

  :

  (

   midisend( offset, msg1, msg2, msg3 );

  );

);


In the same way as with the audio plugin, copy this code into a plain text file and save it in the Effects subfolder in the Reaper resource path ideally in your own subfolder holding all your plugins. Start up Reaper so it does a rescan and then insert reaSynth onto a track as as a VSTi.  Test you can play notes.  Now add your first MIDI plugin onto this track as well.  Before it has any effect thugh yu need to move reaSynth so it is below your first MIDI plugin since the plugin needs to update the MIDI data between it being played and it arriving at reaSynth.  Do this by either cutting and pasting reaSynth so it is second in the chain, or using the action bound to control-shift alt page down (Windows).


Tab to the Semitone shift slider in your new plugin. Play a note and then change the slider.  The pitch of notes is shifted.

Tools to help write plugins

The most basic tool is your plain text editor of choice.  Reaper does have an inbult editor but it is not easily accessible.  So writing code in a plain text editor is the next best thing.  If you make a change to your code and save it though, you will need to return to Reaper and the FX chain , press contrl R on your plugin and replace the plugin with a new instance of itself to for the changes take effect.


It is possible to view all the variables used in a plugin along with their values.  This can be done with NVDA object navigation by tabbing to the edit button in the FX dialogue, hitting enter , and uing object navigation to move right until a list control is reached.  Gone down and you can then review each variable.


Debugging is difficult though in js plugins.  There is no option to display a message box or output diagnostic info to a file. And some variables will change their value with every sample or every block making them impossible to track.  You cannot step through the code one line at a time reviewing variable values like you can in more complex IDE's.

Resources

There are not a whole bunch of great resources for writing js plugins.  Probably the most comprehensive source of information are all the plugins that come with Reaper and found in the Effects folder.  But these can be complex and difficult to work out how they work.

There is a good tutorial made by Admiral Bumblebeee which goes through a modestly complex project to write a MIDI plugin.  There is also other useful content on this web site.

The JSFX Programming Reference - Language Essentials is on Reaper's web site.  It is a reference manual though and not a tutorial but if you get into JSFX programming you will come to appreciate this resource.

The Reaper community are a helpful bunch.  The JSFX forum. Use the search feature or search with something like Google putting reaper jsfx forum in as part of your search. Sign up to post a question.