Panda 1.7 sound crackle - OpenAL

Hi,

I encountered a problem with crackles if I play a “selfcreated” sound with panda (openAL) and created a minimal testcase for crosschecking and maybe fixing the issue:

from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import *

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        source = UserDataAudio(11025,2)
        data = str()
        for x in range(11025*5*2):
            data += str(0)
        source.append(data)
        source.done()
            
        sound = base.sfxManagerList[0].getSound(source)
        sound.play()

app = MyApp()
app.run()

The crackles occur at the beginning and after 5 secounds.

Crashes on my Mac
pastebin.com/SwNtp4ZB

The crackle/pop was my fault, because str(0) != struct.pack(‘h’,0). A to big change in the signal is causing this pop/crackle, so i guess i have to add some fadein/fadeout to my sounds.

Finally found the real reason. I expected that UserDataAudio except an unsigned short as word but it wants a signed short as word! Maybe this should be added to the doc of UserDataAudio.

Nox, is there any chance you could post an updated (working) version of the code seen in your first post? It could be helpful to others (and me)
If you get the time, thank yous…
~powerpup118

Well the working version:

from direct.showbase.ShowBase import ShowBase
from pandac.PandaModules import *
import struct

class MyApp(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)

        source = UserDataAudio(11025,2)
        data = str()
        for x in range(11025*5*2):
            data += struct.pack('h',0) #only changed line
        source.append(data)
        source.done()
           
        sound = base.sfxManagerList[0].getSound(source)
        sound.play()

app = MyApp()
app.run()

So you see only one single line has changed. The clou was to provide the rawdata as signed short and not as unsigned short so I had to fix my importer-module.