Skip to content

Commit

Permalink
Merge pull request #430 from xenharmonic-devs/default-interval-options
Browse files Browse the repository at this point in the history
Attach default interval options to parsed scale lines
  • Loading branch information
frostburn authored Nov 26, 2023
2 parents 1579ca2 + 5498d0b commit caebfe0
Showing 1 changed file with 12 additions and 3 deletions.
15 changes: 12 additions & 3 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,12 @@ import {
} from "./keyboard-mapping";
import { VirtualSynth } from "./virtual-synth";
import { Synth } from "@/synth";
import { Interval, parseLine, Scale } from "scale-workshop-core";
import {
Interval,
parseLine,
Scale,
type IntervalOptions,
} from "scale-workshop-core";
// === Root props and audio ===
const rootProps = defineProps<{
Expand Down Expand Up @@ -163,14 +168,18 @@ function updateFromScaleLines(lines: string[]) {
}
scaleLines.value = lines;
const intervals: Interval[] = [];
const options: IntervalOptions = {
centsFractionDigits: centsFractionDigits.value,
decimalFractionDigits: decimalFractionDigits.value,
};
lines.forEach((line) => {
try {
const interval = parseLine(line, DEFAULT_NUMBER_OF_COMPONENTS);
const interval = parseLine(line, DEFAULT_NUMBER_OF_COMPONENTS, options);
intervals.push(interval);
} catch {}
});
if (!intervals.length) {
intervals.push(parseLine("1/1", DEFAULT_NUMBER_OF_COMPONENTS));
intervals.push(parseLine("1/1", DEFAULT_NUMBER_OF_COMPONENTS, options));
}
const surrogate = Scale.fromIntervalArray(intervals);
Expand Down

0 comments on commit caebfe0

Please sign in to comment.