Speakers cannot be muted or unmuted via the API (bpy.data.speakers.muted is broken) #94627

Open
opened 2022-01-04 10:52:27 +01:00 by Trent Stanley · 10 comments

System Information
Operating system: Windows-10-10.0.19043-SP0 64 Bits
Graphics card: NVIDIA GeForce GTX 1060 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 472.12

Blender Version
Broken: version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: f1cca30557
Worked: 2.79b

Exact steps for others to reproduce the error

  1. Add a speaker object
  2. Add a sound to the speaker.
  3. Play the animation, you should hear the sound playing.
  4. Open the console and run bpy.data.speakers["Speaker"].muted = True
  5. Play the animation, you will still hear the sound playing, even though the UI has been updated to add a checkmark to the box next to "Mute" in the speaker data.

Muting the speaker via the UI works normally.

#94627-speaker-mute-depsgraph.blend

**System Information** Operating system: Windows-10-10.0.19043-SP0 64 Bits Graphics card: NVIDIA GeForce GTX 1060 with Max-Q Design/PCIe/SSE2 NVIDIA Corporation 4.5.0 NVIDIA 472.12 **Blender Version** Broken: version: 3.0.0, branch: master, commit date: 2021-12-02 18:35, hash: `f1cca30557` Worked: 2.79b **Exact steps for others to reproduce the error** 1. Add a speaker object 2. Add a sound to the speaker. 3. Play the animation, you should hear the sound playing. 4. Open the console and run bpy.data.speakers["Speaker"].muted = True 5. Play the animation, you will still hear the sound playing, even though the UI has been updated to add a checkmark to the box next to "Mute" in the speaker data. Muting the speaker via the UI works normally. [#94627-speaker-mute-depsgraph.blend](https://archive.blender.org/developer/F12798587/T94627-speaker-mute-depsgraph.blend)
Author

Added subscriber: @TrentStanley

Added subscriber: @TrentStanley
Member

Added subscribers: @neXyon, @lichtwerk

Added subscribers: @neXyon, @lichtwerk
Member

Changed status from 'Needs Triage' to: 'Confirmed'

Changed status from 'Needs Triage' to: 'Confirmed'
Member

Can confirm.
Not sure why the RNA updates are ifdefed (this seems to be handled by audaspace bindings themselves?)

CC @neXyon

Can confirm. Not sure why the RNA updates are ifdefed (this seems to be handled by audaspace bindings themselves?) CC @neXyon
Member

Added subscriber: @ideasman42

Added subscriber: @ideasman42
Member

There is no RNA update implemented, since it's not necessary. The muted flag is read in sound_update_base frequently. What is weird though is that when you set muted to True in python, the actual flag value of the speaker does not get updated. I tried this by setting a breakpoint in line 1120 in sound.c (just past const bool mute = ((strip->flag & NLASTRIP_FLAG_MUTED) || (speaker->flag & SPK_MUTED));). Is that some weird RNA behavior or bug @ideasman42 ?

There is no RNA update implemented, since it's not necessary. The muted flag is read in `sound_update_base` frequently. What is weird though is that when you set muted to `True` in python, the actual `flag` value of the speaker does not get updated. I tried this by setting a breakpoint in line 1120 in `sound.c` (just past `const bool mute = ((strip->flag & NLASTRIP_FLAG_MUTED) || (speaker->flag & SPK_MUTED));`). Is that some weird RNA behavior or bug @ideasman42 ?

Added subscriber: @dr.sybren

Added subscriber: @dr.sybren

@neXyon this is caused by failure to update the depsgraph from Python.
The UI always tags the ID with the ID_RECALC_COPY_ON_WRITE flag.

This is a small patch that fixes this report, P2708 by setting the ID_RECALC_PARAMETERS tag, although I don't have a good sense of which flag is best in this case. There are ID_RECALC_AUDIO flags (even ID_RECALC_AUDIO_MUTE) however these are intended for the scene from what I can tell.

If the fix from P2708 is acceptable, we should apply the update function for all other parameters too (volume, pitch .. etc)

CC'ing @dr.sybren have you looked into these audio update issues before?

While investigating this I noticed some other issues which don't seem to be as simple as missing depsgraph tags, so I reported them separately:

  • #94778 (Switching scenes doesn't stop playback in the previous scene)
  • #94779 (Switching a speakers sound data-blocks fails)
@neXyon this is caused by failure to update the depsgraph from Python. The UI always tags the ID with the `ID_RECALC_COPY_ON_WRITE` flag. This is a small patch that fixes this report, [P2708](https://archive.blender.org/developer/P2708.txt) by setting the `ID_RECALC_PARAMETERS` tag, although I don't have a good sense of which flag is best in this case. There are `ID_RECALC_AUDIO` flags (even `ID_RECALC_AUDIO_MUTE`) however these are intended for the scene from what I can tell. If the fix from [P2708](https://archive.blender.org/developer/P2708.txt) is acceptable, we should apply the update function for all other parameters too (volume, pitch .. etc) CC'ing @dr.sybren have you looked into these audio update issues before? While investigating this I noticed some other issues which don't seem to be as simple as missing depsgraph tags, so I reported them separately: - #94778 (Switching scenes doesn't stop playback in the previous scene) - #94779 (Switching a speakers sound data-blocks fails)

One thing I don't understand in the depsgraph is that the audio component of the Object (OBSpeaker) and its data (SPSpeaker) don't have any relation between them. To me this looks like the geometry component of a mesh object not depending on the mesh itself, which would be weird.

{F12798584,size=full}

I'd be fine if we use the ID_RECALC_AUDIO… tags for this. Looking at depsgraph_tag_to_component_opcode(), it's not necessarily meant for only scenes, but just maps to the NodeType::AUDIO component. From what I can see, it just happens to be the Scene code that uses this, but otherwise it seems to be fine to expand that use to other sources of audio.

case ID_RECALC_AUDIO_SEEK:
case ID_RECALC_AUDIO_FPS:
case ID_RECALC_AUDIO_VOLUME:
case ID_RECALC_AUDIO_MUTE:
case ID_RECALC_AUDIO_LISTENER:
case ID_RECALC_AUDIO:

      *component_type = NodeType::AUDIO;
break;
One thing I don't understand in the depsgraph is that the audio component of the Object (`OBSpeaker`) and its data (`SPSpeaker`) don't have any relation between them. To me this looks like the geometry component of a mesh object not depending on the mesh itself, which would be weird. {[F12798584](https://archive.blender.org/developer/F12798584/image.png),size=full} I'd be fine if we use the `ID_RECALC_AUDIO…` tags for this. Looking at `depsgraph_tag_to_component_opcode()`, it's not necessarily meant for only scenes, but just maps to the `NodeType::AUDIO` component. From what I can see, it just happens to be the Scene code that uses this, but otherwise it seems to be fine to expand that use to other sources of audio. ```lang=cpp ``` case ID_RECALC_AUDIO_SEEK: case ID_RECALC_AUDIO_FPS: case ID_RECALC_AUDIO_VOLUME: case ID_RECALC_AUDIO_MUTE: case ID_RECALC_AUDIO_LISTENER: case ID_RECALC_AUDIO: ``` *component_type = NodeType::AUDIO; ``` break; ```
Member

I don't understand the dependency graph system fully, so I cannot really comment on the patch, so it's good from me :D

I guess the other bugs are also caused by the dependency graph?

I don't understand the dependency graph system fully, so I cannot really comment on the patch, so it's good from me :D I guess the other bugs are also caused by the dependency graph?
Bastien Montagne added this to the Core project 2023-02-09 15:42:54 +01:00
Bastien Montagne removed this from the Core project 2023-02-09 18:20:37 +01:00
Philipp Oeser removed the
Interest
Python API
label 2023-02-10 09:04:27 +01:00
Sign in to join this conversation.
No Label
Interest
Alembic
Interest
Animation & Rigging
Interest
Asset Browser
Interest
Asset Browser Project Overview
Interest
Audio
Interest
Automated Testing
Interest
Blender Asset Bundle
Interest
BlendFile
Interest
Collada
Interest
Compatibility
Interest
Compositing
Interest
Core
Interest
Cycles
Interest
Dependency Graph
Interest
Development Management
Interest
EEVEE
Interest
EEVEE & Viewport
Interest
Freestyle
Interest
Geometry Nodes
Interest
Grease Pencil
Interest
ID Management
Interest
Images & Movies
Interest
Import Export
Interest
Line Art
Interest
Masking
Interest
Metal
Interest
Modeling
Interest
Modifiers
Interest
Motion Tracking
Interest
Nodes & Physics
Interest
OpenGL
Interest
Overlay
Interest
Overrides
Interest
Performance
Interest
Physics
Interest
Pipeline, Assets & IO
Interest
Platforms, Builds & Tests
Interest
Python API
Interest
Render & Cycles
Interest
Render Pipeline
Interest
Sculpt, Paint & Texture
Interest
Text Editor
Interest
Translations
Interest
Triaging
Interest
Undo
Interest
USD
Interest
User Interface
Interest
UV Editing
Interest
VFX & Video
Interest
Video Sequencer
Interest
Virtual Reality
Interest
Vulkan
Interest
Wayland
Interest
Workbench
Interest: X11
Legacy
Blender 2.8 Project
Legacy
Milestone 1: Basic, Local Asset Browser
Legacy
OpenGL Error
Meta
Good First Issue
Meta
Papercut
Meta
Retrospective
Meta
Security
Module
Animation & Rigging
Module
Core
Module
Development Management
Module
EEVEE & Viewport
Module
Grease Pencil
Module
Modeling
Module
Nodes & Physics
Module
Pipeline, Assets & IO
Module
Platforms, Builds & Tests
Module
Python API
Module
Render & Cycles
Module
Sculpt, Paint & Texture
Module
Triaging
Module
User Interface
Module
VFX & Video
Platform
FreeBSD
Platform
Linux
Platform
macOS
Platform
Windows
Priority
High
Priority
Low
Priority
Normal
Priority
Unbreak Now!
Status
Archived
Status
Confirmed
Status
Duplicate
Status
Needs Info from Developers
Status
Needs Information from User
Status
Needs Triage
Status
Resolved
Type
Bug
Type
Design
Type
Known Issue
Type
Patch
Type
Report
Type
To Do
No Milestone
No project
No Assignees
5 Participants
Notifications
Due Date
The due date is invalid or out of range. Please use the format 'yyyy-mm-dd'.

No due date set.

Dependencies

No dependencies set.

Reference: blender/blender#94627
No description provided.