spop icon indicating copy to clipboard operation
spop copied to clipboard

corrupted audio if I play a sound before starting a song

Open mph070770 opened this issue 9 years ago • 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

mph070770 avatar Apr 18 '15 20:04 mph070770

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?

mph070770 avatar Apr 19 '15 09:04 mph070770

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, ... ?)

Schnouki avatar May 13 '15 08:05 Schnouki