Audio library issues: crashes when using OpenAL

Hello Panda 3D community,

I run Panda3D 1.8.1 on Windows 8 pro 64 bits. I am trying to play video textures on a virtual TV screen with the sound of the video synchonized. I also have a character in my scene that speaks by playing .wav speech files, generated by Microsoft’s speech synthesis. I am running into the following issues:

  • When I want to play a .wav speech sound produced by the voice synthesizer with the openAL audio library I get the following error:
:movies:ffmpeg(warning): parser not found for codec pcm_s16le, packets or times may be invalid.
:audio(error): alGenSources(): Invalid Value
Assertion failed: sound != _sounds_playing.end(), file c:\buildslave\release_sdk_win32\build\panda3d\panda\src\audiotraits\openalAudioManager.cxx, line 871

and the program crashes. I tried with the FMOD sound library and everything turned out to work correctly.

  • However, loading sounds from .avi files does not seem to be supported by FMOD. When I try loading the sound from the video while having selected the FMOD audio library, I get the following error:
:audio(error): createSound(/c/Users/xxx/data/videos/PandaSneezes.avi): Unsupported file or audio format.

In this case, the program does not crash but the video is frozen (as the play method is called on the sfx object, which does not exist, as it could not be loaded, see the code below).

  • I tried to play the video using the openAL library and I also get a crash, with the following error message:
  :audio(error): alGenSources(): Invalid Value
Assertion failed: sound != _sounds_playing.end(), file c:\buildslave\release_sdk_win32\build\panda3d\panda\src\audiotraits\openalAudioManager.cxx, line 871

However, this bit is quite surprising, as playing a video with sound, using the OpenAL audio library, does work when I run the MediaPlayer sample program.

Here are my questions :

  • What could cause OpenAL to crash in my program, whereas it works in the sample and I am using the same video file?
  • Is there a possible incompability of OpenAL with some .wav files format? If so, can it be fixed and how?
  • Is there a way for FMOD to support loading sounds from videos?
  • If neither OpenAL nor FMOD supports both file formats, is there a workaround to use both at the same time?

Here is the code I use to play sounds and videos:

  • Parts of init linked to sound and videos:
from direct.showbase.ShowBase import ShowBase #Panda 3D renderer
from direct.task import Task #Panda 3D task manager
from direct.actor.Actor import Actor #Actor is used by Panda 3D for animated objects
from panda3d.core import *
from direct.gui.DirectEntry import DirectEntry

class PandaScene(ShowBase):
    def __init__(self):
        ShowBase.__init__(self)
        
        tv_frame_path = "data/environment/tv_frame.egg"
        tv_screen_path = "data/environment/tv_screen.egg"

        self.tv_frame = self.loader.loadModel(tv_frame_path)
        self.tv_screen = self.loader.loadModel(tv_screen_path)
        self.tv_screen.reparentTo(self.tv_frame)
        self.tv_frame.setScale(3.0)
        self.tv_frame.setPos(-10,10,8)
        self.tv_frame.setHpr(3,-5,0)

        self.screenTexture = self.tv_screen.getTexture()
        
        self.videoTexture = 0
        self.videoSound = 0
  • Here is the callback method that plays speech whenever a new sound file is available :
def OnEvent(self, eventName, parameters):
        if(eventName == "sound"):
            #getting the sound file's path
            parameterList = parameters.split(";")
            soundFile = parameterList[0]

            #adapting the path format to Panda3D's requirements
            soundFilePanda = "/" + soundFile[0].lower()
            for i in range(2, len(soundFile)):
                char = soundFile[i]
                if char == '\\':
                    char = "/"
                soundFilePanda += char

            #playing the sound
            global base

            sound = base.loader.loadSfx(soundFilePanda)
            sound.play()
  • Here are the methods I use to play a video, with and without sound:
def playVideo(videoName):
    global app
    path = 'data/videos/' + videoName
    app.videoTexture = MovieTexture("name")
    assert app.videoTexture.read(path), "Failed to load video!"
    app.tv_screen.setTexScale(TextureStage.getDefault(), app.videoTexture.getTexScale())
    app.tv_screen.setColor(1,1,1,0)
    app.tv_screen.setTexture(app.videoTexture, 1)
    app.videoTexture.play()
def playVideoWithSound(videoName):
    global app
    path = 'data/videos/' + videoName
    app.videoTexture = MovieTexture("name")
    assert app.videoTexture.read(path), "Failed to load video!"
    app.videoSound = app.loader.loadSfx(path)
    app.videoTexture.synchronizeTo(app.videoSound)
    app.tv_screen.setTexScale(TextureStage.getDefault(), app.videoTexture.getTexScale())
    app.tv_screen.setColor(1,1,1,0)
    app.tv_screen.setTexture(app.videoTexture, 1)
    app.videoSound.play()

Thanks in advance for your help,

Pierre

Could you share the file that produces this crash, so that we might reproduce the issue?

Actually, I notice you’re using 1.8.1; I do recommend that you update to Panda3D 1.9.0, which has a whole new .wav loader that does not use ffmpeg, so it is unlikely to have the same problems unless there is something wrong with the .wav file itself.

Hi,

Thanks for your answer, I will try with Panda version 1.9.0. In that case, what audio library should I select to use this new loader ?

Which files that cause crashes would you like? The source files or the .wav files?

Thanks,

Pierre

I’d suggest OpenAL. I would need all the files necessary for me to run it and replicate the issue.