Skip to content

Add freeplay recording with in-app preview and MIDI export#395

Merged
PolyMeilex merged 16 commits into
PolyMeilex:masterfrom
rumycoding:rumy/recorder
Jul 7, 2026
Merged

Add freeplay recording with in-app preview and MIDI export#395
PolyMeilex merged 16 commits into
PolyMeilex:masterfrom
rumycoding:rumy/recorder

Conversation

@rumycoding

@rumycoding rumycoding commented Jul 5, 2026

Copy link
Copy Markdown
Contributor

Intro

Hi! I’ve been using Neothesia and really enjoy it. To support personal practice, I added a freeplay recording feature that captures live MIDI input, converts the take into a playable song, and allows saving it locally as a MIDI file.

Summary

This PR introduces an in-app recording flow: when recording stops, the app builds a preview of the take directly—no external reload required. It also adds a preview UI with record/save/play/pause, seeking, progress tracking, measure markers, and waterfall/note rendering, all integrated with existing scene components. Supporting changes include in-memory SMF construction and safeguards around playback math to handle zero-length or very short recordings gracefully.

File changed

  • [neothesia/src/scene/freeplay/mod.rs]: adds freeplay recording, in-app preview playback, progress/seek UI, and MIDI export.
  • [midi-file/src/file.rs]: adds in-memory MIDI loading so recorded takes can be previewed without writing a temporary file.
  • [neothesia/src/scene/playing_scene/midi_player.rs]: supports configurable lead-in timing and safer seek/progress handling for preview playback.
  • [midi-file/src/playback.rs]: guards playback progress calculations when a recording has zero length.
  • [neothesia/src/scene/playing_scene/keyboard.rs]: lets freeplay preview apply generated song configuration to the keyboard UI.
  • [neothesia/src/scene/playing_scene/mod.rs]: exposes the MIDI player module for reuse in freeplay preview.

@PolyMeilex PolyMeilex left a comment

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

btw code forrmating is quite random, folow the official Rust formating rules.

Comment thread neothesia/src/scene/playing_scene/midi_player.rs Outdated
Comment thread midi-file/src/playback.rs Outdated
Comment thread neothesia/src/scene/playing_scene/midi_player.rs Outdated
Comment thread neothesia/src/scene/freeplay/mod.rs Outdated
Comment thread neothesia/src/scene/freeplay/mod.rs Outdated
@PolyMeilex

PolyMeilex commented Jul 5, 2026

Copy link
Copy Markdown
Owner

Looks like a good idea btw!

Consolidate freeplay preview state and UI handling so the recorder playback path is easier to follow and maintain.

This also carries the live MIDI input fix for devices that encode note release as NoteOn with velocity 0, keeping keyboard state aligned with recorder semantics.
@rumycoding

Copy link
Copy Markdown
Contributor Author

hi @PolyMeilex, Thanks for the detailed review. I’ve done my best to revise the structure and style so the change is easier to follow and reads more cleanly. While working through the feedback, I also found and fixed a potential bug in keyboard.rs: some MIDI devices encode note release as NoteOn with velocity 0, so that case now gets handled explicitly.

If you see anything else that should be adjusted, please leave a comment!😄

@PolyMeilex

Copy link
Copy Markdown
Owner

I also found and fixed a potential bug in keyboard.rs: some MIDI devices encode note release as NoteOn with velocity 0, so that case now gets handled explicitly.

I already normalize the midi input long before it reaches the app code to avoid the need for doing if vel == 0 checks in multiple places, it's done right here https://github.com/PolyMeilex/Neothesia/blob/master/neothesia%2Fsrc%2Finput_manager%2Fmod.rs#L37

I will take a look at the code tomorrow, but at a glance it looks like what I had in mind so should be good.

@rumycoding

Copy link
Copy Markdown
Contributor Author

ok, have reverted that part. Thanks~

Prevent controller-only recordings, such as sustain pedal input/only note off,
from being treated as previewable or saveable takes.
@rumycoding

rumycoding commented Jul 7, 2026

Copy link
Copy Markdown
Contributor Author

Also, added test coverage for edge cases where the recording contains only pedal or note-off MIDI events, since those should not generate a preview.

@PolyMeilex PolyMeilex enabled auto-merge (squash) July 7, 2026 18:52
@PolyMeilex PolyMeilex merged commit 52b3c39 into PolyMeilex:master Jul 7, 2026
6 checks passed
@PolyMeilex

Copy link
Copy Markdown
Owner

Thanks!

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

Successfully merging this pull request may close these issues.

2 participants