!7 set flag DynModule. sclass Recording { File file, clippedFile; double clippedLength; S text; 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(allRecordings(), func(File f) -> Recording { nu(Recording, file := f, text := wordFromAudioFileName(f.getName())) })); 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); updateTable(); }), ); } }