Ah, I was forgetting the existence of sf_command. Use that to identify file type where possible
This commit is contained in:
@@ -579,21 +579,32 @@ int main(int argc, char **argv)
|
|||||||
sfinfoOut.sections = sfinfo.sections;
|
sfinfoOut.sections = sfinfo.sections;
|
||||||
sfinfoOut.seekable = sfinfo.seekable;
|
sfinfoOut.seekable = sfinfo.seekable;
|
||||||
|
|
||||||
if (extIn == extOut) {
|
sfinfoOut.format = sfinfo.format;
|
||||||
sfinfoOut.format = sfinfo.format;
|
|
||||||
} else {
|
if (extIn != extOut) {
|
||||||
std::string ex = extOut;
|
std::string ex = extOut;
|
||||||
for (size_t i = 0; i < ex.size(); ++i) {
|
for (size_t i = 0; i < ex.size(); ++i) {
|
||||||
ex[i] = tolower(ex[i]);
|
ex[i] = tolower(ex[i]);
|
||||||
}
|
}
|
||||||
if (ex == "wav") {
|
int types = 0;
|
||||||
sfinfoOut.format = SF_FORMAT_WAV | SF_FORMAT_PCM_24;
|
(void)sf_command(0, SFC_GET_FORMAT_MAJOR_COUNT, &types, sizeof(int));
|
||||||
} else if (ex == "w64") {
|
bool found = false;
|
||||||
sfinfoOut.format = SF_FORMAT_W64 | SF_FORMAT_PCM_24;
|
for (int i = 0; i < types; ++i) {
|
||||||
} else if (ex == "ogg") {
|
SF_FORMAT_INFO info;
|
||||||
sfinfoOut.format = SF_FORMAT_OGG;
|
info.format = i;
|
||||||
} else { // fall back to
|
if (sf_command(0, SFC_GET_FORMAT_MAJOR, &info, sizeof(info))) {
|
||||||
sfinfoOut.format = sfinfo.format;
|
continue;
|
||||||
|
} else {
|
||||||
|
if (ex == std::string(info.extension)) {
|
||||||
|
sfinfoOut.format = info.format | SF_FORMAT_PCM_24;
|
||||||
|
found = true;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!found) {
|
||||||
|
cerr << "NOTE: Unknown output file extension \"" << extOut
|
||||||
|
<< "\", will use same file format as input file" << endl;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user