Quantcast
Channel: Raspberry Pi Forums
Viewing all articles
Browse latest Browse all 5266

MicroPython • OSC over PPP?

$
0
0
I'm in the process of developing something like a modular synthesizer. I'll be using ChucK (https://chuck.stanford.edu/), a musical programming language, for sound generation, sampling, and sequencing. This will be running on a Raspberry Pi. I'll be building hot-swappable hardware components with Picos that will function as the interfaces to the oscillators, sampling playback/manipulation functionality, sequencing functionality, etc., that are running in software on the Pi. So I need a way to send data from the Pico components to the Pi. Sending MIDI over USB from the Pico to the Pi is quite simple. I've already got that working. However, the range of values for MIDI is 0-127, which is quite limited. Since I'm reading analog data from potentiometers, and using ADCs on the Picos, I have to convert values from a range of 0-65535 to 0-127 to send that data over MIDI. So I'm losing a lot of precision.

I'd like to use OSC (https://en.wikipedia.org/wiki/Open_Sound_Control) instead of MIDI, as that supports a wide range of data types. It also offers a lot more flexibility and customization of the types of messages. OSC is meant to be used on a network, though. There aren't any pre-built libraries for sending OSC over USB in Micropython for the Pico. I've seen a lot of questions about doing this, and it doesn't seem very straightforward. However, I did stumble across the Point-to-Point Protocol (PPP) library (https://docs.micropython.org/en/latest/ ... serial-ppp) in Micropython. So, I'm thinking about sending the OSC messages over UART using PPP.

The Micropython PPP documentation is rather sparse, though. The only example they give is:

Code:

import networkppp = network.PPP(uart)ppp.connect()while not ppp.isconnected():    passprint(ppp.ipconfig("addr4"))# use the socket module as usual, etcppp.disconnect()
However, I have a few questions to help me get started. I'm assuming that if I have the Pi and Pico connected via the UART pins, then this

Code:

ppp.ipconfig("addr4")
will give me the address of the Pi that I'll use with the socket module to handle the communication? While I am a Python developer, I haven't written socket code in normal Python yet. So I'll have to read up on that. That isn't a problem, but I'm just wondering about how I bridge the PPP module with the socket module. Does anyone have experience with this?

Thanks!

Statistics: Posted by dayunbao — Tue Dec 17, 2024 1:05 pm



Viewing all articles
Browse latest Browse all 5266

Trending Articles