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

Glitch with big audio file #207

Closed
rap2hpoutre opened this issue Nov 21, 2017 · 7 comments

Comments

@rap2hpoutre
Copy link

commented Nov 21, 2017

I tried to add a background music to a micro game. But if I play a big audio file (3 min), it's full of glitches. It slows down and there is some noise. I tried with an ogg and a flac. Here is a relevant part of a small test I made to make sure it's not a performance problem due to some other part : I just created a test based on the "hello world" example of a fresh clone of ggez.

// ...
struct MainState {
    audio: audio::Source,
    frames: usize,
}

impl MainState {
    fn new(ctx: &mut Context) -> GameResult<MainState> {
        let audio = audio::Source::new(ctx, "/caniou_1_.flac")?;
        audio.play()?;

        let s = MainState {
            frames: 0,
            audio: audio,
        };
        Ok(s)
    }
}
// ...

I put the play in the new, not really elegant but anyway!

Thanks for ggez, I really like it!

@icefoxen

This comment has been minimized.

Copy link
Contributor

commented Nov 21, 2017

Gooood to know. I'll check it out. Is this in debug or release mode? Linux/windows/mac?

@TakWolf

This comment has been minimized.

Copy link

commented Nov 22, 2017

I found the same problems. It seams the reason is rodio. Some format decode not compat.

I use some transcoders can create the problems audio files.

Some times later I can provide some simples.

@TakWolf

This comment has been minimized.

Copy link

commented Nov 23, 2017

@icefoxen

http://static.takwolf.com/github/ggez/issues/207/audio_simple.mp3
http://static.takwolf.com/github/ggez/issues/207/audio_simple_with_error.ogg

audio_simple.mp3 is original audio file. ggez can not play it, cause:

thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: AudioError("Audio decoder error: UnrecognizedFormat")', src\libcore\result.rs:906:4
stack backtrace:
   0:     0x7ff71d477180 - std::sys_common::backtrace::_print
                               at C:\projects\rust\src\libstd\sys_common\backtrace.rs:91
   1:     0x7ff71d47fd57 - std::panicking::default_hook::{{closure}}
                               at C:\projects\rust\src\libstd\panicking.rs:380
   2:     0x7ff71d47fa2b - std::panicking::default_hook
                               at C:\projects\rust\src\libstd\panicking.rs:397
   3:     0x7ff71d4803c1 - std::panicking::rust_panic_with_hook
                               at C:\projects\rust\src\libstd\panicking.rs:577
   4:     0x7ff71d4801c0 - std::panicking::begin_panic<alloc::string::String>
                               at C:\projects\rust\src\libstd\panicking.rs:538
   5:     0x7ff71d480111 - std::panicking::begin_panic_fmt
                               at C:\projects\rust\src\libstd\panicking.rs:522
   6:     0x7ff71d480084 - std::panicking::rust_begin_panic
                               at C:\projects\rust\src\libstd\panicking.rs:498
   7:     0x7ff71d4873ee - core::panicking::panic_fmt
                               at C:\projects\rust\src\libcore\panicking.rs:71
   8:     0x7ff71cf1a6b9 - core::result::unwrap_failed<ggez::error::GameError>
                               at C:\projects\rust\src\libcore\macros.rs:23
   9:     0x7ff71cf199cf - core::result::Result<(), ggez::error::GameError>::unwrap<(),ggez::error::GameError>
                               at C:\projects\rust\src\libcore\result.rs:772
  10:     0x7ff71cf3254d - ggez_project_seed::app::App::new
                               at F:\GitOSC\ggez-project-seed\src\app.rs:19
  11:     0x7ff71cf2fe78 - ggez_project_seed::main
                               at F:\GitOSC\ggez-project-seed\src\main.rs:23
  12:     0x7ff71d480da1 - panic_unwind::__rust_maybe_catch_panic
                               at C:\projects\rust\src\libpanic_unwind\lib.rs:99
  13:     0x7ff71d480661 - std::rt::lang_start
                               at C:\projects\rust\src\libstd\rt.rs:51
  14:     0x7ff71cf2ffc6 - main
  15:     0x7ff71d4b73c8 - __scrt_common_main_seh
                               at f:\dd\vctools\crt\vcstartup\src\startup\exe_common.inl:253
  16:     0x7ffa180b13d1 - BaseThreadInitThunk
error: process didn't exit successfully: `target\debug\ggez-project-seed.exe` (exit code: 101)

audio_simple_with_error.ogg is conversion version by a format converter. ggez can play it, but full of error and noise.

ggez version is 0.3.3 or last master. On windows and macOS have the same problem.

Two of audio can normal play on Chrome or Audio Player.


I think the reason is rodio do not support some audio format.
Some non-standard format or conversion can not play well.
I do not know much about technology of audio, for reference only.

@TakWolf

This comment has been minimized.

Copy link

commented Nov 23, 2017

I use the format converter is : http://www.pcfreetime.com/?language=en
Do not go to install it, he is a very bad software, unless you want to do some tests!!!!!
Some other converters can generate good files.

I did not open this issue before, because I think responsibility should be non-standard formatting, not ggez and I can generate the correct audio format myself.

But problems's format audio files are in fact a lot of existence, In a large number of resources library.

@icefoxen

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2017

ggez doesn't have mp3 support, alas. There seems to be no pure Rust crate for mp3 decoding, and some of the better C libraries (MAD and LAME) have incompatible licenses (GPL/LGPL). See RustAudio/rodio#36 . It'd be great to fix that, but alas, I don't have time to write a decoder library.

If you can use linux (or osx?), sox is a good all-purpose sound converter tool.

@icefoxen

This comment has been minimized.

Copy link
Contributor

commented Nov 23, 2017

@TakWolf Confirmed, ggez decodes the given file incorrectly for me as well. Using release mode and debug mode both have the same results, so it's not my first thought, stuttering due to being too slow to keep the audio buffer full. Re-encoding it with sox makes a file that ggez plays fine, but gives no decoding errors in the process. ogginfo shows similar info for both files, also gives no errors.

@rap2hpoutre , can you link to the file that you were trying to play that has errors?

Repository that has a program that reproduces this, with included audio files: https://github.com/ggez/ggez-soundtest

@icefoxen

This comment has been minimized.

Copy link
Contributor

commented Oct 7, 2018

Fixed upstream in RustAudio/lewton@1073e58

Huzzah!

@icefoxen icefoxen closed this Oct 7, 2018

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
3 participants
You can’t perform that action at this time.