!7 set flag DynModule. sclass Recording { File file, clippedFile; double clippedLength; S text; *() {} *(File *file) { text = wordFromAudioFileName(file.getName()); } bool updateClip() { clippedFile = fileIfExists(fileInSubDir(file, "clipped")); if (clippedLength == 0) try { double l = lengthOfWAVInSeconds(clippedFile); if (l != 0) ret true with clippedLength = l; } catch print e { clippedLength = -1; } false; } } sclass AudioRecordings extends DynObjectTable { start { itemToMap = func(Recording r) -> Map { litorderedmap( Name := fileName(r.file), "Clipped length" := r.clippedLength == 0 ? "" : formatDouble(r.clippedLength, 1) + " s", Word := r.text) }; setData(map(latestFilesFirst(allRecordings()), func(File f) -> Recording { Recording(f) })); thread "Get Clip Lengths" { bool change = false; for (Recording r : data) if (r.updateClip()) set change; if (change) updateTable(); } } visualize { JComponent c = super.visualize(); ret withCenteredButtons(c, tableDependentButton(table, "Play full", rThread { playWAV(selected().file) }), tableDependentButton(table, "Play clipped", rThread { playWAV(selected().clippedFile) }), tableDependentButton(table, "Clip", rThread { autoClipRecording(selected().file); selected().updateClip(); updateTable(); }), tableDependentButton(table, "Set word...", rThread { final Recording r = selected(); inputText("Word spoken in " + r.file.getName(), voidfunc(S word) { File newFile = makeFileNameUnique_space(recordingsDir(word + ".wav")); renameRecordingAndClip(r.file, newFile.getName()); Recording r2 = new(newFile); r2.updateClip(); syncReplace(data, r, r2); updateTable(); }); }), ); } }