Pi install

From: Peter (BOUGHTONP)22 Aug 2018 21:10
To: graphitone 26 of 92
"Somehow I've lost all sound"

My sound broke in Arch by doing something that buggered around with PulseAudio, which then fucked up ALSA, because PulseAudio is a buggy bloated piece of shit that nobody actually needs.

So maybe you installed/upgraded (possibly automatically) something that did fiddled with PA?

From: Peter (BOUGHTONP)22 Aug 2018 21:45
To: graphitone 27 of 92
You're still using the "Are we there yet? Are we there yet? ..." method instead of the "Tell me when we're there" one.

If you do really want to do it this way, since you only care about shutdown, you don't need to store/check oldButtonState and can simplify it to:

GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)

# endless loop until button is pressed
while GPIO.input(5):
	time.sleep(.1)

# verify button state before switching off
if not GPIO.input(5):
	subprocess.call("echo 1 > /sys/class/backlight/rpi_backlight/bl_power && shutdown -h now",
		shell=True,stdout=subprocess.PIPE, stderr=subprocess.PIPE)

The if verification is probably not necessary (depending on how Python works), but even so it acts as both a safety against unwanted shutdown (incase something goes wrong), and clarifies the intent slightly. (The event-driven/callback method would make it even clearer.)

From: Chris (CHRISSS)22 Aug 2018 21:54
To: CHYRON (DSMITHHFX) 28 of 92
:D
From: CHYRON (DSMITHHFX)23 Aug 2018 00:17
To: graphitone 29 of 92
Has he really got a 70s stereo system?
From: graphitone23 Aug 2018 08:33
To: Peter (BOUGHTONP) 30 of 92
Could well be.

IQaudIO produce this document (a pdf download) which seems to be wrriten in multiple styles and changes between being helpful and downright confusing.

I'll check the onboard audio is properly disabled and might go back to a vanilla image, and test the sound after every change made.

 
From: graphitone23 Aug 2018 08:36
To: Peter (BOUGHTONP) 31 of 92
Quote: 
You're still using the "Are we there yet? Are we there yet? ..." method instead of the "Tell me when we're there"



Other than being more optimised (and I appreciate the arguments for non-bloated code) does that have a knock on effect on real world performance or not?

Thanks for the suggestions though, I'll try that once I get the sound working again!.

 

From: CHYRON (DSMITHHFX)23 Aug 2018 09:13
To: graphitone 32 of 92
"changes between being helpful and downright confusing"

So standard documentation.
From: graphitone23 Aug 2018 11:48
To: CHYRON (DSMITHHFX) 33 of 92
(nod)

Pretty much. There's an indepth walkthrough of how to build a case with diagrams, then when it comes to installing a rotary encoder as a volume knob it's referencing external libraries and assumes ones knows how to call seperate processes as part of the code.

As a linux luddite, I'm able to fumble my way through most of it with online guides and PB's assistance, but it's not something I use everyday, so whatever I learn soon leaves my brain to be replaced with ingratiating one line lyrics from songs that seem to be on a permanent repeat. 
From: CHYRON (DSMITHHFX)23 Aug 2018 15:26
To: graphitone 34 of 92
I think many/most engineers who write their own documentation fail to appreciate the ambiguities of language, and assume users will be able to infer WTF they are talking about, and if they can't, tough shit you lose. I suppose we should be grateful even for that.  :C
From: Peter (BOUGHTONP)23 Aug 2018 19:58
To: graphitone 35 of 92
How does a sound card require 48 pages of documentation? :/

And what's wrong with the onboard sound that made you opt for this route?

From: graphitone23 Aug 2018 20:16
To: Peter (BOUGHTONP) 36 of 92
The onboard sound is crap. I've got a DAC setup on another Pi attached to my drawing desk and it really makes a difference, the audio is clean and sounds brilliant, way way better than the awful quality through the 3.5mm jack on the Pi.

 
From: Peter (BOUGHTONP)23 Aug 2018 20:30
To: graphitone 37 of 92
> does that have a knock on effect on real world performance or not?

Dunno - it has the potential to, but I suspect one instance isn't going to have much impact - but if you do get symptoms of the CPU being congested (e.g. stuttering audio or sluggish response), I'd check that first.

From: Peter (BOUGHTONP)23 Aug 2018 20:52
To: graphitone 38 of 92
Is that music-snob awful or actually bad? :/

The cards in that documentation look chunky - presumably mixing Pi extension cards can quickly give rise to compatibility/connectivity issues.

From: ANT_THOMAS23 Aug 2018 21:17
To: Peter (BOUGHTONP) 39 of 92
Actually bad.
There's a vast difference even when you use a 99p USB DAC compared to on board. I think on board has improved since the first gen Pis but still not great due to the design restrictions.
There's an even bigger improvement if you use the I2S DACs. Not checked the one graphitone is using but there's some nice models out there that also incorporate an amplifier into the DAC HAT.
From: Peter (BOUGHTONP)23 Aug 2018 21:50
To: ANT_THOMAS 40 of 92
Makes sense, but was frustrating me thinking about having lots of cards/wires and extra complexity.

But it's been a long day and I only just remembered that my plan was to go via MDI connection, so the audio on the Pi is irrelevant. \o/

From: graphitone23 Aug 2018 21:52
To: Peter (BOUGHTONP) 41 of 92
What Ant said, the onboard gives out random pops and hisses when listening to anything.
My DAC is an I2S and sounds great with a decent pair of headphones (on the drawing desk one). I've got that hooked up to a switch that alternates between the headphones and a pair of PC style speakers, so I can put the sound through them too.

The only difference with this setup is that I've got the amp addon (from the same company, so you'd assume they're compatible). I've just found some, admittedly old, builds on IQaudIO's website that are preconfigured. The kodi one was totally out of date and wouldn't run on my Pi3, but there's a Volumio build which I'm downloading now. I'm not tied to Kodi, just that I'm more familiar with it, and Volumio has an option for a Kodi plugin.
From: graphitone25 Aug 2018 07:57
To: ALL42 of 92
The pre-configured builds hosted on IQaudIO's site are either too old for the most recent Pi3, or are corrupted in some way, 'cos they don't run :C

Back to the backup plan of using a backup of Kodi on LibreElec and seeing at what point the sound buggers up.
From: graphitone25 Aug 2018 14:16
To: All 43 of 92
I found that the issue with the sound not working happens when the shutdown script is invoked.

I'm just running the script manaully and not committing it to the autostart.sh and it turns the sound off.

I'm going with the vanilla script again, and providing I can get this working, I'll go with PB's other suggestions.
 
Code: 

#!/usr/bin/python
import sys
sys.path.append('/storage/.kodi/addons/virtual.rpi-tools/lib')
import RPi.GPIO as GPIO
import time
import subprocess

# we will use the pin numbering to match the pins on the Pi, instead of the
# GPIO pin outs (makes it easier to keep track of things)

GPIO.setmode(GPIO.BOARD)  

# use the same pin that is used for the reset button (one button to rule them all!)
GPIO.setup(5, GPIO.IN, pull_up_down = GPIO.PUD_UP)  

oldButtonState1 = True

while True:
    #grab the current button state
    buttonState1 = GPIO.input(5)

  # check to see if button has been pushed
  if buttonState1 != oldButtonState1 and buttonState1 == False:
    subprocess.call("echo 1 > /sys/class/backlight/rpi_backlight/bl_power && shutdown -h now", shell=True,
            stdout=subprocess.PIPE, stderr=subprocess.PIPE)
    oldButtonState1 = buttonState1

    time.sleep(.1)
Going through the manual again, there's a section of what's passed through the GPIO.
The DAC uses pin 5 for I2C.  I reckon if I'm now scripting that 5 is something else, that's what's kicking the sound out of touch. On that diagram though GPIO5 is pin 29, so as the script mentions it must be using the physical layout as only the first 10 pins are presented on top the Amp card and when the script runs, the power button works, but has the undesirable sound side effect.

So, with the attached diagram(s) in mind I'm guessing I could swap pins 5 (gpio3) and 6 (gnd) to be 9 (gnd) and 10 (gpio15). Would that be feasable?!

UPDATE - I've tried a combination of the other pins and updated the script accordingly. No joy there.

The pin diagram from the manual shows 7, 8 and 10 are available pins and I've tried them all against a pin 9 ground and it's just not doing anything when the shutdown button's pushed. I read that pins 5 and 6 are somehow favoured for the two pins that when shorted will put the Pi into a sleep mode. I haven't yet found whether this can be changed.

 
EDITED: 25 Aug 2018 21:13 by GRAPHITONE
From: Peter (BOUGHTONP)26 Aug 2018 14:12
To: graphitone 44 of 92
The GPIO.setmode(GPIO.BOARD) makes it use pin numbers, but you can use GPIO.setmode(GPIO.BCM) to use GPIO numbers instead.

The DAC/AMP might only provide the first 10 pins on top, but it's not clear from photos if they actually prevent you connecting to the other pins underneath?

From: graphitone26 Aug 2018 18:41
To: Peter (BOUGHTONP) 45 of 92
Yeah, they do. The DAC covers all 40 pins, while the amp takes the first ten and passes them through to the headers on top of the whole stack. I'm pretty sure it's passing  pins 1 - 10 through as shorting 5 and 6 with the script configured to use them did shut it down. I don't get that if /a/ GPIO pin can be utilised to do a thing, then why couldn't /another/ GPIO be used to do the same thing, providing it's (apparently) unused?