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

Very Distorted Audio When Playing Short Files #129

Closed
JFulweber opened this issue Sep 17, 2016 · 7 comments
Closed

Very Distorted Audio When Playing Short Files #129

JFulweber opened this issue Sep 17, 2016 · 7 comments

Comments

@JFulweber
Copy link

If I play a short mp3, that seems to be if it's less than 30 seconds, it turns out VERY distorted and sounds awful. I read in another issue that it might be if the audio was mono, so I converted all audio to stereo, but that's not it. I have verified that the mp3 sounds normal if played outside the bot.
Here's the code that pertains to playing:

            event.getTextChannel().sendMessage("Playing " + video.title + " ID is " + video.id);
            File audioFile  = null;
            try {

                System.out.println("playing!");
                audioFile = new File(video.id+".mp3");
                System.out.println(audioFile.getName());
                player = new FilePlayer(audioFile);
                TimerTask playerStop = new PlayerStop(player);
                event.getGuild().getAudioManager().setSendingHandler(player);
                player.play();
                t.schedule(playerStop, (long) video.duration*1000);
                System.out.println("Scheduled player to stop in " + (long) video.duration + " seconds!");
            } catch (IOException | UnsupportedAudioFileException e) {
                // TODO Auto-generated catch block
                e.printStackTrace();
            }

If needed I'll give a comparison of the mp3 being played and the audio that actually is played.

@DV8FromTheWorld
Copy link
Member

Can you please upload an example file for me to test with?

@JFulweber
Copy link
Author

Yeah, here's a link to an mp3 that does it, as github won't let me upload it.
http://harambe.moe/memes/qwrfcKoAti.mp3

@DV8FromTheWorld
Copy link
Member

The file provided sounds incredibly distorted or like a baby animal crying when I play it not using JDA (i played it through Chrome).
When playing it using JDA-Player it sounds identical to how it sounds in chrome.

@JFulweber
Copy link
Author

Does it sound like this though?
http://harambe.moe/memes/RViCst14Dq.webm

@DV8FromTheWorld
Copy link
Member

Nope. Additionally: The problem isn't that it is a short clip. The issue is that it is Mono. If you convert it to Stereo it should work just fine.
As a note, this is only an issue with JDA's prebuilt Player system (e.g: Player, FilePlayer, and URLPlayer).
These 3 classes are being removed in JDA 3.x so I would highly advise not using them.

For an alternative solution for an Audio Player, I would highly recommend JDA-Player.

@JFulweber
Copy link
Author

Okay, I'll try that. Thank you.

@DV8FromTheWorld
Copy link
Member

Closing this as an answer has been provided. If you have further issue, feel free to reopen.

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

No branches or pull requests

2 participants