chaosprint / asak

A cross-platform audio recording/playback CLI tool with TUI, written in Rust.
MIT License
145 stars 3 forks source link

play does not play with correct speed #4

Open madskjeldgaard opened 2 months ago

madskjeldgaard commented 2 months ago

Hi !

Really cool tool!!

Just tried it and record worked flawlessly for me, but play seems to play back the file at the wrong speed. The same file played with sox plays normally through once at normal speed but then in asak it is played twice at double speed it seems. Probably not adjusting for sample rate.

chaosprint commented 2 months ago

thanks! it should be fixed now. try to reinstall it and run again.

madskjeldgaard commented 2 months ago

Yes that fixes it!

Now there's just a panic at the end of the file. It doesn't affect playback but maybe important:

██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████thread '<unnamed>' panicked at /Users/mads/.cargo/registry/src/index.crates.io-6f17d22bba15001f/asak-0.1.3/src/playback.rs:169:60:
                                                                                                                               index out of bounds: the len is 108543 but the index is 108543
                                                        stack backtrace:
                                                                           0: _rust_begin_unwind
                                                                                                   1: core::panicking::panic_fmt
                                                                                                                                   2: core::panicking::panic_bounds_check
                                       3: coreaudio::audio_unit::render_callback::<impl coreaudio::audio_unit::AudioUnit>::set_render_callback::{{closure}}
                         4: _DefaultOutputAUFactory
                                                      5: _AUNotQuiteSoSimpleTimeFactory
                                                                                          6: _AUGenericOutputFactory
                                                                                                                       7: <unknown>
⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⠔⠢⡀⡠⡀⢀⣠   ⡠⢄⣀⡀⡠⢄⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀   8: <unknown>                                 ⠈ ⠑⠁ ⢇⡔⠊   ⠈                                                                        ⠈⠁
                9: <unknown>                       ⠈
                              10: __pthread_joiner_wake
                                                       note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
         fatal runtime error: Rust panics must be rethrown
                                                          zsh: abort      asak play 20240413-165115.wav
                                                                                                       %
chaosprint commented 2 months ago

Yes that fixes it!

Now there's just a panic at the end of the file. It doesn't affect playback but maybe important:

██████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████████thread '<unnamed>' panicked at /Users/mads/.cargo/registry/src/index.crates.io-6f17d22bba15001f/asak-0.1.3/src/playback.rs:169:60:
                                                                                                                               index out of bounds: the len is 108543 but the index is 108543
                                                        stack backtrace:
                                                                           0: _rust_begin_unwind
                                                                                                   1: core::panicking::panic_fmt
                                                                                                                                   2: core::panicking::panic_bounds_check
                                       3: coreaudio::audio_unit::render_callback::<impl coreaudio::audio_unit::AudioUnit>::set_render_callback::{{closure}}
                         4: _DefaultOutputAUFactory
                                                      5: _AUNotQuiteSoSimpleTimeFactory
                                                                                          6: _AUGenericOutputFactory
                                                                                                                       7: <unknown>
⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⠔⠢⡀⡠⡀⢀⣠   ⡠⢄⣀⡀⡠⢄⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⣀⡀   8: <unknown>                                 ⠈ ⠑⠁ ⢇⡔⠊   ⠈                                                                        ⠈⠁
                9: <unknown>                       ⠈
                              10: __pthread_joiner_wake
                                                       note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
         fatal runtime error: Rust panics must be rethrown
                                                          zsh: abort      asak play 20240413-165115.wav
                                                                                                       %

just added a boundary check. does it work for you now?

madskjeldgaard commented 2 months ago

No more panics here (but now the waveform doesn't move in playback mode for some reason). Sorry!

chaosprint commented 2 months ago

No more panics here (but now the waveform doesn't move in playback mode for some reason). Sorry!

it should be fine now; I forgot to change the pointer from the origin file length to the resampled length 😅