Repository navigation
Conversation
5 tasks
Owner
|
Thanks for this. The DSP work is careful: bypassed at 1x, the bounds and the Q14 math hold up, and the tests cover a lot. I haven't merged it yet for three reasons:
A rebase onto current |
…peed Adds the HalAudioSpeed contract with store-only implementations, and a fixed-point dsp module shared by the device engine, the simulator and the host tests: a WSOLA time-stretch for sources up to 48 kHz and a 16-tap polyphase resampler for everything else. Nothing uses it yet. Co-Authored-By: Claude <noreply@anthropic.com>
…time The engine pushes converted frames through the speed stage at the source rate, before the whole-number upsampler, and runs the core 0 equalizer on the stage's output so its cost follows the output rate. Each segment keeps its speed, so the position stays in track time. A finished track drains the stage before the next one opens, so its last words are heard and the next segment starts after them. At normal speed nothing changes. Co-Authored-By: Claude <noreply@anthropic.com>
The speed stage lives in High RAM beside the decode buffers, so it costs nothing against the loaded-image limit. A new speed restarts the stream from its current position at the next service, before a queued track is replaced, or on resume, so a paused book never resumes at the old speed. Faster than normal speed keeps the 200 MHz clock and gives core 1 its full speed. Co-Authored-By: Claude <noreply@anthropic.com>
Two option slots hold the book and podcast speed and pitch, with 0 as normal speed and Keep pitch, so settings from 0.11 load unchanged. The player sends each track's speed right before it plays, queues a next track without a gap only at the same speed, and starts a deferred one when the current track ends. A speed change never takes back a next track the audio path may already have opened. Co-Authored-By: Claude <noreply@anthropic.com>
…g shows it Book & podcast speed and Book & podcast pitch join the Sound group, and a change reaches the player at once. Now Playing puts the speed first on the modes line, such as 1.5x, while a book or episode plays faster or slower than normal. The language packs carry the new texts in English. Co-Authored-By: Claude <noreply@anthropic.com>
The simulator runs the same speed stage as the player, with its SDL stream left at the source rate, and lets a track's tail play out before switching to the next. Headless runs move the virtual position by the speed, so scripted runs stay deterministic. Co-Authored-By: Claude <noreply@anthropic.com>
The user guide explains the two Sound rows and what the speed does to times, bookmarks and the queue. The architecture notes record the HAL contract, the player's per-track rule, the device stage, its memory and clocks, and the filter and WSOLA parameters, which the code can't carry as comments. Known issues lists what still needs a player to confirm. Co-Authored-By: Claude <noreply@anthropic.com>
…tes never stretch A seek or a resume after a long pause re-queued the next track the engine had already opened, even when a newer request had replaced or cancelled it, so the player could be handed a track it no longer expected. Keep pitch also looped forever on a source rate below 25 Hz; it now needs at least 4 kHz and resamples below that. Two engine tests now check what they claim. Co-Authored-By: Claude <noreply@anthropic.com>
…ails The rescan takes the audio path away without telling the player, so a failed scan left it waiting on a stopped track, and with a deferred next track it would have started that one mid-episode. The player is now released first, as for a USB session, so it stays paused where it was. A test also pins that a speed change follows a hand-over the audio path already made before queuing again. Co-Authored-By: Claude <noreply@anthropic.com>
…, and the roadmap Corrects the review's findings: the equalizer's place depends on the codec, the 47 dB figure needs its band, the end-of-track silence is longer at slow speeds, and the speed sources build at -Os. The roadmap marks playback speed as working in the simulator. Co-Authored-By: Claude <noreply@anthropic.com>
…ng is gone The device image no longer fits once 0.12's changes landed, and Follows speed with its resampler cost about 1.5 KB of the code window. Speed now always keeps the voice's pitch, which frees settings slot 23 again, and a book above 48 kHz plays at 1x. A settings file that chose Follows speed still loads. Co-Authored-By: Claude <noreply@anthropic.com>
…s less room Speed added a second path through convert, equalize, ramp and write, so the link kept two copies of each. Both paths now share one copy_chunk, the track ends in one place, and the board keeps its speed in one setting, which frees about 450 bytes of the code window. The ring is byte for byte what it was, and the engine reports its state through an accessor instead of copying its whole status. Co-Authored-By: Claude <noreply@anthropic.com>
The speed labels live once in settings and the Now Playing badge reads them, the stored order maps to quarters by swapping its first two entries instead of a table, the player sends its speed from one helper, and every Settings save hands the stored speed to the player instead of each speed row doing it. Tests now pin that a deferred song which starts is saved, and that choosing a speed reaches the settings file. Co-Authored-By: Claude <noreply@anthropic.com>
The fifo appends and drops in one path each, the stage keeps its speed and resets its fifo once, the crossfade is written once for both channels, the search buffers share memory, and the first sequence runs the normal search, which finds offset 0. Counters sit ahead of the sample arrays so Thumb reaches them with short offsets, and stretch_configure stays out of the -O2 engine. The output is byte for byte the same on 59,400 randomized cases (rates, speeds, signals and push/pull patterns), and the device image fits again. Co-Authored-By: Claude <noreply@anthropic.com>
…t 1.5x Some audiobooks come at 64 kHz or more, and they played at 1x. The time stretch now runs up to 96 kHz in the same memory, its lengths keeping their 48 kHz frame counts. A track never decodes more than 144,000 frames a second, three quarters of what a 192 kHz FLAC needs at 1x, so 88.2 and 96 kHz books go up to 1.5x and 176.4 and 192 kHz ones stay at 1x. The equalizer is off once rate times speed passes 96 kHz, the same limit as at 1x, on core 1, in the engine and in the simulator; core 1 gets the curve again when a kept stream restarts, so a speed change switches it. Now Playing shows the speed a book actually plays at. Co-Authored-By: Claude <noreply@anthropic.com>
… after it The player can withdraw or replace its next track at any moment (a speed change, Play next, Add to Up Next, shuffle, repeat), but the device opens the next track up to one ring before the current one ends (about 0.3 s at 44.1 kHz). It dropped an opened track only when a speed change restarted the stream, and even then it restarted before taking the new request, so the restart's prefill could open the old next track again. In that last fraction of a second this went wrong in two ways: - a speed change could play the old next track (a song at 2x, or the next chapter twice) and save the song's position as the book's resume point; - withdrawing a next track without a speed change let it play under a token the player no longer follows, and the player then stayed in Playing, silent, with auto-off held off until Next or Previous. hal_audio_queue_next now takes the new request first, and treats replacing an opened next track as a restart from the current position, as a speed change already was. follow_queue checks for itself that a next track still waits, so the re-queue after a restart can't arm a track the restart's prefill already opened. The code window gains 20 bytes. Co-Authored-By: Claude <noreply@anthropic.com>
The stage shrank to 28,800 bytes when the pitch setting went. Test builds of playback speed kept the pitch choice in slot 23, so a settings file one of them saved last can still hold a 1 there. Co-Authored-By: Claude <noreply@anthropic.com>
hva314
force-pushed
the
feat/playback-speed
branch
from
November 12, 2026 06:58
48de298 to
beec103
Compare
Contributor
Author
|
Thanks! Rebased onto 0.12.0. The changes are separate commits on top, so they're easy to follow.
Also fixed a race in |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Audiobooks and podcasts can now play at 0.75x, 1x, 1.25x, 1.5x, 1.75x or 2x, always keeping the voice's pitch. Music always plays at 1x.
What the listener sees
There is no new key: on Now Playing, ≡ already opens Up Next (tap) and the Equalizer (hold).
How it works
docs/architecture.md→ "Playback speed" has the full description, including the load limits, WSOLA parameters, where the equalizer runs, memory, and the queue rules.src/dspspeed stage (speed,speed_fifo,stretch), shared by the device, the simulator and the host tests. It uses integers only, no heap and no.data, and the caller owns its 28.8 KBSpeedStage.speed_played_quartersis the only place that decides how fast a track plays. It never lets a track decode more than 144,000 frames a second.hal_audio_set_speed(HalAudioSpeed). Speed is stored in quarters (3–8, 4 = 1x).position_msstays track time at every speed.platform/device/logic/audio_engine.c):copy_chunk, so each helper appears once in the code window..high_ram, so it adds nothing to the loaded image.hal_audio_queue_nexttakes the new request first, then restarts if needed, so a track it replaces can't open again during the restart.hal_audio_play.OPTION_SPOKEN_SPEED, byte 42), default 0 = 1x, so there is no version bump. Slot 23 stays free.tools/lang_pack.py; there are no translations yet, so other languages show the English text. The largest pack,uk.bin, is 12,027 of 12,288 B.Size
main(0.12.0)devicepresetreleasepreset.high_ramusedMeasured with arm-none-eabi-gcc 14.2.1, which leaves about 460 B less room than the numbers in the review (2,308 B free in
deviceonmain). On that toolchain expect roughly 580 B free indeviceand 2,460 B inrelease.The speed sources build with
-Osin cross builds to fit the code window.Changes since the review
feat: books and podcasts always keep their pitch, and the pitch setting is gone. Follows speed and its resampler cost about 1.5 KB. This frees slot 23 again.perf: the audio engine's speed path is one pipeline again (−456 B). Checked against the old engine on 400 randomized runs of 4,000 operations each: the ring and every status field are byte-identical.perf: the speed settings and the player's speed helpers take less room (−224 B), with new tests that a deferred song which starts is saved and that choosing a speed reaches the settings file.perf: the time stretch takes less room with the same output (−796 B). The output is byte-identical to the previous version on 59,400 randomized cases, also under ASan and UBSan.feat: books up to 96 kHz play at speed, with 88.2 and 96 kHz capped at 1.5x (+196 B). This is the decode limit and the equalizer rule above.fix: a track queued near the end of another one plays the right track after it (−20 B). Found in a review of this branch. In the last ~0.3 s of a track:main(repeat All to Off during the last track), and this fixes that too.docs: the stage is 28,800 B, and slot 23 may still hold a pitch choice from earlier builds of this PR.Tests
tests/dsp/test_speed.candtests/sim/test_sim_speed.c.test_audio_engine,test_player,test_spoken_word,test_settings,test_stores,test_settings_screens,test_appandtest_now_playing_screen.ctest --preset dev: 178 of 180 pass, built with clang 21, clang-format 21, arm-none-eabi-gcc 14.2.1 and Python 3.12. The two failures also fail onmainhere and come from tool versions:format: clang-format 21 against the project's version, in files this PR doesn't change. The changed lines are clean.sort_fold_up_to_date: Python 3.12'sunicodedata.device_build,device_image_passes_the_updater_check,target_audit,no_comments,language_packs_up_to_dateandtools_unit_testspass.Not yet tested on a player
ROADMAP.mdmarks this assim, anddocs/known-issues.mdlists the limits. To check on hardware:Landcat 2x for MP3, AAC (m4b), Opus and FLAC books, with the equalizer on and offLandcTry it
The release image is
build/release/HIFIEC90.IMG.The version number and release notes are unchanged, left for a release commit.