# WAV ⇄ FLAC Converter

Overview: A bidirectional converter tool for WAV and FLAC audio files with support for metadata (tags) and cover art preservation.

## Key Features

- WAV → FLAC conversion
- FLAC → WAV conversion
- Metadata preservation (title, artist, album, date, genre, track number, comment, album artist, composer)
- Cover art preservation
- Original sampling rate preserved
- Automatic bit depth detection (16bit/24bit/32bit)
- Drag & drop support (files and folders)
- Batch processing of all WAV/FLAC files in a folder (excluding subfolders)

## Distribution Files

- `wav_flac_converter.exe`
- `wav_flac_converter_readme.html`
- `wav_flac_converter_readme_en.html`

## System Requirements

- OS: Windows 10 / 11 (64-bit)
- FFmpeg: Required for 32-bit FLAC conversion (not needed for 16bit/24bit FLAC)
  - Download from FFmpeg official site
  - Must be registered in PATH environment variable

Note: FFmpeg is NOT required for 16bit/24bit FLAC conversion. It's only needed when converting 32bit FLAC files.

## How to Use

1. Drag and drop WAV/FLAC files or folders containing them onto `wav_flac_converter.exe` (or its shortcut)
2. Converted files will be created in the same folder as the original files
3. Multiple files and folders can be dropped at once
4. When dropping a folder, only WAV/FLAC files in that folder will be processed (subfolders excluded)

## Conversion Details

### WAV → FLAC Conversion

- Compression level: 0.625 (FLAC standard compression ratio)
- Bit depth: Maintains original WAV bit depth (16bit/24bit/32bit)
- Metadata: Reads from RIFF INFO chunks and ID3v2 tags, converts to FLAC tags
- Cover art: Extracts from embedded ID3v2 images in WAV or image files in the same folder

Cover art search order:

1. Embedded ID3v2 image in WAV file
2. `[filename]_cover.jpg` / `[filename]_cover.png`
3. `cover.jpg` / `cover.png`
4. `folder.jpg` / `folder.png`

### FLAC → WAV Conversion

- Bit depth: Maintains original FLAC bit depth (16bit/24bit/32bit float)
- Metadata: Reads FLAC tags and writes ID3v2.3 tags only (RIFF INFO chunks are NOT written)
- Cover art: Embeds FLAC cover art into WAV ID3v2 tags
- 32bit FLAC: Automatically uses FFmpeg when soundfile library cannot handle the format

## Supported Metadata

Important: This tool writes ID3v2.3 tags only to WAV files. RIFF INFO chunks are not used.

Metadata Field | FLAC Tag | WAV (ID3v2.3)
--- | --- | ---
Title | title | TIT2
Artist | artist | TPE1
Album | album | TALB
Date | date | TDRC
Genre | genre | TCON
Track Number | tracknumber | TRCK
Comment | comment | COMM
Album Artist | albumartist | TPE2
Composer | composer | TCOM

## Output Filename

- Default: `original_filename.new_extension`
- If file exists: `original_filename_converted.new_extension`

Examples:

- `song.wav` → `song.flac`
- `music.flac` → `music.wav`
- `track.wav` (when `track.flac` exists) → `track_converted.flac`

## Error Handling

- If a file is not found, an error message will be displayed for that file
- Unsupported file formats will be skipped
- If an error occurs during conversion, the error message will be shown and processing will continue with the next file

## Technical Specifications

### Conversion Method

- Completely lossless conversion: PCM data is directly transferred with no quality degradation
- Bit depth preservation: 16bit/24bit/32bit float are fully maintained
- Sampling rate preservation: No resampling (44.1kHz, 48kHz, 96kHz, etc. are preserved as-is)
- Libraries used:
  - soundfile: Audio data reading and writing
  - mutagen: Metadata reading and writing
  - FFmpeg: Fallback for 32bit FLAC conversion

### WAV File Metadata Structure

- ID3v2.3 tags: Format used by this tool. Supports cover art embedding
- RIFF INFO chunks: Not used by this tool (read-only support)

### FLAC File Metadata Structure

- Vorbis Comments: FLAC standard metadata format
- Picture block: Cover art image embedding

## Limitations

- Supported formats: WAV and FLAC only
- When dropping a folder, files in subfolders will not be processed
- Metadata encoding is UTF-8
- Cover art image formats supported: JPEG and PNG
- FFmpeg is required for 32bit FLAC conversion (not needed for 16bit/24bit)

## License

This tool is free to use and modify.