[RWP] Emailing: REAPER ReaScript.htm

Jim Noseworthy jim.noseworthy at compuconference.com
Tue Feb 12 10:00:31 EST 2013


Hi Folks:

 

I found this information and copied it to this email wondering if RayScript
can bring better access to Reaper.

 

ReaScript 

.
<http://www.reaper.fm/sdk/reascript/reascript.php#reascript_intro>
Introduction 

.
<http://www.reaper.fm/sdk/reascript/reascript.php#reascript_requirements>
Requirements 

.          <http://www.reaper.fm/sdk/reascript/reascript.php#reascript_doc>
ReaScript Documentation and Reference 

.          <http://www.reaper.fm/sdk/reascript/reascript.php#reascript_run>
Running ReaScripts 

.
<http://www.reaper.fm/sdk/reascript/reascript.php#reascript_actions> Calling
REAPER Actions 

.          <http://www.reaper.fm/sdk/reascript/reascript.php#reascript_ext>
ReaScript API 

.          <http://www.reaper.fm/sdk/reascript/reascript.php#reascript_adv>
Advanced 






  _____  

top  Introduction 

ReaScript is a feature that allows you to run Python scripts within REAPER.
>From within the script, you can call any REAPER action, and also call back
into most of the REAPER API functions (the same API used by compiled REAPER
plug-ins and extensions). ReaScript can be used to create anything from
advanced macros to full-featured REAPER extensions. 

Note: REAPER on Windows formerly supported Perl scripts as well, but Perl
support was removed in REAPER version 4.14. ReaScript Perl will be
reinstated when/if the Perl  <http://gitorious.org/perl-ctypes> ctypes
project is complete. 

  _____  

top  Requirements 

To use ReaScript, you must have Python installed on your computer. ReaScript
should work with any version of Python between 2.7 and the current 3.x
release. 

OS X normally comes with Python already installed. If you don't already have
Python, it is available as a free download for Windows or Mac from multiple
sources. For 32-bit REAPER, you need 32-bit Python (regardless of the
operating system). For 64-bit REAPER, you need 64-bit Python. 

A list of Python distributions is  <http://www.python.org/download/> here. 

Once Python is installed, REAPER should automatically detect it, and
ReaScript will work. If REAPER does not detect Python, you can enter the
Python install directory in REAPER preferences, under Plug-Ins/ReaScript. 

  _____  

top  ReaScript Documentation and Reference 

>From within REAPER, under the Help menu, choose "HTML lists/ReaScript
documentation". This will open a web page with some basic documentation, and
a complete list of all REAPER API functions that can be called from
ReaScript. 

There is extensive online documentation for  <http://docs.python.org/>
Python 2 and  <http://docs.python.org/py3k/> Python 3. 

  _____  

top  Running ReaScripts 

You will need to either write a script, or copy a script from another user.
Scripts can be placed anywhere on your disk, but it's convenient to keep
them all in the REAPER/Scripts application data directory. 

To write a new script, show the Actions list (bound to the ? key by
default), and click ReaScript: New/Load. You will be prompted for the
location to save your new script. The default location is the recommended
REAPER/Scripts application data directory. Name your script something like
test.py, then click ReaScript: Edit. A text editor will open. 

The simplest possible ReaScript is:

RPR_APITest()

Save the ReaScript, and then click Run. You should see a window that says
"Test OK". Common reasons for the script failing are: 

*	Python not installed 
*	REAPER cannot find the installed Python 
*	Syntax error (typo, missing newline, incorrect indentation in
Python) 

You can treat a ReaScript just like any custom action: bind it to a key
shortcut, MIDI controller, or toolbar button. ReaScripts can also be run a
la carte, via the actions "ReaScript: run..." and "ReaScript: run last
script". 

  _____  

top  Calling REAPER Actions 

You can call any REAPER action from ReaScript by using the API function

RPR_Main_OnCommand(actionnumber, 0)

Find the action number for a given action by opening the Actions list, and
scrolling the window right to reveal an extra column. For example, from
ReaScript you would call the REAPER action "Item: Split item under mouse
cursor" like this:

RPR_Main_OnCommand(40746, 0)

If you use ReaScript as an advanced macro language, this is the only API
function you need to know. 

  _____  

top  ReaScript API 

ReaScripts also have access to most of the
<http://www.reaper.fm/sdk/plugin/plugin.php> REAPER Extension API functions.
For a list of all API functions available to ReaScripts, see the built-in
ReaScript documentation. That help page will explain the basics of how to
call API functions, which may require idiosyncratic syntax, because API
functions can return information in the parameter list as well as the
function return value. For convenience, there are also basic API functions
for getting information from, and showing information to, the user. 

  _____  

top  Advanced 

You can set a custom editor for Python scripts in REAPER's
Preferences/External Editors, by assigning an application to the ".py"
extension. 

ReaScripts can keep persistent state by using the API functions
RPR_SetExtState() and RPR_GetExtState(). This allows ReaScripts to set
key/value pairs (similar to a Python dictionary) that will persist between
ReaScripts, and optionally persist between REAPER instances as well. For
example, a module called "utility" might want to remember that some flag is
set: 

RPR_SetExtState("utility", "someflag", "2", True)
val=RPR_GetExtState("utility", "someflag") # even if called after REAPER is
closed and reopened, val will be equal to "2" 

You can create and save modules of useful functions that you can import into
other ReaScripts. For example, if you create a file called
reascript_utility.py that contains the function helpful_function(), you can
import that file into any ReaScript with the line 

import reascript_utility 

and call the function by using 

reascript_utility.helpful_function() 

Note that reascript_utility.py must itself import reaper_python, with the
line 

from reaper_python import * 

(Although it is not required, it is good practice to start all ReaScripts
with that line.) 

  _____  


For more help on ReaScript, to report bugs, to request additional API
functions, to share ReaScripts, or just to discuss the possibilities, please
use the 
 <http://forum.cockos.com/forumdisplay.php?f=3> REAPER ReaScript Forum. 

http://www.reaper.fm/siteimages/to_top.jpg

 <http://www.reaper.fm/index.php> Home 

 <http://www.cockos.com/company.php> Company 

 <http://www.reaper.fm/reviews.php> Reviews 

 <http://www.reaper.fm/about.php> About 

 <http://www.reaper.fm/aboutusers.php> Uses 

 <http://www.reaper.fm/aboutaudio.php> Audio 

 <http://www.reaper.fm/aboutmidi.php> MIDI 

 <http://www.reaper.fm/technical.php> Technical 

 <http://www.reaper.fm/download.php> Download 

 <http://www.reaper.fm/userguide.php> User Guide 

 <http://www.reaper.fm/download-old.php> Old Versions 

 <http://www.reaper.fm/reaplugs/index.php> ReaPlugs 

 <http://www.reaper.fm/purchase.php> Purchase 

 <http://www.reaper.fm/dist-agreement.php> Distribution 

 <http://www.reaper.fm/reference.php> Developer 

 <http://www.reaper.fm/sdk/walter/walter.php> Theme Development 

 <http://www.reaper.fm/sdk/cursors/cursors.php> Custom Cursors 

 <http://www.reaper.fm/sdk/js/js.php> JS Programming 

 <http://www.reaper.fm/sdk/reascript/reascript.php> . ReaScript 

 <http://www.reaper.fm/sdk/plugin/plugin.php> Extensions SDK 

 <http://www.reaper.fm/sdk/vst/vst_ext.php> Extensions to VST SDK 

 <http://www.reaper.fm/sdk/osc/osc.php> OSC 

 <http://www.reaper.fm/resources.php> Resources 

 <http://www.reaper.fm/forum.php> Forum 

 <http://stash.reaper.fm> Stash 

 <http://www.reaper.fm/wiki.php> Wiki 

C 2005-2012 Cockos Incorporated 

-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://bluegrasspals.com/pipermail/rwp/attachments/20130212/0ae52a82/attachment.html>
-------------- next part --------------
A non-text attachment was scrubbed...
Name: image003.jpg
Type: image/jpeg
Size: 926 bytes
Desc: not available
URL: <http://bluegrasspals.com/pipermail/rwp/attachments/20130212/0ae52a82/attachment.jpg>


More information about the Rwp mailing list