Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
134 lines (122 loc) · 3.36 KB

File metadata and controls

134 lines (122 loc) · 3.36 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
package d3;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.io.IOException;
import java.text.SimpleDateFormat;
import java.util.TimeZone;
import PamUtils.FileParts;
public class D2TextTime {
long tagReferenceTime = 0;
public D2TextTime() {
/*
* Convert the tag reference time string to a long ...
* 13:38:35 on 14 June 2003
*/
SimpleDateFormat dateFormat = new SimpleDateFormat("dd/MM/yyyy hh:mm:ss");
dateFormat.setTimeZone(TimeZone.getTimeZone("UTC"));
try {
// tagReferenceTime = dateFormat.parse("14/06/2003 13:38:35").getTime();
tagReferenceTime = dateFormat.parse("01/01/1900 00:00:00").getTime();
}
catch (Exception e) {
System.out.println("d2 reference date string cannot be parsed ! " + e.getLocalizedMessage());
}
// tagReferenceTime = 0;
}
// @Override
public long getTimeFromFile(File file) {
String wavFileName = file.getAbsolutePath();
FileParts fp = new FileParts(file);
String end = fp.getFileEnd();
if (end == null) {
return Long.MIN_VALUE;
}
if (!end.equalsIgnoreCase("wav")) {
return Long.MIN_VALUE;
}
String txtFileName = wavFileName.replace(".wav", ".txt");
txtFileName = txtFileName.replace(".WAV", ".txt");
File txtFile = new File(txtFileName);
if (!txtFile.exists()) {
return Long.MIN_VALUE;
}
long fileTime = Long.MIN_VALUE;
try {
FileReader fileReader = new FileReader(txtFile);
BufferedReader bufferedReader = new BufferedReader(fileReader);
// StringBuffer stringBuffer = new StringBuffer();
String line;
while ((line = bufferedReader.readLine()) != null && fileTime == Long.MIN_VALUE) {
// stringBuffer.append(line);
// stringBuffer.append("\n");
fileTime = interpretLine(line);
}
fileReader.close();
// System.out.println("Contents of file:");
// System.out.println(stringBuffer.toString());
} catch (IOException e) {
e.printStackTrace();
}
return fileTime;
}
private static String searchLine = "File recording started";
/**
* Attempt to get a valid data from within a single line from the file.
* @param line
* @return a millisecond data, or Long.Min_VALUE if it can't be interpreted.
*/
private long interpretLine(String line) {
/*
* Sample file from Marjo is#FFSRD DTAG flexible file system extractor
% Chunk report for file gm143a03.dtg, 
% Starting at chip 3, block 1
% Recording number 162
% File recording started: cbe00ffd
% Error numbers:
% CHUNK TOO LARGE 1
% UNKNOWN SOURCE ID 2
% BAD DATA CRC 3
% OUT OF SEQUENCE CHUNK 4
% INTERPRETATION ERROR 5
*/
if (line == null) {
return Long.MIN_VALUE;
}
int p = line.indexOf(searchLine, 0);
if (p < 0) {
return Long.MIN_VALUE;
}
String hexStr = "0x"+ line.substring(p + searchLine.length() + 2).trim();
long tVal = Long.MIN_VALUE;
try {
tVal = Long.decode(hexStr);
}
catch (NumberFormatException e) {
return Long.MIN_VALUE;
}
if (tVal == Long.MIN_VALUE) {
return Long.MIN_VALUE;
}
return tagReferenceTime + tVal * 1000;
}
// @Override
// public boolean hasSettings() {
// return false;
// }
//
// @Override
// public boolean doSettings() {
// return false;
// }
//
// @Override
// public String getName() {
// return "d2 file time";
// }
//
// @Override
// public String getDescription() {
// return "Extract time information from txt files accompanying d2 wav files";
// }
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.