|
|
@ -18,8 +18,6 @@ import javax.json.JsonObject; |
|
|
|
class Format |
|
|
|
class Format |
|
|
|
{ |
|
|
|
{ |
|
|
|
|
|
|
|
|
|
|
|
private static final Pattern SIZE_PATTERN = Pattern.compile("\\b([0-9]+\\.?[0-9]*)([kkMmGg])i?[bB]\\b"); |
|
|
|
|
|
|
|
private static final Pattern SAMPLE_RATE_PATTERN = Pattern.compile("\\b([0-9]+)k(b(ps?))?\\b"); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private final String code; |
|
|
|
private final String code; |
|
|
|
private final String extension; |
|
|
|
private final String extension; |
|
|
@ -97,29 +95,9 @@ class Format |
|
|
|
return size; |
|
|
|
return size; |
|
|
|
|
|
|
|
|
|
|
|
// try to find eg. "1.32MiB" inside note
|
|
|
|
// try to find eg. "1.32MiB" inside note
|
|
|
|
Matcher matcher = SIZE_PATTERN.matcher(note); |
|
|
|
long size = Util.parseSize(note); |
|
|
|
if (matcher.find()) |
|
|
|
|
|
|
|
{ |
|
|
|
return size; |
|
|
|
double value = Double.parseDouble(matcher.group(1)); |
|
|
|
|
|
|
|
String mag = matcher.group(2).toUpperCase(); |
|
|
|
|
|
|
|
long mult = 1; |
|
|
|
|
|
|
|
switch (mag) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
case "K": |
|
|
|
|
|
|
|
mult = 1024; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "M": |
|
|
|
|
|
|
|
mult = 1024 * 1024; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
case "G": |
|
|
|
|
|
|
|
mult = 1024 * 1024 * 1024; |
|
|
|
|
|
|
|
break; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
value *= mult; |
|
|
|
|
|
|
|
return (long) value; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public int getSampleRate() |
|
|
|
public int getSampleRate() |
|
|
@ -128,12 +106,7 @@ class Format |
|
|
|
return samplerate; |
|
|
|
return samplerate; |
|
|
|
|
|
|
|
|
|
|
|
// try to find eg. "51k" inside note
|
|
|
|
// try to find eg. "51k" inside note
|
|
|
|
Matcher matcher = SAMPLE_RATE_PATTERN.matcher(note); |
|
|
|
return Util.parseSampleRate(note); |
|
|
|
if (matcher.find()) |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
return Integer.parseInt(matcher.group(1)) * 1000; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return -1; |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public void setSampleRate(int samplerate) |
|
|
|
public void setSampleRate(int samplerate) |
|
|
|