hi all-- new to the forum, but have been using reaper for a while now. we are building an exhibit for a conference that goes up next week (tuesday oct 15, 2013). it plays coupled sounds and movies of earthquakes, and we have built an arduino-based Earthquake Control Box that sends four commands to the serial bus to run REAPER through a ReaScript--- so in the script we call pySerial to read what is coming in from the serial bus. Using REAPER 4.3.1 and python 2.7.5 on a Mac (OSX 10.6.8). Code sample is below.
I have isolated the problem (i believe) to the loop in the ReaScript that must be there somehow to always look for events coming in from the controller to trigger the ActionNumbers. I know the pySerial works as i can get the strings in (when the loop is turned off). And I can run the necessary action numbers triggered by the strings. When i try to implement a loop (example below), the whole user interface freezes up and I need to Force Quit. I have found threads that say that Reaper doesnt like an infinite loop (ReaScript: About the "possibly infinite loop" error message...) , so i fixed that, and that there is a limit to the number of ActionNumbers, so we just run the loop with a delay (time.sleep) to try to get it to work for now.
Has anyone had this problem? Does anyone know why loops are causing so much trouble ? This thread also seems relevant:
http://forum.cockos.com/showthread.php?t=127977
We think we need a loop to be running to look for input from the controller, but if there are any other ways of making that work, please let us know!
Thanks very very much-- ben
"
import sys
import os.path
import subprocess
import serial
import time
from reaper_python import *
Version = sys.version_info
RPR_ShowConsoleMsg(str(Version))
# DEFINE THE USB PORT:
ser = serial.Serial('/dev/tty.usbmodem621', 9600)
x = ser.readline()
RPR_ShowConsoleMsg(str(x))
for i in range(10000):
time.sleep(0.5)
x = ser.readline()
if x.startswith("L"):
msg = "go back one EQ"
actionNum = 40172 # Markers: Previous marker/project start
RPR_Main_OnCommand(actionNum, 0)
RPR_ShowConsoleMsg(msg)
"