Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add Elapsed filter #273

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open

Add Elapsed filter #273

wants to merge 3 commits into from

Conversation

PaddyCo
Copy link

@PaddyCo PaddyCo commented Mar 1, 2020

as discussed in #192, a way to get the current elapsed time is almost required for things that are supposed to be synced to the audio (rhythm games for example)

I tried solving this by making a filter, and it appears to work pretty well!

I'm not sure this is the most idiomatic approach to the problem (I'll be honest, not super familiar with rodio, or audio in general for that matter) so if you have any suggestions or better ways to solve this, shoot 😄

@PaddyCo PaddyCo changed the title Elapsed filter Add Elapsed filter Mar 1, 2020
@TonalidadeHidrica
Copy link

I think this implementation has several problems:

  • The duration updates only when next iteration of a chunk occurs. This is a problem when we want more precise timestamp than the chunk size.
  • Audio timer is not necessarily synchronized with system timer, and nor is the timing when the next called. Fortunately, now that the new feature of tracking precise playing/recording position is introduced in [WIP] Timestamp and StreamInstant APIs cpal#397, we should make use of this instead.

@ghost
Copy link

ghost commented Jan 2, 2021

Hello, any progress on this? Currently implementing a rhythm game using rodio and I'm hitting on this roadblock. Should I go ahead and open a PR utilising RustAudio/cpal#397 instead?

@TonalidadeHidrica
Copy link

@JackRedstonia Although there's no direct way to get the elapsed time info, current API already enables us getting it. I'm developing a rhythm game too and already succeeded in implemented precise a/v sync feature. You can see my code in my repository: TonalidadeHidrica/taiko-untitled . By the way if you want to implement this feature you can go ahead, I think. (I'm not an owner of this repo though)

@ghost
Copy link

ghost commented Jan 2, 2021

@TonalidadeHidrica I looked through the code and it seems that it only works for one music track at a time, which isn't exactly what I need, I think. I also tried to add the functionality into the rodio crate for the PR but ended up nuking it all as it was too complex.

I believe I should leave this up to someone with better understanding of rodio and cpal.

@TonalidadeHidrica
Copy link

@JackRedstonia I agree that current rodio interface is, although quite easy when performing "fuzzy" playback like music player, not really cut out for precise, framewise playback, when you want to build rhythm game or DTM software for example. That's why I only used rodio for decoding several audio data, and write to audio stream with cpal directly by myself.

Just for curiosity, what is your specific usecase you thought that my code lacks? (Should I refrain from discussing here?)

@ghost
Copy link

ghost commented Jan 2, 2021

@TonalidadeHidrica I'm making a game framework (which the rhythm game is built on) and I'm looking to have the ability to have any (reasonable) number of tracks playing and to be able to get their playing positions, so I'll have to change quite a lot of things to get that working. Nevertheless, the information about RustAudio/cpal#397 was quite useful, so much thanks for that.
Hopefully I'll come up with a decent way to get the above idea into decent code, but for now I'll experiment with another library called BASS. (not that rodio and cpal is bad of course, I just want to see what the available options are, and I'll likely not use BASS anyways due to its horrendous licensing)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants