https://gr33nonline.files.wordpress.com/2018/04/barry-klein-electronic-music-circuits.pdf
import board
import neopixel
import time
# Define the number of pixels in the strip and the pin it is connected to
num_pixels = 60
pixels = neopixel.NeoPixel(board.D18, num_pixels)
# Define the party LED sequence
sequence = [
(255, 0, 0), # Red
(0, 255, 0), # Green
(0, 0, 255), # Blue
(255, 255, 0), # Yellow
(255, 0, 255), # Purple
(0, 255, 255) # Cyan
]
while True:
for color in sequence:
for i in range(num_pixels):
pixels[i] = color
pixels.show()
time.sleep(0.05)
import pro_tools_sdk
# Connect to Pro Tools
session = pro_tools_sdk.Session()
# Get a reference to the fader you want to control
fader = session.get_fader("Fader 1")
# Set the fader's level to -12 dB
fader.set_level(-12)
# Close the Pro Tools session
session.close()
Pan: You can use the set_pan() method to control the pan position of a channel.
Mute: You can use the set_mute() method to mute or unmute a channel.
Solo: You can use the set_solo() method to solo or unsolo a channel.
Input or output routing: You can use the set_input_routing() and set_output_routing() methods to control the input and output routing of a channel.
Inserts: You can use the get_inserts() method to get a list of inserts on a channel, and then use the enable() and set_parameter() methods to control the settings of each insert.
Automation: You can use the get_automation_parameters() method to get a list of automation parameters on a channel, and then use the enable() and set_value() methods to control the settings of each automation parameter.
from pysnmp.hlapi import *
import gspread
from oauth2client.service_account import ServiceAccountCredentials
# SNMP query function
def snmp_query(ip, community, oid):
errorIndication, errorStatus, errorIndex, varBinds = next(
getCmd(SnmpEngine(),
CommunityData(community),
UdpTransportTarget((ip, 161)),
ContextData(),
ObjectType(ObjectIdentity(oid)))
)
if errorIndication:
print(errorIndication)
elif errorStatus:
print(‘%s at %s’ % (errorStatus.prettyPrint(),
errorIndex and varBinds[int(errorIndex) – 1][0] or ‘?’))
else:
for varBind in varBinds:
return varBind[1].prettyPrint() Continue reading
import pythoncom
import reapy
import RPi.GPIO as GPIO
# Set up the GPIO pins
GPIO.setmode(GPIO.BCM)
GPIO.setup(17, GPIO.OUT) # Volume pin
GPIO.setup(27, GPIO.OUT) # Mute pin
GPIO.setup(22, GPIO.OUT) # Solo pin
def set_track_volume(track, volume):
track.volume = volume
if volume > 0.5:
GPIO.output(17, GPIO.HIGH)
else:
GPIO.output(17, GPIO.LOW)
def set_track_mute(track, mute):
track.mute = mute
if mute:
GPIO.output(27, GPIO.HIGH)
else:
GPIO.output(27, GPIO.LOW)
def set_track_solo(track, solo):
track.solo = solo
if solo:
GPIO.output(22, GPIO.HIGH)
else:
GPIO.output(22, GPIO.LOW)
# Create a function to map Reaper tracks to GPIO pins
def map_track(track):
# Connect to Reaper
reapy.connect()
# Get the track from Reaper
track = reapy.Track(track)
# Set the track’s volume, mute, and solo status
set_track_volume(track, track.volume)
set_track_mute(track, track.mute)
set_track_solo(track, track.solo)
# Disconnect from Reaper
reapy.disconnect()
# Map Reaper track 1 to GPIO pins
map_track(1)
# Clean up the GPIO pins
GPIO.cleanup()
import reapy
import OSC
# Create an OSC client to send messages to Reaper
client = OSC.OSCClient()
client.connect(("127.0.0.1", 8000))
# Create an OSC server to receive messages from the fader and switches
server = OSC.OSCServer(("127.0.0.1", 9000))
def handle_volume(path, tags, args, source):
volume = args[0]
# Set the volume of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.volume = volume
reapy.disconnect()
# Add a callback for the volume fader
server.addMsgHandler("/volume", handle_volume)
def handle_mute(path, tags, args, source):
mute = args[0]
# Set the mute of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.mute = mute
reapy.disconnect()
# Add a callback for the mute switch
server.addMsgHandler("/mute", handle_mute)
def handle_solo(path, tags, args, source):
solo = args[0]
# Set the solo of the track using the Reaper API
reapy.connect()
track = reapy.Track(1)
track.solo = solo
reapy.disconnect()
# Add a callback for the solo switch
server.addMsgHandler("/solo", handle_solo)
# Run the OSC server
st = threading.Thread(target=server.serve_forever)
st.start()
python script that sends a CSV with a time (in seconds) and labels to the reaper API and converts them into timeline markers
import csv
from reaper_python import *
# Open the CSV file
with open('markers.csv', 'r') as csvfile:
# Read the CSV file
reader = csv.reader(csvfile)
next(reader) # skip the header
# Iterate through the rows
for row in reader:
time = float(row[0])
label = row[1]
# Convert the time to a Reaper time format
reaper_time = int(time * 1000)
# Create a new marker at the specified time
RPR_AddProjectMarker2(0, False, reaper_time, 0, label, -1, 0)
Sure! Here is an example of an Arduino sketch that uses four motor controllers and receives s-bus inputs from a remote control, and also maps MIDI notes to each motor controller:
#include <SBUS.h> // include the SBUS library
#include <MIDI.h> // include the MIDI library
// define the pin numbers for the s-bus input and the four motor controllers
const int SBUS_PIN = 10;
const int MOTOR1_PIN = 3;
const int MOTOR2_PIN = 5;
const int MOTOR3_PIN = 6;
const int MOTOR4_PIN = 9;
// create an instance of the SBUS library
SBUS sbus(SBUS_PIN);
// create an instance of the MIDI library
MIDI_CREATE_DEFAULT_INSTANCE();
void setup() {
// initialize the s-bus input and the four motor controllers
sbus.begin();
pinMode(MOTOR1_PIN, OUTPUT);
pinMode(MOTOR2_PIN, OUTPUT);
pinMode(MOTOR3_PIN, OUTPUT);
pinMode(MOTOR4_PIN, OUTPUT);
// begin MIDI communication
MIDI.begin(MIDI_CHANNEL_OMNI);
}
void loop() {
// read the s-bus input
sbus.read();
// get the values of the channels from the s-bus input
int channel1 = sbus.getChannel(1);
int channel2 = sbus.getChannel(2);
int channel3 = sbus.getChannel(3);
int channel4 = sbus.getChannel(4);
// set the speed of the first motor based on the value of channel 1
analogWrite(MOTOR1_PIN, channel1);
// set the speed of the second motor based on the value of channel 2
analogWrite(MOTOR2_PIN, channel2);
// set the speed of the third motor based on the value of channel 3
analogWrite(MOTOR3_PIN, channel3);
// set the speed of the fourth motor based on the value of channel 4
analogWrite(MOTOR4_PIN, channel4);
// check for incoming MIDI messages
MIDI.read();
// if a MIDI note on message is received, set the speed of the corresponding motor
if (MIDI.getType() == midi::NoteOn) {
int note = MIDI.getData1(); // get the MIDI note number
int velocity = MIDI.getData2(); // get the MIDI velocity value
// map the MIDI note to a motor controller and set its speed
if (note == 60) { // map MIDI note 60 to motor 1
analogWrite(MOTOR1_PIN, velocity);
}
else if (note == 61) { // map MIDI note 61 to motor 2
analogWrite(MOTOR2_PIN, velocity);
}
else if (note == 62) { // map MIDI note 62 to motor 3
analogWrite(MOTOR3_PIN, velocity);
}
else if (note == 63) { // map MIDI note 63 to motor 4
analogWrite(MOTOR4_PIN, velocity);