Skip to content

Conversation

@ivanstepanovftw
Copy link
Contributor

@ivanstepanovftw ivanstepanovftw commented Jun 16, 2024

Objective

  • Seeking in audio sink to specific location

Solution

Related issue: #9076

Testing

  • It is not working, help needed.

    /home/i/.cargo/bin/cargo +nightly run --color=always --package bevy --example audio_control --release
    Finished `release` profile [optimized] target(s) in 0.30s
     Running `target/release/examples/audio_control`
2024-06-16T07:42:04.325210Z  INFO bevy_diagnostic::system_information_diagnostics_plugin::internal: SystemInfo { os: "Linux 40 Fedora Linux", kernel: "6.8.11-300.fc40.x86_64", cpu: "AMD Ryzen 7 5800U with Radeon Graphics", core_count: "8", memory: "14.5 GiB" }
2024-06-16T07:42:04.451561Z  INFO bevy_render::renderer: AdapterInfo { name: "AMD Radeon Graphics (RADV RENOIR)", vendor: 4098, device: 5688, device_type: IntegratedGpu, driver: "radv", driver_info: "Mesa 24.1.1", backend: Vulkan }
2024-06-16T07:42:04.852471Z  INFO bevy_winit::system: Creating new window "App" (Entity { index: 0, generation: 1 })
2024-06-16T07:42:04.853166Z  INFO winit::platform_impl::platform::x11::window: Guessed window scale factor: 2
thread 'Compute Task Pool (1)' panicked at examples/audio/audio_control.rs:62:68:
called `Result::unwrap()` on an `Err` value: NotSupported { underlying_source: "rodio::decoder::vorbis::VorbisDecoder<std::io::cursor::Cursor<bevy_audio::audio_source::AudioSource>>" }
stack backtrace:
   0: rust_begin_unwind
   1: core::panicking::panic_fmt
   2: core::result::unwrap_failed
   3: core::ops::function::impls::<impl core::ops::function::FnMut<A> for &mut F>::call_mut
   4: <bevy_ecs::system::function_system::FunctionSystem<Marker,F> as bevy_ecs::system::system::System>::run_unsafe
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
Encountered a panic in system `audio_control::seek`!
Encountered a panic in system `bevy_app::main_schedule::Main::run_main`!

Process finished with exit code 101

Changelog

Added

  • Seeking to specific location in audio sink.

@github-actions
Copy link
Contributor

Welcome, new contributor!

Please make sure you've read our contributing guide and we look forward to reviewing your pull request shortly ✨

@torsteingrindvik
Copy link
Contributor

torsteingrindvik commented Jun 16, 2024

https://github.com/RustAudio/rodio/blob/master/src/decoder/vorbis.rs#L90

It looks like seeking is only possible for some audio formats, and vorbis is not one.
So you could consider changing formats until vorbis has support.

EDIT: Whoops I thought this was an issue not a PR

sink.try_seek(std::time::Duration::from_secs_f64(0.0)).unwrap();

The problem then is just that you cannot call .unwrap() since it's fallible and some backends might not support it.

@alice-i-cecile alice-i-cecile added C-Feature A new feature, making something new possible A-Audio Sounds playback and modification S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jun 16, 2024
@ivanstepanovftw ivanstepanovftw marked this pull request as draft June 17, 2024 19:52
@alice-i-cecile alice-i-cecile added S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged and removed S-Needs-Review Needs reviewer attention (from anyone!) to move forward labels Jul 14, 2024
@taj-holliday
Copy link
Contributor

@ivanstepanovftw are you planning on finishing this PR? One of my projects would benefit from this feature, and I'd be willing to adopt if you aren't.

@NthTensor
Copy link
Contributor

Closing as adopted.

@NthTensor NthTensor closed this Apr 28, 2025
@github-project-automation github-project-automation bot moved this to Done in Audio Apr 28, 2025
github-merge-queue bot pushed a commit that referenced this pull request May 3, 2025
Adopted #13869 

# Objective

Fixes #9076 

## Solution

Using `rodio`'s `try_seek`

## Testing

@ivanstepanovftw added a `seek` system using `AudioSink` to the
`audio_control.rs` example. I got it working with .mp3 files, but rodio
doesn't support seeking for .ogg and .flac files, so I removed it from
the commit (since the assets folder only has .ogg files). Another thing
to note is that `try_seek` fails when using `PlaybackMode::Loop`, as
`rodio::source::buffered::Buffered` doesn't support `try_seek`. I
haven't tested `SpatialAudioSink`.

## Notes

I copied the docs for `try_seek` verbatim from `rodio`, and re-exported
`rodio::source::SeekError`. I'm not completely confident in those
decisions, please let me know if I'm doing anything wrong.

</details>

---------

Co-authored-by: Ivan Stepanov <ivanstepanovftw@gmail.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
Co-authored-by: François Mockers <mockersf@gmail.com>
andrewzhurov pushed a commit to andrewzhurov/bevy that referenced this pull request May 17, 2025
Adopted bevyengine#13869 

# Objective

Fixes bevyengine#9076 

## Solution

Using `rodio`'s `try_seek`

## Testing

@ivanstepanovftw added a `seek` system using `AudioSink` to the
`audio_control.rs` example. I got it working with .mp3 files, but rodio
doesn't support seeking for .ogg and .flac files, so I removed it from
the commit (since the assets folder only has .ogg files). Another thing
to note is that `try_seek` fails when using `PlaybackMode::Loop`, as
`rodio::source::buffered::Buffered` doesn't support `try_seek`. I
haven't tested `SpatialAudioSink`.

## Notes

I copied the docs for `try_seek` verbatim from `rodio`, and re-exported
`rodio::source::SeekError`. I'm not completely confident in those
decisions, please let me know if I'm doing anything wrong.

</details>

---------

Co-authored-by: Ivan Stepanov <ivanstepanovftw@gmail.com>
Co-authored-by: François Mockers <francois.mockers@vleue.com>
Co-authored-by: Jan Hohenheim <jan@hohenheim.ch>
Co-authored-by: François Mockers <mockersf@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

A-Audio Sounds playback and modification C-Feature A new feature, making something new possible S-Waiting-on-Author The author needs to make changes or address concerns before this can be merged

Projects

Status: Done

Development

Successfully merging this pull request may close these issues.

5 participants