fast4x / RiMusic

A multilingual Android application for streaming music from YouTube Music.
https://rimusic.xyz
GNU General Public License v3.0
2.61k stars 133 forks source link

[Feature]:Waveforms for every song #2720

Open ALMIGHTY-VC opened 4 months ago

ALMIGHTY-VC commented 4 months ago

Description

https://medium.com/swlh/creating-waveforms-out-of-spotify-tracks-b22030dd442b Can we similarly generate real waveforms for song we are streaming on rimusic this will be a complex task definitely

Suggested Solution

We can just follow the guide and try to implement something similar in the rimusic player and i think yt music even has less restrictions and it would be easy to make waveforms for it for each song.

Alternatives

No alternatives the default options suffice.

Additional Context

No response

twistios commented 4 months ago

I think it might not even be very hard to implement (because of the visualizer) but I think that it requires to download the full song first so there will be a higher delay until a song can start playing. Something that might be a bit easier would be a waveform until the point of how far it has been played already.

aneesh1122 commented 4 months ago

until the point of how far it has been played already

Or how far it has been loaded already.

ALMIGHTY-VC commented 4 months ago

until the point of how far it has been played already

Or how far it has been loaded already.

Yes and the next time we play it the apo might save it as a cache and load the whole waveform?!

aneesh1122 commented 4 months ago

until the point of how far it has been played already

Or how far it has been loaded already.

Yes and the next time we play it the apo might save it as a cache and load the whole waveform?!

If the song is cached or downloaded I don't see why not

That's waaaay above my pay grade though. Only fast4x can do this

ALMIGHTY-VC commented 4 months ago

until the point of how far it has been played already

Or how far it has been loaded already.

Yes and the next time we play it the apo might save it as a cache and load the whole waveform?!

If the song is cached or downloaded I don't see why not

That's waaaay above my pay grade though. Only fast4x can do this

Yes this feature if we want to use simultaneously would require a lil bit more net and ram but the main part is how the processes happen and what are the bugs which may take place

abrar-wadud commented 4 months ago

In my opinion, I think this is an excellent idea. But I think it doesn't worth to do it now. Think about it, how many people uses these kind of player in foreground. Most of the users uses this in the foreground for only couple of time and then forget about it. They mostly uses these as a background music player. So, I think instead of focusing on the frontend of the app @fast4x should focus on its backend. Like fixing bugs(this app has a lot of them) or other things.

twistios commented 4 months ago

Actually I was already thinking about this feature when 0.6.41 had the new visualizer incl. the first one which has the audio wave.

twistios commented 4 months ago

I really would like to try to work on this feature. It does not seem to be too hard and I think this does match my knowledge, especially as I already know how to do this in pseudocode.

twistios commented 4 months ago

The hardest part is how I can get the information of the past, because I think currently it only uses the audio wave of a very short recent section.

aneesh1122 commented 4 months ago

The hardest part is how I can get the information of the past, because I think currently it only uses the audio wave of a very short recent section.

visualizer also require microphone access which means it's accessing the highs and lows in real time. I don't know how visualizer can be used to access the future highs and lows.

twistios commented 4 months ago

It should not be too hard for the already played section at least.

twistios commented 4 months ago

Ok it is harder than expected (that was expected :smile: )

https://github.com/user-attachments/assets/36024830-f6ab-470f-ae9f-5c45e9954a57

This video shows that width and speed of visualizer already (kind of) works. As it can be seen, it does not do anything useful visually.

(For some reason the video skips for me...)

aneesh1122 commented 4 months ago

Ok it is harder than expected (that was expected :smile: )

https://github.com/user-attachments/assets/36024830-f6ab-470f-ae9f-5c45e9954a57

This video shows that width and speed of visualizer already (kind of) works. As it can be seen, it does not do anything useful visually.

(For some reason the video skips for me...)

I don't know what's happening here but you just need one high value for each specific time interval. X-axis -> duration and Y-axis -> high value. Set a maximum value wrt which the volume will be measured.

Later mirror it wrt x axis and you'll have the waveform.

Now I don't know how the visualizer works and how hard it is to do. I'm just throwing out ideas

twistios commented 4 months ago

I am currently trying to do a one-to-one visualizer first (so the idea is visualizer 1 but all of it until the position that is played).

twistios commented 4 months ago

Mostly right (except some bugs).

https://github.com/user-attachments/assets/a7d31fae-e02a-40d4-815a-71d8bfbcbd21

aneesh1122 commented 4 months ago

Mostly right (except some bugs).

https://github.com/user-attachments/assets/a7d31fae-e02a-40d4-815a-71d8bfbcbd21

Okay this is much better. Can you reduce the height of the waveform?

twistios commented 4 months ago

This is the normal height. Because it is this small, I "hard-coded" scaled it up.

https://github.com/user-attachments/assets/5510e30d-d18e-482c-8a7a-b3ded83592dc

twistios commented 4 months ago

I also wanted to implement the frame-skipping (just for testing) but it doesn't do anything, no matter how many frames I disable it. I guess the condition is not activated for some reason.

aneesh1122 commented 4 months ago

This is the normal height. Because it is this small, I "hard-coded" scaled it up.

https://github.com/user-attachments/assets/5510e30d-d18e-482c-8a7a-b3ded83592dc

In that case, increase the datum for loudness measurement.

For example, if the loudness is 1200 and you set datum as 1000 then 200 will be measured.

twistios commented 4 months ago

New calculation method (but less weird behaviour), still hardcoded scaling (I don't know how to do this what you proposed @aneesh1122).

New features: speed-scaling (if 1 then normal visualizer, if larger moves to beginning after reaching end, example video with factor 10). Still some bugs, for example position can currently not be properly reduced.

https://github.com/user-attachments/assets/f521ffe4-a8ff-4f08-a347-a6cf98fb3269

aneesh1122 commented 4 months ago

New calculation method (but less weird behaviour), still hardcoded scaling (I don't know how to do this what you proposed @aneesh1122).

New features: speed-scaling (if 1 then normal visualizer, if larger moves to beginning after reaching end, example video with factor 10). Still some bugs, for example position can currently not be properly reduced.

rimusic_waveform_v0.5.mp4

that's great. Now, take this, create a function inside visualizer file and place it in controls file.

twistios commented 4 months ago

Moving the play position around does seem to work now (you can see some of the current bugs in the video). It seems like the wave-data is not normalized so sometimes it is too large.

https://github.com/user-attachments/assets/3f9ab3fd-0b67-4f87-a909-32e12047425b

aneesh1122 commented 4 months ago

Moving the play position around does seem to work now (you can see some of the current bugs in the video). It seems like the wave-data is not normalized so sometimes it is too large.

https://github.com/user-attachments/assets/3f9ab3fd-0b67-4f87-a909-32e12047425b

Is it not possible to multiply these data with a factor like 0.5? Normalize them yourself if they are not normalized.

twistios commented 4 months ago

This is with factor=100.

https://github.com/user-attachments/assets/ae2e79a7-3a37-415e-8d9d-0fb3718a88b5

About normalizing myself: I don't know the maximal value so I can not do this (I don't know the full song).

aneesh1122 commented 4 months ago

This is with factor=100.

https://github.com/user-attachments/assets/ae2e79a7-3a37-415e-8d9d-0fb3718a88b5

About normalizing myself: I don't know the maximal value so I can not do this (I don't know the full song).

In the settings RiMusic has the option to normalize. Maybe that can help

twistios commented 4 months ago

that's great. Now, take this, create a function inside visualizer file and place it in controls file.

I did not yet find this places.

aneesh1122 commented 4 months ago

that's great. Now, take this, create a function inside visualizer file and place it in controls file.

I did not yet find this places.

just try to improve it. after fast4x merges my pull request I'll look into your repo and see if I can do something

twistios commented 4 months ago

Next step is done. I don't yet know what the maximal value should be, currently there is no custom icon (I just used the playback speed one). Also it is not yet connected to the visualizer and it is in the menu by default (even if visualizer is not activated and current visualizer is not the first/correct one).

https://github.com/user-attachments/assets/ed924780-3769-49f5-a1cf-8c9675ece755

fast4x commented 4 months ago

Visualizer it's more complex, your work is ok with visualizer, but it require permission by default. A suggestion for you, work in another think because for now isn't possible to spent time in this functionality. Sorry.

I'm working hard on crash and it's much complicated to find...

twistios commented 4 months ago

I want to help with crashes. If it is about crashes that I have reported, you can give me some idea what I should try.

fast4x commented 4 months ago

I think the problem can be in MainActivity related initialization of any variable. You can work in onResume, onCreate for test your crash. Try to understand...

Wjxfi commented 4 months ago

I hope ...