Close

Not so easy

A project log for Raspberry Pi Guitar Amplifier

Guitar Amplifier and effects made with Raspberry Pi and reused Vox amplifier case

dsagmandsagman 08/12/2022 at 15:581 Comment

OK, I've got a button working, and recording working, but when I try to do playback I get:  terminated by signal SIGSEGV (Address boundary error)

I think the problem may be that I am somehow starting the pedalmaster main program at the same time and they are conflicting. So maybe not my code. 

Here's the code, and I have button wired up to GPIO pin 2.

# Looper. This is test code that:
# on GPIO connected button press: starts a recording
# second press: stops listening and plays a loop of the recording
# third press: stops looping and returns to initial state
#!/usr/bin/env python3
from gpiozero import Button
from signal import pause
import pyo
import os

s = pyo.Server().boot()
s.start()
audio = pyo.Input()
loop_file = os.path.dirname(os.path.abspath(__file__))+'/myloop.wav'
times_clicked = 0

def looper_func(key):
    global times_clicked, rec, looper, audio, loop_file
    if times_clicked == 0:
        print("Recording")
        rec = pyo.Record(audio, filename=loop_file, fileformat=0, sampletype=1).out()
    if times_clicked == 1:
        print("Looping")
        rec.stop()
        looper = pyo.SfPlayer(loop_file, loop=True).out()
    if times_clicked == 2:
        print("Waiting")
        looper.stop()
    times_clicked = (times_clicked+1)%3
    print(times_clicked)

switch = Button(2)
switch.when_pressed = looper_func

pause()

Discussions

dsagman wrote 08/12/2022 at 18:31 point

It's something wrong in the pyo module on raspbian. The code works fine on my Arch linux laptop. So, hmmmmmmm. I can't even get the most minimal to work with sFplayer.

  Are you sure? yes | no