-
-
Notifications
You must be signed in to change notification settings - Fork 13
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Issue #411 #501
Issue #411 #501
Conversation
src/views/AnalysisView.vue
Outdated
@@ -87,7 +89,8 @@ const matrix = computed(() => { | |||
props.scale.head(MAX_SCALE_SIZE).mergeOptions({ | |||
centsFractionDigits: 1, | |||
decimalFractionDigits: 3, | |||
}) | |||
}), | |||
1 - (matrixStartIndex.value) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You shouldn't call a property something and then pass it as the inverse of that to another function.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What I have should work fine (for issue #411), though. I am using just "matrixStartIndex.value" in other parts.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's admittedly a really janky way to not display the zeroth column but just for the zero-indexed option. I should fix that.
src/views/AnalysisView.vue
Outdated
@@ -99,10 +102,10 @@ const matrix = computed(() => { | |||
<table> | |||
<tr> | |||
<th></th> | |||
<th v-for="i of Math.min(scale.size, MAX_SCALE_SIZE)" :key="i"> | |||
<th v-for="i of Math.min(scale.size-1+matrixStartIndex, MAX_SCALE_SIZE-1)" :key="i"> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
MAX_SCALE_SIZE
is a sanity limit that makes sure the browser doesn't go 💥 . You could rename it to something like MAX_NUM_COLUMNS
or something. That -1
should be there on a constant.
src/analysis.ts
Outdated
const result = []; | ||
const degrees = [...Array(scale.size + 1).keys()]; | ||
const degrees = [...Array(scale.size + 1 - startIndex).keys()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I know this is my code, but this is no longer an array of degrees
.
Just do an extra for
loop below and collect stuff into a const row = []
array.
src/views/AnalysisView.vue
Outdated
@@ -19,6 +19,8 @@ const props = defineProps<{ | |||
}>(); | |||
|
|||
const cellFormat = ref<"best" | "cents" | "decimal">("best"); | |||
const indexing = ref<"zero" | "one">("zero"); | |||
const matrixStartIndex = computed(() => indexing.value === "one" ? 1 : 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To be specific: Swap here, not down there.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Computed properties should be collected together after mutable state.
The choice should be persisted
and the corresponding |
src/views/AnalysisView.vue
Outdated
@@ -19,6 +19,8 @@ const props = defineProps<{ | |||
}>(); | |||
|
|||
const cellFormat = ref<"best" | "cents" | "decimal">("best"); | |||
const intervalMatrixIndexing = ref<"zero" | "one">("zero"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If you want to persist the value you have to use a component prop and drill it back to the app using emits.
Now this line just creates a new local property.
src/App.vue
Outdated
@@ -288,6 +289,7 @@ watch( | |||
pingPongFeedback, | |||
pingPongSeparation, | |||
pingPongGain, | |||
intervalMatrixIndexing |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
You specifically don't want to share your personal preferences with the world.
The app doesn't load at all for me now. |
src/analysis.ts
Outdated
@@ -103,12 +103,12 @@ export function utonalFundamental(frequencies: number[], maxDivisor = 23) { | |||
} | |||
|
|||
// Interval matrix a.k.a the modes of a scale | |||
export function intervalMatrix(scale: Scale) { | |||
export function intervalMatrix(scale: Scale, startIndex: number) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This is now an unrelated change that doesn't belong in the scope of this PR.
Now it works on my end. What's the intended behaviour? |
src/App.vue
Outdated
@@ -120,6 +120,7 @@ const centsFractionDigits = ref(3); | |||
const decimalFractionDigits = ref(5); | |||
const showVirtualQwerty = ref(false); | |||
const midiOctaveOffset = ref(-1); | |||
const intervalMatrixIndexing = ref<"zero" | "one">("zero"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This could be replaced with a number called intervalMatrixIndexOffset
that gets added to the headers if that's the intended effect.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In my previous iterations of attempting that, it seems the radio buttons don't want me to make their associated type a number
instead of a radio
:
Internal server error: Unnecessary value binding used alongside v-model. It will interfere with v-model's behavior.
Plugin: vite:vue
File: /home/inthar/Downloads/scale-workshop-main/src/views/AnalysisView.vue
160| <input
161| type="number"
162| id="indexing-zero"
| ^
163| value="0"
164| v-model="intervalMatrixIndexing"
at Object.createCompilerError (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:19:19)
at createDOMCompilerError (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js:2483:25)
at checkDuplicatedValue (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js:2547:29)
at transformModel (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-dom/dist/compiler-dom.cjs.js:2579:29)
at buildProps (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:4777:48)
at Array.postTransformElement (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:4374:38)
at traverseNode (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2225:19)
at traverseChildren (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2167:9)
at traverseNode (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2218:13)
at traverseChildren (/home/inthar/Downloads/scale-workshop-main/node_modules/@vue/compiler-core/dist/compiler-core.cjs.js:2167:9)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's one of these things that seem like they ought to work but don't.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, you need an auxillary ref and a watcher if you want to use v-model
it's better to just emit the correct values from the radio buttons directly.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What can I use to label the data instead of a v-model
?
src/views/AnalysisView.vue
Outdated
@@ -87,7 +97,8 @@ const matrix = computed(() => { | |||
props.scale.head(MAX_SCALE_SIZE).mergeOptions({ | |||
centsFractionDigits: 1, | |||
decimalFractionDigits: 3, | |||
}) | |||
}), | |||
0 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This whole change should be reverted as I misread your intention when suggesting it.
This is now 13 commits long. They should all be squashed into one so that we get a readable commit history in |
@@ -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()]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A little unrelated, but OK...
src/App.vue
Outdated
@@ -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")!); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
parseInt(null)
results in NaN
so that exclamation mark is definitely in the wrong here. (Remember to test after running window.localStorage.clear()
in the console.)
GitHubActions seems to have something to say about your code style. |
The commit message is too long. Use |
…of the top row of the interval matrix in Analysis view.
src/App.vue
Outdated
|
||
if ("intervalMatrixIndexing" in storage) { | ||
intervalMatrixIndexing.value = parseInt( | ||
storage.getItem("intervalMatrixIndexing")! |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still doing naughty things and storing a NaN
on first load.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This really should be parseInt(storage.getItem("intervalMatrixIndexing") ?? "0", 10)
Commits need squashing again. |
Feel free to add your name on the About page. |
Prevent a NaN on first load.
Added radio buttons and the reaction. Using zero-indexing is the default and omits the column of all unisons.