Scirra / Construct-bugs

Public bug report submissions for Construct 3 and Construct Animate. Please read the guidelines then click the 'Issues' tab to get started.
https://www.construct.net
104 stars 83 forks source link

"Audio.playbacktime()" is not affected by the action "Set {} playback rate to {}" #4867

Closed mitsuhashish closed 3 years ago

mitsuhashish commented 3 years ago

Problem description

The "Audio.playbacktime()" expression returns an incorrect value when the playback rate is modified by the "Set {} playback rate to {}" action

Attach a .c3p

AUDIO PLAYBACKRATE BUG.zip

Steps to reproduce

Run the layout and see how the playbacktime expression stops at 210.256... while the slowed-down audio is still playing

Observed result

Compared to time from the audio server the playbacktime advance at the same rate and the audio continue playing while the playbacktime stop due to advancing at the wrong rate

Expected result

playbacktime proceed slowly and isn't advancing at the same rate as the audio server time, matching the actual speed the audio is played back at.

More details

Affected browsers/platforms: Tested only on chrome so far

First affected release: Unknown, Tested only on r250 so far

System details

View details Platform information Browser: Chrome Browser version: 91.0.4472.77 Browser engine: Chromium Context: webapp Operating system: Windows Operating system version: 10 Device type: desktop Device pixel ratio: 1 Logical CPU cores: 4 Approx. device memory: 8 GB User agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.77 Safari/537.36 C3 release: r250 (beta) Language setting: en-US Local storage Storage quota (approx): 134 gb Storage usage (approx): 855 mb (0.6%) Persistant storage: No Browser support notes This list contains missing features that are not required, but could improve performance or user experience if supported. Nothing is missing. Everything is OK! WebGL information Version string: WebGL 2.0 (OpenGL ES 3.0 Chromium) Numeric version: 2 Supports NPOT textures: yes Supports GPU profiling: yes Supports highp precision: yes Vendor: Google Inc. (AMD) Renderer: ANGLE (AMD, AMD Radeon (TM) R9 380 Series Direct3D11 vs_5_0 ps_5_0, D3D11-27.20.21002.112) Major performance caveat: no Maximum texture size: 16384 Point size range: 1 to 1024 Extensions: EXT_color_buffer_float EXT_color_buffer_half_float EXT_disjoint_timer_query_webgl2 EXT_float_blend EXT_texture_compression_bptc EXT_texture_compression_rgtc EXT_texture_filter_anisotropic EXT_texture_norm16 KHR_parallel_shader_compile OES_texture_float_linear WEBGL_compressed_texture_s3tc WEBGL_compressed_texture_s3tc_srgb WEBGL_debug_renderer_info WEBGL_debug_shaders WEBGL_lose_context WEBGL_multi_draw OVR_multiview2 Audio information System sample rate: 48000 Hz Output channels: 2 Output interpretation: speakers Supported decode formats: WebM Opus (audio/webm; codecs=opus) Ogg Opus (audio/ogg; codecs=opus) WebM Vorbis (audio/webm; codecs=vorbis) Ogg Vorbis (audio/ogg; codecs=vorbis) MPEG-4 AAC (audio/mp4; codecs=mp4a.40.5) MP3 (audio/mpeg) FLAC (audio/flac) PCM WAV (audio/wav; codecs=1) Supported encode formats: WebM Opus (audio/webm; codecs=opus) Video information Supported decode formats: WebM AV1 (video/webm; codecs=av01.0.00M.08) MP4 AV1 (video/mp4; codecs=av01.0.00M.08) WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8) Ogg Theora (video/ogg; codecs=theora) H.264 (video/mp4; codecs=avc1.42E01E) Supported encode formats: WebM VP9 (video/webm; codecs=vp9) WebM VP8 (video/webm; codecs=vp8)
mitsuhashish commented 3 years ago

In my case, this would be very useful for a time slowdown effect on my rhythm game where gameplay sync to audio, for example, allowing the playbackrate to be changed multiple times on the same audio, this effect COULD be achieved by using timescale & setting the property "Timescale audio" to ON, however not only it is very inconvenient since you can't use a local timescale and are forced to use global timescale, but also it is not viable due to issue #4865

AshleyScirra commented 3 years ago

This should be fixed in the next beta. Note the PlaybackTime returns the seek time, so with the fix, your example displays the PlaybackTime starting at 200 and incrementing by 1 every 10 seconds due to the playback rate of 0.1, which doesn't match the time measured in events (because that calculation does not itself take in to account the playback rate).