ManimCommunity / ManimCommunity/manim

Unable to add sound for opengl renderer

Open
#2,144 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

issue:bug opengl
Dominant language
Python
Stars
40.9k
Forks
3.1k
Avg merge
3d 12h
Merged PRs (30d)
25

Description

## Description of bug / unexpected behavior

When going through cairo's tests the below one failed that was testing sound, it doesn't seem to have implemented some of cairo's logic to add sound to a movie file.

I was trying to run the following test with opengl:

```py
def test_add_sound(using_opengl_renderer, tmpdir):
# create sound file
sound_loc = Path(tmpdir, "noise.wav")
f = wave.open(str(sound_loc), "w")
f.setparams((2, 2, 44100, 0, "NONE", "not compressed"))
for _ in range(22050): # half a second of sound
packed_value = struct.pack("h", 14242)
f.writeframes(packed_value)
f.writeframes(packed_value)

f.close()

scene = Scene()
scene.add_sound(sound_loc)
```

Which results in

```AttributeError: 'OpenGLRenderer' object has no attribute 'time'```

## Expected behavior

## How to reproduce the issue

Code for reproducing the problem

```py
class Example(Scene):
def construct(self):
self.add_sound("path/to/soundfile")
```

## Additional media files

Images/GIFs

## Logs
Terminal output

```
PASTE HERE OR PROVIDE LINK TO https://pastebin.com/ OR SIMILAR
```

## System specifications

System Details

- OS (with version, e.g Windows 10 v2004 or macOS 10.15 (Catalina)):
- RAM:
- Python version (`python/py/python3 --version`):
- Installed modules (provide output from `pip list`):
```
PASTE HERE
```

LaTeX details

+ LaTeX distribution (e.g. TeX Live 2020):
+ Installed LaTeX packages:

FFMPEG

Output of `ffmpeg -version`:

```
PASTE HERE
```

## Additional comments

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start with the failing test_add_sound case and inspect how Scene.add_sound reaches OpenGLRenderer, especially the missing time attribute reported in the traceback. Compare the OpenGL path with the Cairo renderer's sound handling. Done means the test can add sound while using the OpenGL renderer without raising AttributeError.

Written by the indexing model from the issue text.

Assessment

Tech stack
python
Domain
audio-video-rtc, computer-graphics, testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
45/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.