Actually im working on a project wi raspberry PI 3 for an arcade mini-bartop.
The project its close to the end but i noticed to a big amount of delay audio (2 second and more), during the videosnap (front-end) and ingame.
I already tried the solutions of the wiki page, but didn't help me.
Basically i had try to edit config.txt and the script (who change the rotation of the screen and at same time the output of the audio trought these commands amixer cset numid=3 1 and amixer cset numid=3 2 ).
I do not know if is a common issue the audio delay i do not find too much over internet.
I really appreciate every kind of test, because im quite lost at the moment...
config.txt
Code: Select all
# For more options and information see
# http://rpf.io/configtxtreadme
# Some settings may impact device functionality. See link above for details
disable_splash=1
# uncomment if you get no picture on HDMI for a default "safe" mode
#hdmi_safe=1
# uncomment this if your display has a black border of unused pixels visible
# and your display can output without overscan
disable_overscan=1
# uncomment the following to adjust overscan. Use positive numbers if console
# goes off screen, and negative if there is too much border
#overscan_left=16
#overscan_right=16
#overscan_top=16
#overscan_bottom=16
# uncomment to force a console size. By default it will be display's size minus
# overscan.
#framebuffer_width=1280
#framebuffer_height=720
# uncomment if hdmi display is not detected and composite is being output
#hdmi_force_hotplug=1
# uncomment to force a specific HDMI mode (this will force VGA)
hdmi_group=1
hdmi_mode=16
# uncomment to force a HDMI mode rather than DVI. This can make audio work in
# DMT (computer monitor) modes .... se lo abilito non sento più l'audio dal JACK AUDIO
# hdmi_drive=2
# uncomment to increase signal to HDMI, if you have interference, blanking, or
# no display
#config_hdmi_boost=4
# uncomment for composite PAL
#sdtv_mode=2
#uncomment to overclock the arm. 700 MHz is the default.
#arm_freq=800
# Uncomment some or all of these to enable the optional hardware interfaces
#dtparam=i2c_arm=on
#dtparam=i2s=on
#dtparam=spi=on
# Uncomment this to enable the lirc-rpi module
#dtoverlay=lirc-rpi
# Additional overlays and parameters are documented /boot/overlays/README
# Enable audio (loads snd_bcm2835)
dtparam=audio=on
gpu_mem_256=128
gpu_mem_512=256
gpu_mem_1024=256
overscan_scale=1
# position screen based on display_rotate=0 for horizontal
# display_rotate=1 for vertical, top to right (90)
# display_rotate=2 for horizontal, flip (180)
# display=3 or vertical, top to left (270)
display_rotate=1
# Pretends all audio formats are supported by display, allowing passthrough of DTS/AC even when not reported as supported.
#hdmi_force_edid_audio=1
# To remove hiss or static or white noise when using the 3.5mm headphone jack
disable_audio_dither=1
#audio_pwm_mode=2Code: Select all
#!/usr/bin/env python2.7
# This script detects an input on pin 18.
# When it sees input go low, it rewrites /boot/config.txt to set display rotation opposite what
# it currently is, then reboots the RPi. KRR 2018
# Added ability to switch audio outputs KRR 4/25/2018
# Changed loop timne from 0.5 to 2. This is to not tax CPU as bad. --KRR 04/25/2018
import os
import RPi.GPIO as GPIO #GPIO module
import time
import subprocess
import atexit #exit cleanup
# assign input pin we are using (default 18. You can change 18 to the pin number you are using)
inpin = 18
# setup GPIO to use pin number not GPIO number.
GPIO.setmode(GPIO.BOARD) #This allows me to access the I/O by pin numbers not GPIO ID
GPIO.setwarnings (False)
# set inpin as an input, also pull the pin high, because we want to detect it going low when button is pressed.
GPIO.setup(inpin, GPIO.IN, pull_up_down=GPIO.PUD_UP)
# assign varaiable to allow only one scan of shutmedown
completed = False
# assign variable for path to config.txt
mainfile = '/boot/config.txt'
# set audio output based on screen rotation in config.txt
if os.path.isfile(mainfile):
readfile = open(mainfile)
for line in readfile:
if line [0:16] == ('display_rotate=1'): # may have to change 1 to 0 to get what you want.
process = subprocess.Popen('amixer cset numid=3 1', stdout=subprocess.PIPE, stderr=None, shell=True)
output = process.communicate()
else: #add this else, should line up with the if above it.
process = subprocess.Popen('amixer cset numid=3 2', stdout=subprocess.PIPE, stderr=None, shell=True)# add this line change the 2 to whatever it should be
output = process.communicate()# add this line.
continue # make sure continue, else and if all line up
# assign variable to a temporary file
tempfile = 'config.tmp'
# what happens when input pin goes low
def shutmedown(channel):
#this runs when button press is detected.
global completed
junk = ''
if completed == False:
if os.path.isfile(mainfile):
writefile = open(tempfile,'w')
readfile = open(mainfile)
for line in readfile:
junk= line
if line [0:16] == ('display_rotate=1'):
junk = 'display_rotate=0\n'
if line [0:16] == ('display_rotate=0'):
junk = 'display_rotate=1\n'
writefile.write(junk)
continue
readfile.close()
writefile.close()
if os.path.isfile(tempfile):
writefile = open(mainfile,'w')
readfile = open(tempfile)
for line in readfile:
writefile.write(line)
continue
readfile.close()
writefile.close()
completed = True
# issue reboot command
os.system('sudo reboot')
sys.exit() # exit program
# setup interupt to detect button pressed. Bouncetime is to prevent false triggers being picked up so you will have to hold the button for 500 MS (half second)
GPIO.add_event_detect(inpin, GPIO.FALLING, callback = shutmedown, bouncetime=500)
# Loop while program is running. This is so the program doesnt scan once then end. It will keep looping every .5 seconds
while True:
time.sleep(2)