diff --git a/magic.json.default b/magic.json.default index 2a18a21..c031c63 100644 --- a/magic.json.default +++ b/magic.json.default @@ -1,5 +1,6 @@ { "ffmpeg" : "/usr/bin/ffmpeg", + "sox" : "/usr/bin/sox", "app_secret" : "your_secret", "app_id" : "your_id", diff --git a/source/app.d b/source/app.d index 772df02..203e45a 100644 --- a/source/app.d +++ b/source/app.d @@ -1,4 +1,4 @@ -import std.stdio, std.regex, std.json, std.file, std.datetime, std.conv, std.process, std.net.curl; +import std.stdio, std.regex, std.json, std.file, std.datetime, std.conv, std.process, std.net.curl, std.string; import qobuz.api; int main(string[] args) @@ -96,5 +96,24 @@ int main(string[] args) download(id.getArtUrl, dirName~"/cover.jpg"); writeln("Done!"); + string choice; + while (choice != "n" && choice != "y") { + write("Generate spectrals? [y/n] "); + choice = readln().chomp; + } + if (choice == "y") { + auto full = execute([magic["sox"].str, dirName~"/01 "~tracks[0]["title"].str~".flac", "-n", "remix", "1", "spectrogram", + "-x", "3000", "-y", "513", "-z", "120", "-w", "Kaiser", "-o", "SpecFull.png"]); + auto zoom = execute([magic["sox"].str, dirName~"/01 "~tracks[0]["title"].str~".flac", "-n", "remix", "1", "spectrogram", + "-X", "500", "-y", "1025", "-z", "120", "-w", "Kaiser", "-S", "0:30", "-d", "0:04", "-o", "SpecZoom.png"]); + if (full.status != 0 || zoom.status != 0) { + writeln("Generating spectrals failed! Is sox configured properly?"); + } else { + writeln("SpecFull.png and SpecZoom.png written."); + } + } + + writeln("All done, exiting."); + return 0; }