Repository navigation
Closed
Description
Reproducer
I tried this code:
fn get_metadata(path: &path::PathBuf) -> (Box<[Tag]>, u32) {
let tagged_file = Probe::open(path)
.expect("ERROR: file removed before processing")
.read()
.expect("ERROR: file in use");
let tags = tagged_file.tags().iter().cloned().collect();
let sample_rate = tagged_file
.properties()
.sample_rate()
.expect("ERROR: file has no sample rate");
(tags, sample_rate)
}
fn process_metadata(mut tags: Box<[Tag]>, peak: f32) -> Box<[Tag]> {
for tag in &mut tags {
tag.remove_empty();
// File peak will change due to processing
tag.remove_key(ItemKey::ReplayGainAlbumPeak);
// Paste the new peak value
tag.insert_text(ItemKey::ReplayGainTrackPeak, peak.to_string());
}
let mut id3v2_tags = tags.clone();
id3v2_tags
.iter_mut()
.for_each(|tag| tag.re_map(TagType::Id3v2));
let mut riff_tags = tags.clone();
riff_tags
.iter_mut()
.for_each(|tag| tag.re_map(TagType::RiffInfo));
id3v2_tags.into_iter().chain(riff_tags).collect()
}
fn write_tags(file_path: &Path, tags: Box<[Tag]>) {
for tag in tags {
_ = tag.save_to_path(file_path, WriteOptions::default());
}
}Summary
I have a DSP project where I'm exporting files as a .wav with the tags copied over. Since lofty only supports ID3v2 and RIFF tags for .wav, I use these functions to collect all of the tags for a particular file and convert them to both ID3v2 and RIFF, then write all of them since the conversion process is likely lossy. Most of my files are FLAC, so the Vorbis Comments will always cause a loss, even for LYRICS and UNSYNCEDLYRICS/UNSYNCED_LYRICS/'UNSYNCED LYRICS'.
For lofty 0.22.4, the ReplayGain tags are copied over. However, for lofty 0.23.1 and 0.23.2, these tags are lost; other main tags like the title and album name are retained.
Expected behavior
No response
Assets
No response
Activity
Serial-ATA commentedon Feb 27, 2026
Good catch! Looks like I missed a handful of
ItemKeys when I rewrote the generic conversion