larsimmisch / pyalsaaudio

ALSA wrappers for Python
http://larsimmisch.github.io/pyalsaaudio/
Other
214 stars 74 forks source link

PCM stuttering #138

Open marcomac01 opened 8 months ago

marcomac01 commented 8 months ago

Hi guys. I was trying to make a simple mumble client. I wrote the basics but the audio i get stutters a lot. The code follows:

import pymumble_py3
from pymumble_py3.callbacks import PYMUMBLE_CLBK_SOUNDRECEIVED as PCS
import alsaaudio as a

# Mumble server connection Settings
password = "" 
server = "192.168.1.61"  
username = "Pi"
port = 64738 

# Audio stream settings
CHUNK = 5000
DATATYPE = 'int16'
CHANNELS = 1
RATE = 48000

# Inistialize the audio stream using devices

# This part is about the connection to the Mumble Server
# Setting 

device = 'hw:CARD=PCH,DEV=0'
out = a.PCM(a.PCM_PLAYBACK, channels=1, rate=48000, format=a.PCM_FORMAT_S16_LE, periodsize=32,
             device=device, mode=a.PCM_NONBLOCK)
def sound_received_handler(user, soundchunk):
    out.write(soundchunk.pcm)
    pass

mumble = pymumble_py3.Mumble(server, username, password=password, port=port)
mumble.callbacks.set_callback(PCS, sound_received_handler)
mumble.set_receive_sound(1)
mumble.start()
mumble.is_ready()

while True:
    pass

thanks for your patience

ossilator commented 7 months ago

if you were not using version 0.10.0, then you most probably just saw the effect of buffer underruns, which this library unfortunately just papers over. i had sort of fixed that, but it was reverted (for the time being) - see #130.