Page MenuHome

Can't get sound factory from python
Closed, ArchivedPublic

Description

System Information
Operating system: Ubuntu linux, probably also other systems
Graphics card: not related

Blender Version
Broken: 2.80, c0c1b4542f39, master, 2019-06-24, but not sure when it started
Worked: 2.80, 5ac7675f4c9c 2019-04-15

Short description of error
Code "bpy.data.sounds[0].factory" returns "None", instead of "aud.Sound" object.

Exact steps for others to reproduce the error

  • add any sound anywhere
  • switch to scripting workspace
  • try this code:

print(bpy.data.sounds[0].factory)

Details

Type
Bug

Event Timeline

Dalai Felinto (dfelinto) lowered the priority of this task from Needs Triage by Developer to Confirmed, Medium.

Sergey I can't really reproduce with my home builds, but it happens with official builds. So I don't really know right now if this was introduced by your depsgraph changes to the sound system.
That said I can confirm that it worked before (had a build of rBaca13040dac laying around).

Sergey Sharybin (sergey) closed this task as Archived.Jun 28 2019, 9:32 AM

All sound handles are now stored in the evaluated speakers, sounds and scenes. This is because same scene might be evaluated to a different state now.

So you need to access sound factory from an evaluated sound:

depsgraph = bpy.context.evaluated_depsgraph_get()
sound_eval = bpy.data.sounds[0].evaluated_get(depsgraph)
print(sound_eval.factory)

Thanks for the report,but this was an inevitable API change.

Thank you very much, I will use this code.

It would be nice to have this information in the api documentation:
https://docs.blender.org/api/blender2.8/bpy.types.Sound.html?highlight=factory#bpy.types.Sound.factory