Skip to content

Commit

Permalink
Fix volume not being parsed
Browse files Browse the repository at this point in the history
- Range should be parseFloat instead of parseInt
- floats starting with a dot should be prefixed with a zero
  • Loading branch information
selimnahimi committed Sep 29, 2023
1 parent 95521b5 commit 69a116f
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 8 deletions.
5 changes: 3 additions & 2 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

24 changes: 18 additions & 6 deletions src/lib/SoundscapeScriptParser.ts
Original file line number Diff line number Diff line change
Expand Up @@ -186,21 +186,33 @@ export default class SoundscapeScriptParser {
const split = this.stringBuffer.split(",");

if (split.length > 1) {
const start = split[0].trim();
const end = split[1].trim();
let start = split[0].trim();
let end = split[1].trim();

start = this.addZeroToFloatString(start);
end = this.addZeroToFloatString(end);

return {
min: parseInt(start),
max: parseInt(end)
min: parseFloat(start),
max: parseFloat(end)
}
} else {
const singleNumber = split[0];
return {
min: parseInt(singleNumber),
max: parseInt(singleNumber)
min: parseFloat(singleNumber),
max: parseFloat(singleNumber)
}
}
}

private addZeroToFloatString(floatString: string) {
if (floatString.startsWith(".")) {
return "0" + floatString;
}

return floatString;
}

private increaseDepth() {
this.depth++;
}
Expand Down

0 comments on commit 69a116f

Please sign in to comment.