|
|
|
@ -18,8 +18,6 @@ import javax.json.JsonObject; |
|
|
|
|
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 extension; |
|
|
|
@ -97,29 +95,9 @@ class Format |
|
|
|
|
return size; |
|
|
|
|
|
|
|
|
|
// try to find eg. "1.32MiB" inside note
|
|
|
|
|
Matcher matcher = SIZE_PATTERN.matcher(note); |
|
|
|
|
if (matcher.find()) |
|
|
|
|
{ |
|
|
|
|
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; |
|
|
|
|
long size = Util.parseSize(note); |
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
return -1; |
|
|
|
|
return size; |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public int getSampleRate() |
|
|
|
@ -128,12 +106,7 @@ class Format |
|
|
|
|
return samplerate; |
|
|
|
|
|
|
|
|
|
// try to find eg. "51k" inside note
|
|
|
|
|
Matcher matcher = SAMPLE_RATE_PATTERN.matcher(note); |
|
|
|
|
if (matcher.find()) |
|
|
|
|
{ |
|
|
|
|
return Integer.parseInt(matcher.group(1)) * 1000; |
|
|
|
|
} |
|
|
|
|
return -1; |
|
|
|
|
return Util.parseSampleRate(note); |
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
public void setSampleRate(int samplerate) |
|
|
|
|