| 910 | } |
| 911 | |
| 912 | void DexedAudioProcessor::applySCLTuning() { |
| 913 | FileChooser fc( "Please select a scale (.scl) file.", File(), "*.scl" ); |
| 914 | File s; |
| 915 | |
| 916 | // loop to enforce the proper selection |
| 917 | for (;;) { |
| 918 | // open file chooser dialog |
| 919 | if (!fc.browseForFileToOpen()) |
| 920 | // User cancelled |
| 921 | return; |
| 922 | s = fc.getResult(); |
| 923 | |
| 924 | // enforce file extenstion ''.scl''. |
| 925 | // (reason: the extension ''.scl'' is mandatory according to |
| 926 | // ''https://www.huygens-fokker.org/scala/scl_format.html'' |
| 927 | if (s.getFileExtension() != ".scl") { |
| 928 | AlertWindow::showMessageBox(AlertWindow::WarningIcon, "Invalid file type!", "Only files with the \".scl\" extension (in lowercase!) are allowed."); |
| 929 | continue; |
| 930 | } |
| 931 | |
| 932 | // enforce to select file below the max limit16KB sized files |
| 933 | if (s.getSize() > MAX_SCL_KBM_FILE_SIZE) { |
| 934 | std::string msg; |
| 935 | msg = "File size exceeded the maximum limit of " + std::to_string(MAX_SCL_KBM_FILE_SIZE) + " bytes."; |
| 936 | AlertWindow::showMessageBox(AlertWindow::WarningIcon, "File size error!", msg); |
| 937 | continue; |
| 938 | } |
| 939 | |
| 940 | // enforce to select non-empty file |
| 941 | // TODO: check, whether zero sized files may occur indeed here; if not, delete this if-statement, please |
| 942 | if (s.getSize() == 0) { |
| 943 | std::string msg; |
| 944 | msg = "File is empty."; |
| 945 | AlertWindow::showMessageBox(AlertWindow::WarningIcon, "File size error!", msg); |
| 946 | continue; |
| 947 | } |
| 948 | |
| 949 | // try to apply the SCL file |
| 950 | applySCLTuning(s); |
| 951 | |
| 952 | // exit the loop |
| 953 | break; |
| 954 | } |
| 955 | } |
| 956 | |
| 957 | void DexedAudioProcessor::applySCLTuning(File s) { |
| 958 | std::string sclcontents = s.loadFileAsString().toStdString(); |
no test coverage detected