Skip to content

Conversation

@macsplit
Copy link
Contributor

Overview

SampleEditor is a graphical audio sample editor that provides essential editing capabilities for WAV and FLAC audio files.

Features

  • Format Support: Load and save both WAV and FLAC audio files
  • Playback: Real-time audio playback with cursor/selection support
  • Editing: Copy, cut, and paste operations with format compatibility checking
  • Visualization: Waveform display with zoom controls, colors adapt to active theme
  • Architecture: Reference-based design for memory-efficient handling of large files

Implementation Details

The application uses a reference-based block architecture:

  • SampleFileBlock - References portions of audio files on disk
  • SampleNullBlock - Represents silence
  • SampleBlockContainer - Manages sequences of blocks and handles streaming

Copy/paste operations work by storing file paths and sample ranges in the clipboard as JSON.

When pasting, new file block references are created pointing to the original source files rather than duplicating data in memory. This allows editing large audio files efficiently.

Files Added

  • Userland/Applications/SampleEditor/ - Main application source (~2800 LOC, 11 source files)
  • Base/res/apps/SampleEditor.af - Application metadata
  • Base/res/icons/{16x16,32x32}/app-sample-editor.png - Application icons
  • Base/usr/share/man/man1/Applications/SampleEditor.md - User documentation

Testing Performed

  • Open WAV files
  • Open FLAC files
  • Save as WAV
  • Save as FLAC
  • Copy/cut/paste operations
  • Format mismatch error handling
  • Playback controls
  • Zoom controls
  • Keyboard shortcuts

Screenshots

SampleEditor Screenshot SampleEditor Screenshot with Dark Theme

SampleEditor is a graphical audio sample editor supporting WAV and
FLAC file formats. It provides essential audio editing functionality
including playback, waveform visualization, and clipboard operations.

Key features:
- WAV and FLAC format support for loading and saving
- Real-time audio playback with configurable start positions
- Copy/cut/paste operations with format validation
- Reference-based architecture for memory-efficient editing
- Zoom controls for waveform inspection
- Keyboard shortcuts for all common operations

The application uses a block-based design where audio content is
represented as file references (SampleFileBlock) or silence
(SampleNullBlock). Copy/paste operations store file paths and ranges
in the clipboard, creating new references when pasted rather than
duplicating audio data. This allows efficient editing of large files
without loading everything into RAM.
@github-actions github-actions bot added the 👀 pr-needs-review PR needs review from a maintainer or community member label Nov 15, 2025
Copy link
Member

@LucasChollet LucasChollet left a comment

Choose a reason for hiding this comment

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

Nice work! I will definitely want to give this a look, but that will be in a long time (more than a week).
In the meantime, here are some hints that I suggest you to consider (I only had a glance so don't consider them as final, and you can also wait until I come back):

  • Maybe remove the editing capacities (especially the clipboard part) from this PR and add them in another one. It seems to be a big chunk of code, so putting it apart will probably ease the review process.
  • I'm not sure why you need SampleNullBlock can't you have that backed in SampleBlock?
  • It seems like only SampleSourceFile inherits from SampleFile maybe there is no need to have an abstract class.


#pragma once

typedef struct {
Copy link
Member

Choose a reason for hiding this comment

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

No typedef please, this is not C code.

#include <AK/Vector.h>
#include <LibAudio/Sample.h>

#include <cassert>
Copy link
Member

Choose a reason for hiding this comment

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

Let's use our asserts: VERIFY and friends.

@macsplit
Copy link
Contributor Author

Nice work! I will definitely want to give this a look, but that will be in a long time (more than a week). In the meantime, here are some hints that I suggest you to consider (I only had a glance so don't consider them as final, and you can also wait until I come back):

* Maybe remove the editing capacities (especially the clipboard part) from this PR and add them in another one. It seems to be a big chunk of code, so putting it apart will probably ease the review process.

* I'm not sure why you need `SampleNullBlock` can't you have that backed in `SampleBlock`?

* It seems like only `SampleSourceFile` inherits from `SampleFile` maybe there is no need to have an abstract class.

Thanks, that would be great, as mentioned on Discord this has been very long term for me, so expecting it to be a gradual process with likely revisions needed on my part.

Taking those points fully on board, but just by way of a little explanation:

  • Yes I did speak to some of the folk in the multimedia Discord channel about a year ago, when it was minus the editing features, at that point I was advised not to submit until it had minimal functionality as an editor, the danger (this being quite plausible) that it would be accepted in that state and abandoned.

  • Those classes can best be explained as part of a larger design with extra classes that I removed for this submission, since they were not implemented yet. For example, there might be in-memory blocks rather than file-reference-blocks, and there might have been temporary files versus actual sample files. Some of this was about anticipating features (editing and effects say) where the abstraction and different sub-classes could be handy.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

👀 pr-needs-review PR needs review from a maintainer or community member

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants