corrupted audio if I play a sound before starting a song
mph070770 opened this issue · 2 comments
Hi All,
I'm writing a python program that plays a beep before I then start a spotify track. My code is:
# -*- coding: utf-8-*-
import socket
import json
import subprocess
def connect():
global TCP_IP
global TCP_PORT
global BUFFER_SIZE
global s
TCP_IP = '127.0.0.1'
TCP_PORT = 6602 #spop
BUFFER_SIZE = 4096
s = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
s.connect((TCP_IP, TCP_PORT))
s.send("")
data = s.recv(BUFFER_SIZE)
print "CONNECT: received data:", data
def communicate(message):
global TCP_IP
global TCP_PORT
global BUFFER_SIZE
global s
s.send(message)
data = ""
while 1:
block = s.recv(1024)
data = data + block
if "]}" in block: break
processed = json.loads(data)
return processed
def close_connection():
global s
s.close()
def play_test():
subprocess.call("mplayer beep_hi.wav", shell=True)
and from another python module I call:
connect()
play_test()
processed = communicate('uplay spotify:track:0N8g7nmvTEhPnQkYDThuxP\n')
The track sounds a little bit fast and corrupted. If I remove the play_test() call (the call that produces the beep) then the track plays normally.
Can anyone advise what I'm doing wrong? Is my sound interfering with the sound setup for spop? The beep file is a 44.1KHz stereo wav. I'd really appreciate any help people can provide - it has me foxed!
Thanks
Martin
I've ran spop in debug mode and I'm getting the following displayed when the music is corrupted:
2015-04-19 10:01:05 [DBG ] ao stats: samples: 0; stutter: 1
Any clues?
Hi, sorry for the delayed answer.
Apparently you're using the ao
output. Could you please tell me which driver is libao configured to use on your system? This is usually in /etc/libao.conf
. And similarly, which audio output is mplayer using? (alsa, PulseAudio, ... ?)