This commit is contained in:
Douglas Gillespie 2023-06-09 12:28:29 +01:00
commit b0a063004e
3 changed files with 30 additions and 15 deletions

View File

@ -104,9 +104,13 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
boolean ans = super.prepareInputFile(); boolean ans = super.prepareInputFile();
if (ans == false && ++currentFile < allFiles.size()) { if (ans == false && ++currentFile < allFiles.size()) {
System.out.println("Failed to open sound file. Try again with file " + allFiles.get(currentFile).getName()); System.out.println("Failed to open sound file. Try again with file " + allFiles.get(currentFile).getName());
/*
* jumping striaght to the next file messes it up if it thinks the files
* are continuous, so we HAVE to stop and restart.
*/
// return prepareInputFile();
PamController.getInstance().pamStop(); PamController.getInstance().pamStop();
PamController.getInstance().startLater(); PamController.getInstance().startLater(false);
} }
return ans; return ans;
} }
@ -614,16 +618,16 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
long currFileEnd = 0; long currFileEnd = 0;
if (currentFile >= 0) { if (currentFile >= 0) {
try { try {
WavFileType currentWav = allFiles.get(currentFile); WavFileType currentWav = allFiles.get(currentFile);
currFileStart = getFileStartTime(currentWav.getAbsoluteFile()); currFileStart = getFileStartTime(currentWav.getAbsoluteFile());
if (audioStream != null) { if (audioStream != null) {
fileSamples = audioStream.getFrameLength(); fileSamples = audioStream.getFrameLength();
currFileLength = (long) (fileSamples * 1000 / audioStream.getFormat().getFrameRate()); currFileLength = (long) (fileSamples * 1000 / audioStream.getFormat().getFrameRate());
currFileEnd = currFileStart + currFileLength; currFileEnd = currFileStart + currFileLength;
} }
} }
catch (Exception e) { catch (Exception e) {
} }
} }
if (currFileEnd == 0) { if (currFileEnd == 0) {
@ -648,7 +652,17 @@ public class FolderInputSystem extends FileInputSystem implements PamSettings, D
} }
setFolderProgress(); setFolderProgress();
// sayEta(); // sayEta();
ans = prepareInputFile(); /*
* I think that here, we just need a check of the file. the prepareInputFile in
* this class will (on failure) move straight to the next file and also issue a
* stop/start, which is not good if it's trying a continuous file, where this is
* being called, if false is returned it should manage moving onto the next file by
* itself if we use the super.prep ....
*/
ans = super.prepareInputFile();
if (ans == false) {
return false;
}
currentFileStart = System.currentTimeMillis(); currentFileStart = System.currentTimeMillis();
// if (ans && audioFormat.getSampleRate() != currentSampleRate && currentFile > 0) { // if (ans && audioFormat.getSampleRate() != currentSampleRate && currentFile > 0) {
// acquisitionControl.getDaqProcess().setSampleRate(currentSampleRate = audioFormat.getSampleRate(), true); // acquisitionControl.getDaqProcess().setSampleRate(currentSampleRate = audioFormat.getSampleRate(), true);

View File

@ -48,9 +48,9 @@ public class SudAudioFile extends WavAudioFile {
} }
// don't do anything and it will try the built in Audiosystem // don't do anything and it will try the built in Audiosystem
catch (UnsupportedAudioFileException e) { catch (UnsupportedAudioFileException e) {
System.err.println("Could not open sud file: not a supported file " + soundFile.getName()); System.err.println("UnsupportedAudioFileException: Could not open sud file: not a supported file " + soundFile.getName());
System.err.println(e.getMessage());
e.printStackTrace(); // e.printStackTrace();
} catch (IOException e) { } catch (IOException e) {
System.err.println("Could not open sud file: IO Exception: " + soundFile.getName()); System.err.println("Could not open sud file: IO Exception: " + soundFile.getName());

View File

@ -46,7 +46,8 @@ public class SudAudioFileReader {
try { try {
sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, false); sudAudioInputStream = SudAudioInputStream.openInputStream(file, sudParams, false);
} catch (Exception e) { } catch (Exception e) {
e.printStackTrace(); String msg = String.format("Corrupt sud file %s: %s", file.getName(), e.getMessage());
throw new UnsupportedAudioFileException(msg);
} }
return sudAudioInputStream; return sudAudioInputStream;
} }