VSE - Bad interpolation in exported audio #68946

Open
opened 2019-08-21 00:53:20 +02:00 by hudson barkley · 20 comments

Blender Version
Broken: 2.80

Short description of error
Exported audio from the VSE is not properly interpolated, creating a 'stair-stepped' pattern when it should be smooth.
Untitled3.png
Channel 1 is the original waveform with keyframe applied, channel 2 is the timeline exported to wav, and imported back in.

Also, there appears to be a delay on the animation by a frame - the fade in should be at full volume on frame 7, but it reaches full volume at frame 8 on the exported waveform.

**Blender Version** Broken: 2.80 **Short description of error** Exported audio from the VSE is not properly interpolated, creating a 'stair-stepped' pattern when it should be smooth. ![Untitled3.png](https://archive.blender.org/developer/F7676264/Untitled3.png) Channel 1 is the original waveform with keyframe applied, channel 2 is the timeline exported to wav, and imported back in. Also, there appears to be a delay on the animation by a frame - the fade in should be at full volume on frame 7, but it reaches full volume at frame 8 on the exported waveform.
Author

Added subscriber: @snuq

Added subscriber: @snuq

#70682 was marked as duplicate of this issue

#70682 was marked as duplicate of this issue

Added subscriber: @PaulMcManus

Added subscriber: @PaulMcManus
Author

side note: The frequency of the interpolation can be controlled with the 'accuracy' setting when exporting as audio only, but there appears to be now way to control this when exporting to video.
My suggestion: This accuracy setting should be changed to a render setting, and always displayed in the render panel under the other audio settings.

side note: The frequency of the interpolation can be controlled with the 'accuracy' setting when exporting as audio only, but there appears to be now way to control this when exporting to video. My suggestion: This accuracy setting should be changed to a render setting, and always displayed in the render panel under the other audio settings.

Added subscriber: @iss

Added subscriber: @iss

I have a strong feeling, that this, #68945 (VSE - Improper audio on frame 1 when exporting to lossy-compressed audio) and #69167 (VSE - "Render Audio" exports only one audio strip in some cases) are caused by the same issue, or at least an issue in depsgraph.

I have a strong feeling, that this, #68945 (VSE - Improper audio on frame 1 when exporting to lossy-compressed audio) and #69167 (VSE - "Render Audio" exports only one audio strip in some cases) are caused by the same issue, or at least an issue in depsgraph.

I am testing this now, and I can reproduce this issue in 2.79 also.
I will have to ask more devs how/if this can be mitigated.

I am testing this now, and I can reproduce this issue in 2.79 also. I will have to ask more devs how/if this can be mitigated.

Added subscribers: @neXyon, @dr.sybren

Added subscribers: @neXyon, @dr.sybren

Perhaps I never noticed this effect, because I render 60FPS and rarely use fade-ins, but I always thought, that property animation was done in audaspace internally. @neXyon, do you know how this was/should be implemented?

Not sure who else to ask, perhaps @dr.sybren may know something about this?

Perhaps I never noticed this effect, because I render 60FPS and rarely use fade-ins, but I always thought, that property animation was done in audaspace internally. @neXyon, do you know how this was/should be implemented? Not sure who else to ask, perhaps @dr.sybren may know something about this?

I haven't looked at audio handling in the VSE, so I wouldn't know by heart what could cause this.

I haven't looked at audio handling in the VSE, so I wouldn't know by heart what could cause this.

In #68946#786927, @dr.sybren wrote:
I haven't looked at audio handling in the VSE, so I wouldn't know by heart what could cause this.

This task has little(nothing) to do with VSE, but rather actual implementation of rendering the audio and its animation.

> In #68946#786927, @dr.sybren wrote: > I haven't looked at audio handling in the VSE, so I wouldn't know by heart what could cause this. This task has little(nothing) to do with VSE, but rather actual implementation of rendering the audio and its animation.
Member

The interpolation is not a bug per se. The audio animation system is evaluated once for every read, so you basically get nearest neighbor interpolation for your buffer size. The buffer size can be adjusted during audio export as you correctly noticed. When rendering a video though, the audio system is called once per (image) frame so you get this issue here. I think having a general option in the render settings would be a good idea to mitigate the issue.

Regarding the one frame off error: does this also happen in 2.79?

The interpolation is not a bug per se. The audio animation system is evaluated once for every read, so you basically get nearest neighbor interpolation for your buffer size. The buffer size can be adjusted during audio export as you correctly noticed. When rendering a video though, the audio system is called once per (image) frame so you get this issue here. I think having a general option in the render settings would be a good idea to mitigate the issue. Regarding the one frame off error: does this also happen in 2.79?

In #68946#786957, @neXyon wrote:
I think having a general option in the render settings would be a good idea to mitigate the issue.

I think there is the same issue with exporting audio right now. Perhaps it's the depsgraph limited to evaluation only at whole frames, I really don't know.

Regarding the one frame off error: does this also happen in 2.79?

I will bring up the offset issue in #68945 (VSE - Improper audio on frame 1 when exporting to lossy-compressed audio).
My suspicion just by reading code is, that we set wrong frame by AUD_SequenceEntry_setAnimationData(). But I want to test this myself first before I comment.

Thanks for help!

I will keep this open, because this behavior is quite bad.

> In #68946#786957, @neXyon wrote: > I think having a general option in the render settings would be a good idea to mitigate the issue. I think there is the same issue with exporting audio right now. Perhaps it's the depsgraph limited to evaluation only at whole frames, I really don't know. > Regarding the one frame off error: does this also happen in 2.79? I will bring up the offset issue in #68945 (VSE - Improper audio on frame 1 when exporting to lossy-compressed audio). My suspicion just by reading code is, that we set wrong frame by `AUD_SequenceEntry_setAnimationData()`. But I want to test this myself first before I comment. Thanks for help! I will keep this open, because this behavior is quite bad.
Member

Let me revise what I wrote in my previous comment, my bad memory caused some wrong statements:

There is indeed linear volume interpolation during audio mixing. It interpolates from the last value it had (initially 0 now, thanks to #68945) to whatever value is set during one of those buffer mixes. This most likely causes the delay that you observe which is bigger the bigger the buffer size is, since it will reach the value that the whole buffer would have had in the case of no/nearest neighbor interpolation only at the end of the buffer.

Thanks to #68945 I digged a bit deeper into the issue and I think (though not certain) the odd resulting curve is caused by the depsgraph that keeps changing animation cache values during mixing/rendering.
I also modified your test file to animate volume from 0 to 1 from beginning to end of the animation. When I load this file after blender startup and immediately mixdown/render audio I get a silent sound file (0 volume all the way through). The Properties -> Scene Properties -> Audio -> Update Animation Cache button that should mitigate this issue has no effect.

[rant start]
I have the feeling that the audio animation system and the new depsgraph are very difficult to get to work together. The audio animation system was already a hack in the first place to get audio animation working with Blender's animation system that is certainly not designed for audio. Seems like the number of issues increased further with the depsgraph. I have neither time nor inclination to work on another hack to get the hack to work (better). As it is now I see basically two options: depsgraph core developers think through the issues of audio animation that I've been raising for a while and together we come up with a proper, working solution or we completely remove audio animation from Blender.
[rant end]

Let me revise what I wrote in my previous comment, my bad memory caused some wrong statements: There is indeed linear volume interpolation during audio mixing. It interpolates from the last value it had (initially 0 now, thanks to #68945) to whatever value is set during one of those buffer mixes. This most likely causes the delay that you observe which is bigger the bigger the buffer size is, since it will reach the value that the whole buffer would have had in the case of no/nearest neighbor interpolation only at the end of the buffer. Thanks to #68945 I digged a bit deeper into the issue and I think (though not certain) the odd resulting curve is caused by the depsgraph that keeps changing animation cache values during mixing/rendering. I also modified your test file to animate volume from 0 to 1 from beginning to end of the animation. When I load this file after blender startup and immediately mixdown/render audio I get a silent sound file (0 volume all the way through). The Properties -> Scene Properties -> Audio -> Update Animation Cache button that should mitigate this issue has no effect. [rant start] I have the feeling that the audio animation system and the new depsgraph are very difficult to get to work together. The audio animation system was already a hack in the first place to get audio animation working with Blender's animation system that is certainly not designed for audio. Seems like the number of issues increased further with the depsgraph. I have neither time nor inclination to work on another hack to get the hack to work (better). As it is now I see basically two options: depsgraph core developers think through the issues of audio animation that I've been raising for a while and together we come up with a proper, working solution or we completely remove audio animation from Blender. [rant end]

Thanks for fix.
The animation cache stuff may explain #69167 (VSE - "Render Audio" exports only one audio strip in some cases). I will look into this as well. I've got quite a few audio related bugs in tracker, so this may have to be resolved in some way.

I will look into those and see what can be done.

Couldn't this be resolved by providing simple callback interface?
I mean instead of AUD_SequenceEntry_setAnimationData() it could be AUD_SequenceEntry_setPropertyEvalFunction(). Depsgraph would register its function to call during mixdown, so you can have precise data, exactly when you need it.

Thanks for fix. The animation cache stuff may explain #69167 (VSE - "Render Audio" exports only one audio strip in some cases). I will look into this as well. I've got quite a few audio related bugs in tracker, so this may have to be resolved in some way. I will look into those and see what can be done. Couldn't this be resolved by providing simple callback interface? I mean instead of `AUD_SequenceEntry_setAnimationData()` it could be `AUD_SequenceEntry_setPropertyEvalFunction()`. Depsgraph would register its function to call during mixdown, so you can have precise data, exactly when you need it.
Member

As I wrote in #59540#588156 doing a callback for every sound sample is way too slow. We could consider it for every buffer if it is fast enough and it is possible. The issue here is that the depsgraph would need to provide the functionality to get the value of a single property for a specific time. I'm not sure if it can easily do that?

As I wrote in #59540#588156 doing a callback for every sound sample is way too slow. We could consider it for every buffer if it is fast enough and it is possible. The issue here is that the depsgraph would need to provide the functionality to get the value of a single property for a specific time. I'm not sure if it can easily do that?

Added subscriber: @Sergey

Added subscriber: @Sergey

In #68946#789089, @neXyon wrote:
As I wrote in #59540#588156 doing a callback for every sound sample is way too slow. We could consider it for every buffer if it is fast enough and it is possible.

That's what I thought, not every sample, but fairly regulary. Even if it was for each sample, and would be slow, audio rendering is done in separate thread, and it's not likely it would bottleneck rendering itself. It would be at least correct. During preview callback could be called say every 10ms only, if that is distinguishable from rendering.

We can also pre-build a waveform(float array) with good enough resolution that could be used to modulate property value. The later would correspond to animation cache idea, not sure how it's done now.

The issue here is that the depsgraph would need to provide the functionality to get the value of a single property for a specific time. I'm not sure if it can easily do that?

Assuming, we want to correctly render audio, it has to be able to do that for each sample.

Not sure if @Sergey would like to add anything here, or if there is already some TODO written for this issue?

> In #68946#789089, @neXyon wrote: > As I wrote in #59540#588156 doing a callback for every sound sample is way too slow. We could consider it for every buffer if it is fast enough and it is possible. That's what I thought, not every sample, but fairly regulary. Even if it was for each sample, and would be slow, audio rendering is done in separate thread, and it's not likely it would bottleneck rendering itself. It would be at least correct. During preview callback could be called say every 10ms only, if that is distinguishable from rendering. We can also pre-build a waveform(float array) with good enough resolution that could be used to modulate property value. The later would correspond to animation cache idea, not sure how it's done now. > The issue here is that the depsgraph would need to provide the functionality to get the value of a single property for a specific time. I'm not sure if it can easily do that? Assuming, we want to correctly render audio, it has to be able to do that for each sample. Not sure if @Sergey would like to add anything here, or if there is already some TODO written for this issue?
Author

Just wanted to chime in as a user who animates audio all the time.

Im thinking that the current system (and accuracy) is fine for live playback, and i dont think it would be a big deal if audio rendering were slower (tho, a progress meter might be good... an hour+ of audio does take some time to render already).

On the other hand, if making the linear interpolation behave the way it should is a reasonable possible fix, i dont know if implementing every-sample depsgraph is needed really, thats kinda what the audio render accuracy is for, right?

Regardless tho, id be more than happy with even just putting the accuracy setting in scene render settings so i can crank it up and set it in my startup file.

Just wanted to chime in as a user who animates audio all the time. Im thinking that the current system (and accuracy) is fine for live playback, and i dont think it would be a big deal if audio rendering were slower (tho, a progress meter might be good... an hour+ of audio does take some time to render already). On the other hand, if making the linear interpolation behave the way it should is a reasonable possible fix, i dont know if implementing every-sample depsgraph is needed really, thats kinda what the audio render accuracy is for, right? Regardless tho, id be more than happy with even just putting the accuracy setting in scene render settings so i can crank it up and set it in my startup file.

Added subscriber: @ronsn

Added subscriber: @ronsn
Philipp Oeser removed the
Interest
VFX & Video
label 2023-02-10 09:32:06 +01:00
Philipp Oeser added the
Interest
Core
label 2023-02-10 11:09:57 +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
6 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#68946
No description provided.