Uses 12716K of libraries. Click here for Pure Java version (7935L/40K).
1 | !7 |
2 | |
3 | set flag DynModule. |
4 | |
5 | sclass Recording { |
6 | File file; |
7 | double length; |
8 | S containsVoice; |
9 | |
10 | *() {} |
11 | *(File *file) { |
12 | containsVoice = getFileInfoField(file, "Contains voice"); |
13 | } |
14 | |
15 | bool updateClip() { |
16 | bool change = false; |
17 | if (length == 0) try { |
18 | double l = lengthOfWAVInSeconds(file); |
19 | if (l != 0) { length = l; set change; } |
20 | } catch print e { length = -1; } |
21 | ret change; |
22 | } |
23 | } |
24 | |
25 | cmodule AudioRecordings2 extends DynObjectTable<Recording> { |
26 | transient ReliableSingleThread scan = dm_rst(this, r _scan); |
27 | |
28 | start { |
29 | itemToMap = func(Recording r) -> Map { |
30 | litorderedmap( |
31 | Name := fileName(r.file), |
32 | "Length" := formatDouble(r.length, 1) + " s", |
33 | "Contains Voice" := or2(r.containsVoice, "?")) |
34 | }; |
35 | ownResource(vmBus_onMessage('newRecording, scan)); |
36 | scan.trigger(); |
37 | } |
38 | |
39 | void _scan { |
40 | temp enter(); |
41 | setData(map(latestFilesFirst(allRecordings()), f1_new(Recording))); |
42 | |
43 | thread "Get Clip Lengths" { |
44 | bool change = false; |
45 | for (Recording r : data) |
46 | if (r.updateClip()) set change; |
47 | if (change) updateTable(); |
48 | } |
49 | } |
50 | |
51 | visualize { |
52 | JComponent c = super.visualize(); |
53 | ret withCenteredButtons(c, |
54 | tableDependentButton(table, "Clip", rThread { |
55 | File f = selected().file; |
56 | //autoClipRecording(f); |
57 | clipWAVFromMarkers(f, fileInSubDir(f, "clipped")); |
58 | selected().updateClip(); |
59 | updateTable(); |
60 | }), |
61 | tableDependentButton(table, "Copy path", rThread { copyTextToClipboard(f2s(selected().file)) }), |
62 | tableDependentButton(table, "Play", rThread { dm_playWAV(selected().file) }), |
63 | tableDependentButton(table, "Has voice", rThread { |
64 | final Recording r = selected(); |
65 | setFileInfoField(r.file, "Contains voice", "Yes"); |
66 | updateTable(); |
67 | }), |
68 | tableDependentButton(table, "No voice", rThread { |
69 | final Recording r = selected(); |
70 | setFileInfoField(r.file, "Contains voice", "No"); |
71 | updateTable(); |
72 | }), |
73 | ); |
74 | } |
75 | } |
Began life as a copy of #1018656
download show line numbers debug dex old transpilations
Travelled to 13 computer(s): bhatertpkbcr, cbybwowwnfue, cfunsshuasjs, gwrvuhgaqvyk, irmadwmeruwu, ishqpsrjomds, lpdgvwnxivlt, mqqgnosmbjvj, pyentgdyhuwx, pzhvpgtvlbxg, tvejysmllsmz, vouqrxazstgt, xrpafgyirdlv
No comments. add comment
Snippet ID: | #1019278 |
Snippet name: | Mark Recordings as Voice/Non-Voice [Dyn Module] |
Eternal ID of this version: | #1019278/4 |
Text MD5: | fa0994fe3bef2d1d1cadd83c5edc0511 |
Transpilation MD5: | 46e1d0133c4d975aade432e09ca75e57 |
Author: | stefan |
Category: | javax / stefan's os |
Type: | JavaX source code (Dynamic Module) |
Public (visible to everyone): | Yes |
Archived (hidden from active list): | No |
Created/modified: | 2020-02-04 01:48:18 |
Source code size: | 2111 bytes / 75 lines |
Pitched / IR pitched: | No / No |
Views / Downloads: | 330 / 1295 |
Version history: | 3 change(s) |
Referenced in: | [show references] |