hendriks73 / ffsampledsp

FFmpeg based service provider for javax.sound.sampled.
GNU Lesser General Public License v2.1
24 stars 5 forks source link

I have another question with audioInputStream.skip() #13

Closed Kokecena closed 2 years ago

Kokecena commented 2 years ago

Yeah it's me again, sorry 😥, I will try to put you in context, I am rewriting an old abandoned project and everything using your library, everything so far works perfectly well, the problem comes when I want to jump to some second of the song, there is a seek() listener method in charge of executing when you do click to some position of the JSlider, internally it passes the parameter to the method of my player in this case seek(long byte) I pass the following formula as a parameter

Math.round(<Total size in bytes of the audioinputstream> * (double) <current selected second> / <duration of the song in milliseconds>)

and inside the method, the person in charge of skipping the song is the audioInputStream.skip (bytes); this same formula and code is exactly the same as the one in the project.

My observations have been at least those that I have tried both in mp3 and in ogg, it happens that they remain as 1 or 1:45 minutes from the total of the song

In Flac format something else happens, and that is that it ends 1 to 2 minutes before, I have not tried other formats. So I don't know what I'm doing wrong if it's me and I have to program this part in another way in which I can't think of any, or another is that it is somehow affected by your library.

In both cases, as I mentioned, it only happens when I want to jump to some part of the song.

I am not using a Clip to play the file I use a SourceDataLine, hope my problem is understood

Kokecena commented 2 years ago

https://user-images.githubusercontent.com/75457600/145736477-e78003b6-4fa4-48a2-a58b-55846ac73da4.mp4

Everything works perfect when it is allowed to reproduce, but when I jump to some second this happens

Part of the code that I have for everything is almost the same as the project, but especially in this one it is exactly the same and I am having problems, for each format do I require another way of skipping the seconds that I want?

hendriks73 commented 2 years ago

Sorry for the late reply. I have an idea where this might be coming from (a side-effect of the earlier "fix") and plan on fixing it, but currently don't have the time. Sorry.

Kokecena commented 2 years ago

Hi, Merry Christmas haha, don't worry, I actually solved it, relatively, I divided the total duration of the song by some magic number that would fit relatively well with most songs and well, it works more or less, but well it's functional haha Magic numbers

https://user-images.githubusercontent.com/75457600/147746176-02523223-ff0c-478a-ab1b-f7a51a51d09b.mp4

In the longest songs it has a margin of error of 1s to 3s and in others of 1s or less, but I repeat it is functional for me, do not worry, happy new years holidays 😄😃

hendriks73 commented 2 years ago

I believe the issue is fixed in 0.9.44 (soon on Maven central).

Kokecena commented 2 years ago

Hello, sorry for the delay, I just updated to 0.9.45 and tried to do it again with the formula but the same thing still happens, or is there any other way to skip to the second of a song without using the skip method?

hendriks73 commented 2 years ago

That leaves me puzzled. Can you provide a minimal, reproducible example?

Kokecena commented 2 years ago

Excuse me for being confused, I meant to use the skip method of the AudioInputStream class to skip a second of a song but it's fixed now, everything works fine, thanks for the fixes you made, I have a question and I'll leave it at Peace 😥, what formats does it support? Currently I only put the FLAC, AAC, M4A, OGG and MP3 formats on my player, but I really don't know the range of audio formats your library has, and the website doesn't make it very clear to me what they are, and sorry for the inconvenience

hendriks73 commented 2 years ago

FFSampledSP is built on https://www.tagtraum.com/ffmpeg/ and supports pretty much everything FFmpeg supports, minus the formats disabled in the configuration described at https://www.tagtraum.com/ffmpeg/#Configuration So there is plenty more formats, but not a concrete list.

Kokecena commented 2 years ago

Understood, I really appreciate the bug fixes, thanks to your library now I have a beautiful player with support for various formats.

image

I will recommend this library😄because I feel that it is not well known, when I was looking for something to play mp3 they always throw me libraries like JLayer

hendriks73 commented 2 years ago

Very nice! Is your player available somewhere?

I will recommend this library

Thank you. Please do! :-)

This may not be of any value to you, because you show amplitudes (or RMS or the like), but check out https://github.com/hendriks73/audioplayer4j It's a (non-visual) audio player with a nice and simple API.

Kokecena commented 2 years ago

Well, I really don't know, it's just a project to say goodbye to the fun of Java and start with the boring and highly requested SpringBoot or Spring, those famous frameworks... and why current players have so many things that I don't even use, so I started mine, anyway I will upload it to GitHub and I will upload a video of its use, there I will reference all the libraries that I have been occupying, and in the player an "About..." section where I will refer to the authors of the libraries that I occupy and their GitHub references

This may not be of any value to you, because you show amplitudes (or RMS or the like), but check out https://github.com/hendriks73/audioplayer4j It's a (non-visual) audio player with a nice and simple API.

Wow it's so simple that if I had found it before, I don't think I would have put the visualizations, it was a headache to see how to implement them, Seeing the API code, it supports change of output audio device at runtime, right? That's great, not long ago I tried to implement it in my player, but I had to restart the program and I was looking for something in real time, but I gave up. and I settle for just plugging in my headphones