wav.rs

crates/veilvoice-meta/src/wav.rs

veilvoice-meta · 425 lines · read the source here · or on GitHub

Chunk-level RIFF/WAVE metadata removal.

Why WAV gets its own path

lofty handles tags in every other container, but it cannot remove an ID3v2 block from a WAV file: the attempt fails with an encoding error and the tag stays put. Silently leaving metadata in place is exactly the failure this crate exists to prevent, and WAV is the format VeilVoice writes itself, so it gets a direct implementation rather than a caveat.

Whitelist, not blacklist

A RIFF file is a flat list of chunks, and metadata hides in a lot of them: LIST/INFO (artist, software, comments), id3 and ID3 , bext (the broadcast extension, carrying originator, date and even a coding history), iXML, _PMX (XMP), axml, cart. Enumerating those would leave every chunk nobody thought of, and new ones keep being invented.

So this keeps only the chunks needed to decode the audio and drops everything else. Anything unrecognised is discarded by default, which is the right bias for a privacy tool: the worst case is a lost non-essential chunk, not a leaked identity.

In plain words

Strips the hidden information out of a WAV file specifically.

WAV is built as a series of labelled sections, and the ones carrying the sound sit alongside ones carrying text somebody or some program wrote. Those are removed and the sound is copied through exactly, byte for byte.

It gets its own path because WAV is what VeilVoice writes, so this is the one that runs on nearly every file it produces, and doing it directly means not handing VeilVoice's own output to a general-purpose parser.

WHAT THIS FILE CONTAINS

425 lines defining 4 functions (2 public), 0 types and 2 constants. Everything below is read out of the source, so it cannot disagree with the code.

What happens when it runs. These are the ways in: public, and nothing else in this file calls them, so they are what an outside caller reaches first.

  • clean_wav_bytes line 59 · Rewrite a WAV, keeping only the chunks needed to decode it.
    reaches info_chunk, is_wav, show

WHAT CALLS WHAT

is_wav line 54 clean_wav_bytes line 59 info_chunk line 143 show line 162 entry: a way in: public, and nothing in this file calls it api: public, and also used inside this file helper: private to this file dashed: a call that goes back up, or across a wrapped rank The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The functions this file defines, and the calls between them. An edge means the callee's name appears, called, inside the caller's body. This is a syntactic reading, not a type-resolved one.

The same graph as Mermaid source
%%{init: {"theme":"base","themeVariables":{"background":"#1a1b26","primaryColor":"#1f2335","primaryTextColor":"#c0caf5","primaryBorderColor":"#7aa2f7","secondaryColor":"#16161e","tertiaryColor":"#16161e","lineColor":"#737aa2","textColor":"#c0caf5","mainBkg":"#1f2335","nodeBorder":"#7aa2f7","clusterBkg":"#16161e","clusterBorder":"#2f3549","fontFamily":"ui-monospace, SFMono-Regular, Consolas, monospace","fontSize":"14px"}}}%%
flowchart TD
    n_is_wav["is_wav<br/>line 54"]
    n_clean_wav_bytes(["clean_wav_bytes<br/>line 59"])
    n_info_chunk["info_chunk<br/>line 143"]
    n_show["show<br/>line 162"]
    n_clean_wav_bytes --> n_info_chunk
    n_clean_wav_bytes --> n_is_wav
    n_clean_wav_bytes --> n_show
    click n_is_wav href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/wav.rs#L54" "open the source"
    click n_clean_wav_bytes href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/wav.rs#L59" "open the source"
    click n_info_chunk href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/wav.rs#L143" "open the source"
    click n_show href "https://github.com/tilas01/veilvoice/blob/main/crates/veilvoice-meta/src/wav.rs#L162" "open the source"
    classDef entry fill:#1f2335,stroke:#7aa2f7,color:#c0caf5
    class n_clean_wav_bytes entry
    classDef api fill:#1f2335,stroke:#7dcfff,color:#c0caf5
    class n_is_wav api
    classDef helper fill:#1f2335,stroke:#bb9af7,color:#c0caf5
    class n_info_chunk,n_show helper

This site loads no third-party script, so it cannot run Mermaid; the diagram above is the same nodes and edges drawn by the generator instead. GitHub renders the source below directly.

ITEMS

ItemLineDocumentation
KEEP const40Chunks required to interpret the audio.
REALISTIC_INFO const47Tags written in Policy::Realistic mode, as LIST/INFO sub-chunks.
is_wav pub fn54Whether bytes looks like a RIFF/WAVE file.
clean_wav_bytes pub fn59Rewrite a WAV, keeping only the chunks needed to decode it.
info_chunk fn143Build a bland LIST/INFO chunk.
show fn162