Skip to content

Commit

Permalink
Issue #411, add radio buttons to change the indexing of the top row o…
Browse files Browse the repository at this point in the history
…f the interval matrix in Analysis view.

Add files via upload

Update AnalysisView.vue

The table now keeps the 0-step column for both 0-indexed and 1-indexed, so we can now address #445 if we want.

Update AnalysisView.vue

`indexing` -> `intervalMatrixIndexing`

Update App.vue

Persist `intervalMatrixIndex` in local storage

Update AnalysisView.vue

emit value `intervalMatrixIndex` to persist it

Add files via upload

Add files via upload

Add files via upload

`intervalMatrixIndexing` is now a `number`.

`intervalMatrixIndexing` is now a `number`.

Update AnalysisView.vue

`value="0"` etc. -> `:value="0"` etc.

Update AnalysisView.vue

Update AnalysisView.vue

Make sure to parse the integer emitted by indexing radio buttons as decimal

Update AnalysisView.vue

Update analysis.ts

startIndex is not necessary yet (issue #445 should be dealt with separately)
  • Loading branch information
inthar-raven committed Nov 29, 2023
1 parent 6589dcb commit 995ab97
Show file tree
Hide file tree
Showing 3 changed files with 46 additions and 6 deletions.
10 changes: 9 additions & 1 deletion src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,6 +120,7 @@ const centsFractionDigits = ref(3);
const decimalFractionDigits = ref(5);
const showVirtualQwerty = ref(false);
const midiOctaveOffset = ref(-1);
const intervalMatrixIndexing = ref(0);
// Special keyboard codes also from local storage.
const deactivationCode = ref("Backquote");
Expand Down Expand Up @@ -783,7 +784,9 @@ onMounted(() => {
if ("midiOctaveOffset" in storage) {
midiOctaveOffset.value = parseInt(storage.getItem("midiOctaveOffset")!);
}
if ("intervalMatrixIndexing" in storage) {
intervalMatrixIndexing.value = parseInt(storage.getItem("intervalMatrixIndexing")!);

Check warning on line 788 in src/App.vue

View workflow job for this annotation

GitHub Actions / build (17.x)

Replace `storage.getItem("intervalMatrixIndexing")!` with `⏎······storage.getItem("intervalMatrixIndexing")!⏎····`
}
// Fetch special key map
if ("deactivationCode" in storage) {
deactivationCode.value = storage.getItem("deactivationCode")!;
Expand Down Expand Up @@ -968,6 +971,9 @@ watch(showVirtualQwerty, (newValue) =>
watch(midiOctaveOffset, (newValue) =>
window.localStorage.setItem("midiOctaveOffset", newValue.toString())
);
watch(intervalMatrixIndexing, (newValue) =>
window.localStorage.setItem("intervalMatrixIndexing", newValue.toString())
);
// Store keymaps
watch(deactivationCode, (newValue) =>
window.localStorage.setItem("deactivationCode", newValue)
Expand Down Expand Up @@ -1069,6 +1075,7 @@ watch(degreeDownCode, (newValue) =>
:keyboardMapping="keyboardMapping"
:showVirtualQwerty="showVirtualQwerty"
:midiOctaveOffset="midiOctaveOffset"
:intervalMatrixIndexing="intervalMatrixIndexing"
@update:audioDelay="audioDelay = $event"
@update:mainVolume="mainVolume = $event"
@update:scaleName="scaleName = $event"
Expand All @@ -1095,6 +1102,7 @@ watch(degreeDownCode, (newValue) =>
@update:decimalFractionDigits="decimalFractionDigits = $event"
@update:showVirtualQwerty="showVirtualQwerty = $event"
@update:midiOctaveOffset="midiOctaveOffset = $event"
@update:intervalMatrixIndexing="intervalMatrixIndexing = $event"
@update:deactivationCode="deactivationCode = $event"
@update:equaveUpCode="equaveUpCode = $event"
@update:equaveDownCode="equaveDownCode = $event"
Expand Down
4 changes: 2 additions & 2 deletions src/analysis.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,10 +105,10 @@ export function utonalFundamental(frequencies: number[], maxDivisor = 23) {
// Interval matrix a.k.a the modes of a scale
export function intervalMatrix(scale: Scale) {
const result = [];
const degrees = [...Array(scale.size + 1).keys()];
const columns = [...Array(scale.size + 1).keys()];
for (let i = 0; i < scale.size; ++i) {
const mode = scale.rotate(i);
result.push(degrees.map((j) => mode.getInterval(j)));
result.push(columns.map((j) => mode.getInterval(j)));
}
return result;
}
38 changes: 35 additions & 3 deletions src/views/AnalysisView.vue
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,18 @@ const props = defineProps<{
scale: Scale;
virtualSynth: VirtualSynth;
colorScheme: "light" | "dark";
intervalMatrixIndexing: number;
}>();
const emit = defineEmits([

Check warning on line 22 in src/views/AnalysisView.vue

View workflow job for this annotation

GitHub Actions / build (17.x)

Replace `⏎··"update:intervalMatrixIndexing",⏎` with `"update:intervalMatrixIndexing"`
"update:intervalMatrixIndexing",
]);
const intervalMatrixIndexing = computed({
get: () => props.intervalMatrixIndexing,
set: (newValue: string) => emit("update:intervalMatrixIndexing", parseInt(newValue, 10)),

Check warning on line 28 in src/views/AnalysisView.vue

View workflow job for this annotation

GitHub Actions / build (17.x)

Insert `⏎···`
});
const cellFormat = ref<"best" | "cents" | "decimal">("best");
const trailLongevity = ref(70);
const maxOtonalRoot = ref(16);
Expand Down Expand Up @@ -87,7 +97,7 @@ const matrix = computed(() => {
props.scale.head(MAX_SCALE_SIZE).mergeOptions({
centsFractionDigits: 1,
decimalFractionDigits: 3,
})
}),

Check warning on line 100 in src/views/AnalysisView.vue

View workflow job for this annotation

GitHub Actions / build (17.x)

Delete `,`
).map((row) => row.map(formatMatrixCell));
});
</script>
Expand All @@ -100,9 +110,9 @@ const matrix = computed(() => {
<tr>
<th></th>
<th v-for="i of Math.min(scale.size, MAX_SCALE_SIZE)" :key="i">
{{ i }}
{{ i - 1 + intervalMatrixIndexing }}
</th>
<th>({{ scale.size + 1 }})</th>
<th>({{ scale.size + intervalMatrixIndexing }})</th>
</tr>
<tr v-for="(row, i) of matrix" :key="i">
<th>{{ formatMatrixCell(scale.getInterval(i)) }}</th>
Expand Down Expand Up @@ -143,6 +153,28 @@ const matrix = computed(() => {
<label for="format-decimal"> Decimal ratio </label>
</span>
</div>
<div class="control radio-group">
<label>Interval indexing</label>
<span>
<input
type="radio"
id="indexing-zero"
value="0"
v-model="intervalMatrixIndexing"
/>
<label for="indexing-zero"> 0-indexing (default) </label>
</span>

Check warning on line 167 in src/views/AnalysisView.vue

View workflow job for this annotation

GitHub Actions / build (17.x)

Delete `········`
<span>
<input
type="radio"
id="indexing-one"
value="1"
v-model="intervalMatrixIndexing"
/>
<label for="indexing-one"> 1-indexing </label>
</span>
</div>
</div>
<div class="columns-container">
<div class="column">
Expand Down

0 comments on commit 995ab97

Please sign in to comment.