Use LoP-Parameters with PureData

Making your program work.
RoyBear
Posts: 1
Joined: Tue Aug 27, 2013 4:42 am

Use LoP-Parameters with PureData

Post by RoyBear »

Hi Guys & Gals,

I got me a Lots of Pots, soldered the Pins and Pots, strapped some other Buttons and Encoder and a Friend set me an Environment, i could work with.
He used Arch Linux, installed a GUI, phyton2 and PureData with all the stuff you need to work with (including ALSA and Jack).
Then he wrote down the Pyhton code and showed me how it works. Fine.

But thats all i know 'bout that stuff :(

could someone tell me how i could "tunnel" the Parameters of that codesample to PureData, so i could use them as classic midi-data?

i don't even know if this Forum is the right place, but i thought that it should be a good start :)

yours
Roy

oz
Site Admin
Posts: 542
Joined: Mon May 12, 2008 4:19 pm

Re: Use LoP-Parameters with PureData

Post by oz »

RoyBear,

Shawn is working on an example and tutorial for a blog post. Coming up on the blog front page.

haigarmen
Posts: 1
Joined: Tue Feb 06, 2018 11:14 pm

Re: Use LoP-Parameters with PureData

Post by haigarmen »

Has anyone been able to get LoP working with Raspberry Pi 3 with Raspbian 9 (Stretch)? When I run the test script I don't get any errors but 0's for all the 8 potentiometer readings. Any help would be appreciated.
thanks.

JeffAvery
Posts: 1
Joined: Fri Jan 17, 2020 11:34 pm

Re: Use LoP-Parameters with PureData

Post by JeffAvery »

I was able to get the code working on more modern hardware with a bit of massaging :) also be sure to actually solder the pots in.

Code: Select all

import time
import spidev

spi_ch = 0

# Enable SPI
spi = spidev.SpiDev(0, spi_ch)
spi.max_speed_hz = 1200000

def read_adc(channel, vref = 3.3):

    if channel > 7 or channel < 0:
        return -1

    # spi.xfer2 sends three bytes and returns three bytes:
    # byte 1: the start bit (always 0x01)
    # byte 2: configure bits, see MCP3008 datasheet table 5-2
    # byte 3: don't care
    r = spi.xfer2([1, 8 + channel << 4, 0])

    # Three bytes are returned; the data (0-1023) is in the
    # lower 3 bits of byte 2, and byte 3 (datasheet figure 6-1)    
    v = ((r[1] & 3) << 8) + r[2]

    return v;

while True:
    for i in range(8):
        value = read_adc(i)
        print "%4d" % value,
    time.sleep(0.2)
    print;

oz
Site Admin
Posts: 542
Joined: Mon May 12, 2008 4:19 pm

Re: Use LoP-Parameters with PureData

Post by oz »

Jeff Avery,

Thank you for your code snippet. I'm glad you got it working.

Paul Badger

Post Reply