GithubHelp home page GithubHelp logo

whofferbert / rpi-midi-rotary-encoder Goto Github PK

View Code? Open in Web Editor NEW
4.0 1.0 0.0 20 KB

A python script to create a midi device, and send control change messages out through it.

License: MIT License

Python 100.00%

rpi-midi-rotary-encoder's Introduction

rpi-midi-rotary-encoder

rotary_encoder.py

A python script to create a midi device, and send control change messages out through it.

import RPi.GPIO as GPIO
import time
import mido
import os
import re

Also requires 'amidithru'

For a first time setup on a pi, you may have to install rpi.gpio for python3:

sudo apt-get update
sudo apt-get install python3-rpi.gpio 

The script is hopefully laid out clearly enough that customizing and adjusting things should be easy.

Common usage would be to put it on a Raspberry Pi which is connected to a rotary encoder, and run this script to monitor the voltage changes and relay appropriate midi data out through a chosen virtual interface, usable to other software running on the Pi.

Generally, add an entry to your crontab to call the script on startup: (Make sure you set your path properly)

@reboot /usr/bin/sudo /path/to/rotary_encoder.py &

Note about sudo

This script requires root to run, so you need to call it with sudo, without password, or save the startup command to the root user's crontab, without need for sudo.

To have this work on boot with sudo, you must not have sudo require a password to work.

You can achieve this by adding a new file and rule to your sudoers config. with visudo (username modep in examples):

sudo visudo -f /etc/sudoers.d/modep

Once in visudo, write the sudoers rule to allow your user to run sudo without a password:

modep ALL = (ALL:ALL) NOPASSWD: ALL

After that, you can log out and back in or reboot, and then be able to run sudo things without a password.

rpi-midi-rotary-encoder's People

Contributors

whofferbert avatar

Stargazers

 avatar  avatar  avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.