# Description
A library for identifying MQA (Master Quality Authenticated) audio files, with an optional companion binary.
Similar to [mqaid](https://github.com/redsudo/mqaid) (python) and [MQA_identifier](https://github.com/purpl3F0x/MQA_identifier) (C++).
Detection works by searching for the MQA magic word in the three least significant bit planes of the
XOR of the two channels, over the first three seconds of audio. A match is strong evidence, not
proof - the magic word may also appear in a non-MQA file by chance, though this is very unlikely.
Files that cannot carry MQA at all, i.e. anything that is not stereo with at least 16 bits per
sample, are reported as not MQA without being decoded.
## Installation
```bash
cargo install mqa-identify
```
## Binary Usage
```bash
mqa-identify path/to/file.flac path/to/directory
```
Directories are scanned recursively for `.flac` files. Paths that could not be checked are listed on
stderr and cause a non-zero exit status.
## Library Usage
The binary is a default feature, so disable it when depending on the library to avoid pulling in unnecessary dependencies:
```toml
# Cargo.toml
[dependencies]
mqa-identify = { version = "0.3", default-features = false }
```
```rust
let flac_file_path = PathBuf::from("path/to/flac/file");
match mqa_identify::identify_mqa(flac_file_path) {
Ok(true) => println!("File is likely mqa encoded"),
Ok(false) => println!("File is not mqa encoded"),
Err(error) => println!("Error decoding file: {error}"),
}
```
`identify_mqa_reader` accepts any `std::io::Read` if you are not working with a file on disk.
## License
MIT — see [LICENSE](LICENSE).