Skip to content

Commit

Permalink
Merge branch 'virtual-keyboard-labels' of https://github.com/wilckers…
Browse files Browse the repository at this point in the history
…on/scale-workshop into virtual-keyboard-labels
  • Loading branch information
wilckerson committed Apr 19, 2024
2 parents 5229335 + 511954a commit 754ed9a
Show file tree
Hide file tree
Showing 53 changed files with 483 additions and 396 deletions.
3 changes: 3 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,10 @@
* Feature: Tonnetz prime ellipse coordinates on the lattice tab [#588](https://github.com/xenharmonic-devs/scale-workshop/issues/588)
* Feature: New `latticeView()` command for displaying the order of intervals (prior to sorting) [#597](https://github.com/xenharmonic-devs/scale-workshop/issues/597)
* Feature: New "repeat" modifier [#406](https://github.com/xenharmonic-devs/scale-workshop/issues/406)
* Feature: Implement multi-channel MIDI mode compatible with the Lumatone [#649](https://github.com/xenharmonic-devs/scale-workshop/pull/649)
* Bug fix: Extreme ratios now only break parts of the tuning table that do not have IEEE floating point representation and format better when non-finite [#631](https://github.com/xenharmonic-devs/scale-workshop/issues/631), [#632](https://github.com/xenharmonic-devs/scale-workshop/issues/632)
* Style fix: Make checkbox and radio button labels more consistent [#644](https://github.com/xenharmonic-devs/scale-workshop/issues/644)
* Beta cycle issues: [#643](https://github.com/xenharmonic-devs/scale-workshop/issues/643), [#640](https://github.com/xenharmonic-devs/scale-workshop/issues/640), [#577](https://github.com/xenharmonic-devs/scale-workshop/issues/577), [#513](https://github.com/xenharmonic-devs/scale-workshop/issues/513), [#658](https://github.com/xenharmonic-devs/scale-workshop/issues/658)
* Alpha cycle issues: [#574](https://github.com/xenharmonic-devs/scale-workshop/issues/574), [#579](https://github.com/xenharmonic-devs/scale-workshop/issues/579)

## 2.4.1
Expand Down
222 changes: 104 additions & 118 deletions package-lock.json

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "scale-workshop",
"version": "3.0.0-beta.11",
"version": "3.0.0-beta.14",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
Expand All @@ -21,14 +21,14 @@
"moment-of-symmetry": "^0.4.2",
"pinia": "^2.1.7",
"qs": "^6.12.0",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.12",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.20",
"sw-synth": "^0.1.0",
"temperaments": "^0.5.3",
"vue": "^3.3.4",
"vue-router": "^4.3.0",
"webmidi": "^3.1.8",
"xen-dev-utils": "^0.2.9",
"xen-midi": "^0.1.3"
"xen-midi": "^0.2.0"
},
"devDependencies": {
"@rushstack/eslint-patch": "^1.8.0",
Expand Down
36 changes: 26 additions & 10 deletions src/App.vue
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ import { useAudioStore } from '@/stores/audio'
import { useStateStore } from './stores/state'
import { useMidiStore } from './stores/midi'
import { useScaleStore } from './stores/scale'
import { clamp } from 'xen-dev-utils'
import { clamp, mmod } from 'xen-dev-utils'
import { parseScaleWorkshop2Line, setNumberOfComponents } from 'sonic-weave'
// === Pinia-managed state ===
Expand Down Expand Up @@ -71,21 +71,37 @@ function sendNoteOn(frequency: number, rawAttack: number) {
return off
}
function midiNoteOn(index: number, rawAttack?: number) {
function midiNoteOn(index: number, rawAttack?: number, channel?: number) {
const multichannel = midi.multichannelToEquave
// in multichannel-to-equave mode calculate an offset based on the incoming channel
if (multichannel && channel !== undefined) {
let offset =
mmod(
channel - midi.multichannelCenter + midi.multichannelEquavesDown,
midi.multichannelNumEquaves
) - midi.multichannelEquavesDown
offset = offset * scale.scale.size
index = index + offset
}
if (rawAttack === undefined) {
rawAttack = 80
}
let frequency = scale.frequencies[index]
if (!midi.velocityOn) {
rawAttack = 80
}
// since index can go out of range in multichannel-to-equave mode, use getFrequency()
let frequency = scale.getFrequency(index)
// Store state to ensure consistent note off.
const info = midiKeyInfo(index)
const whiteMode = midi.whiteMode
const indices = scale.whiteIndices
if (whiteMode === 'off') {
if (whiteMode === 'off' || multichannel) {
tuningTableKeyOn(index)
} else if (whiteMode === 'simple') {
if (info.whiteNumber === undefined) {
Expand Down Expand Up @@ -142,7 +158,9 @@ function midiNoteOn(index: number, rawAttack?: number) {
if (!midi.velocityOn) {
rawRelease = 80
}
if (whiteMode === 'simple') {
if (whiteMode === 'off' || whiteMode === 'keyColors' || multichannel) {
tuningTableKeyOff(index)
} else if (whiteMode === 'simple') {
if (info.whiteNumber !== undefined) {
tuningTableKeyOff(info.whiteNumber)
}
Expand All @@ -153,8 +171,6 @@ function midiNoteOn(index: number, rawAttack?: number) {
} else {
tuningTableKeyOff(info.whiteNumber)
}
} else {
tuningTableKeyOff(index)
}
noteOff(rawRelease)
}
Expand Down Expand Up @@ -294,7 +310,7 @@ function typingKeydown(event: CoordinateKeyboardEvent) {
return emptyKeyup
}
let index = scale.baseMidiNote + scale.scale.size * scale.equaveShift + scale.degreeShift
let index = scale.scale.baseMidiNote + scale.scale.size * scale.equaveShift + scale.degreeShift
if (scale.keyboardMode === 'isomorphic') {
index += x * state.isomorphicHorizontal + (2 - y) * state.isomorphicVertical
Expand Down Expand Up @@ -337,7 +353,7 @@ onMounted(() => {
const scaleWorkshopOneData = new ScaleWorkshopOneData()
scale.name = scaleWorkshopOneData.name
scale.baseFrequency = scaleWorkshopOneData.freq
scale.userBaseFrequency = scaleWorkshopOneData.freq
scale.autoFrequency = false
scale.baseMidiNote = scaleWorkshopOneData.midi
state.isomorphicHorizontal = scaleWorkshopOneData.horizontal
Expand Down Expand Up @@ -375,7 +391,7 @@ onMounted(() => {
}
scale.name = decodedState.scaleName
scale.baseFrequency = decodedState.baseFrequency
scale.userBaseFrequency = decodedState.baseFrequency
scale.autoFrequency = false
scale.baseMidiNote = decodedState.baseMidiNote
state.isomorphicHorizontal = decodedState.isomorphicHorizontal
Expand Down
4 changes: 2 additions & 2 deletions src/analysis.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Interval, TimeMonzo } from 'sonic-weave'
import { Interval, TimeMonzo, TimeReal } from 'sonic-weave'
import { circleDistance, mmod, valueToCents } from 'xen-dev-utils'

const EPSILON = 1e-6
Expand Down Expand Up @@ -446,7 +446,7 @@ export function varietySignature(matrix: Interval[][]) {
return result
}
for (let i = 0; i < matrix[0].length; ++i) {
const variants: TimeMonzo[] = [matrix[0][i].value]
const variants: (TimeMonzo | TimeReal)[] = [matrix[0][i].value]
search: for (let j = 1; j < matrix.length; ++j) {
const monzo = matrix[j][i].value
for (const variant of variants) {
Expand Down
11 changes: 10 additions & 1 deletion src/assets/main.css
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,9 @@ select {
width: 6rem;
line-height: var(--base-line-height);
}
input[type='radio'] {
vertical-align: -0.05rem;
}
optgroup {
font-weight: bold;
}
Expand Down Expand Up @@ -142,12 +145,18 @@ ul.btn-group {
}
.control.checkbox-container label {
font-weight: normal;
margin-left: 0.2rem;
text-align: left;
vertical-align: baseline;
}
.control.radio-group {
gap: 0.15rem 1rem;
gap: 0rem 1rem;
}
.control.radio-group span label {
font-weight: unset;
margin-left: 0.35rem;
text-align: left;
vertical-align: baseline;
}

/* Responding to screen size */
Expand Down
8 changes: 0 additions & 8 deletions src/components/ExporterButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -46,8 +46,6 @@ function doExport(exporter: ExporterKey) {
scaleUrl: window.location.href,
filename: sanitizeFilename(scale.name),
relativeIntervals: scale.relativeIntervals,
baseFrequency: scale.baseFrequency,
baseMidiNote: scale.baseMidiNote,
scale: scale.scale,
labels: scale.labels,
midiOctaveOffset: -1,
Expand All @@ -68,8 +66,6 @@ function doExport(exporter: ExporterKey) {
@cancel="showKorgExportModal = false"
:newline="state.newline"
:scaleName="scale.name"
:baseMidiNote="scale.baseMidiNote"
:baseFrequency="scale.baseFrequency"
:relativeIntervals="scale.relativeIntervals"
:midiOctaveOffset="-1"
:scale="scale.scale"
Expand All @@ -82,8 +78,6 @@ function doExport(exporter: ExporterKey) {
@cancel="showMtsSysexExportModal = false"
:newline="state.newline"
:scaleName="scale.name"
:baseMidiNote="scale.baseMidiNote"
:baseFrequency="scale.baseFrequency"
:relativeIntervals="scale.relativeIntervals"
:midiOctaveOffset="-1"
:scale="scale.scale"
Expand All @@ -96,8 +90,6 @@ function doExport(exporter: ExporterKey) {
@cancel="showReaperExportModal = false"
:newline="state.newline"
:scaleName="scale.name"
:baseMidiNote="scale.baseMidiNote"
:baseFrequency="scale.baseFrequency"
:relativeIntervals="scale.relativeIntervals"
:midiOctaveOffset="-1"
:scale="scale.scale"
Expand Down
12 changes: 8 additions & 4 deletions src/components/JustIntonationLattice.vue
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<script setup lang="ts">
import { useJiLatticeStore } from '@/stores/ji-lattice'
import { spanLattice } from 'ji-lattice'
import { type Interval } from 'sonic-weave'
import { TimeMonzo, type Interval } from 'sonic-weave'
import { computed, nextTick, reactive, ref, watch } from 'vue'
import { dot } from 'xen-dev-utils'
Expand All @@ -23,9 +23,13 @@ const monzos = computed(() => {
const result: number[][] = []
for (const interval of props.relativeIntervals) {
const value = interval.value.clone()
value.numberOfComponents = numComponents
const monzo = interval.value.primeExponents.map((pe) => pe.valueOf())
result.push(monzo)
if (value instanceof TimeMonzo) {
value.numberOfComponents = numComponents
const monzo = value.primeExponents.map((pe) => pe.valueOf())
result.push(monzo)
} else {
result.push(Array(numComponents).fill(0))
}
}
return result
})
Expand Down
3 changes: 2 additions & 1 deletion src/components/MidiPiano.vue
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ const props = defineProps<{
baseMidiNote: number
whiteModeOffset: number
midiWhiteMode: 'off' | 'simple' | 'blackAverage' | 'keyColors'
multichannel: boolean
keyColors: string[]
activeKeys: Set<number>
}>()
Expand All @@ -30,7 +31,7 @@ const whiteIndices = computed(() => computeWhiteIndices(props.baseMidiNote, prop
function keyLabel(chromaticNumber: number) {
const info = midiKeyInfo(chromaticNumber)
if (props.midiWhiteMode === 'off') {
if (props.midiWhiteMode === 'off' || props.multichannel) {
return [(chromaticNumber - props.baseMidiNote).toString()]
} else if (props.midiWhiteMode === 'simple') {
if (info.whiteNumber !== undefined) {
Expand Down
2 changes: 1 addition & 1 deletion src/components/NewScale.vue
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ function blur() {
}
function updateBaseFrequency(value: number) {
scale.baseFrequency = value
scale.userBaseFrequency = value
scale.autoFrequency = false
}
Expand Down
8 changes: 4 additions & 4 deletions src/components/ScaleControls.vue
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,7 @@ defineExpose({ focus, clearPaletteInfo })
id="base-frequency"
type="number"
step="any"
v-model="scale.baseFrequency"
v-model="scale.baseFrequencyDisplay"
:disabled="scale.autoFrequency"
@input="updateScale"
/>
Expand All @@ -87,7 +87,7 @@ defineExpose({ focus, clearPaletteInfo })
v-model="scale.autoColors"
@input="updateScale"
/>
<label for="colors-silver"> Silver </label>
<label for="colors-silver">Silver</label>
</span>

<span>
Expand All @@ -98,7 +98,7 @@ defineExpose({ focus, clearPaletteInfo })
v-model="scale.autoColors"
@input="updateScale"
/>
<label for="colors-cents"> Cents </label>
<label for="colors-cents">Cents</label>
</span>

<span>
Expand All @@ -109,7 +109,7 @@ defineExpose({ focus, clearPaletteInfo })
v-model="scale.autoColors"
@input="updateScale"
/>
<label for="colors-factors"> Factors </label>
<label for="colors-factors">Factors</label>
</span>
</div>
</div>
Expand Down
4 changes: 0 additions & 4 deletions src/components/modals/export/KorgExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import type { Scale } from '@/scale'
const props = defineProps<{
newline: string
scaleName: string
baseMidiNote: number
baseFrequency: number
midiOctaveOffset: number
relativeIntervals: Interval[]
labels: string[]
Expand Down Expand Up @@ -50,9 +48,7 @@ async function doExport() {
scale: props.scale,
relativeIntervals: props.relativeIntervals,
labels: props.labels,
baseFrequency: props.baseFrequency,
filename: sanitizeFilename(props.scaleName),
baseMidiNote: props.baseMidiNote,
midiOctaveOffset: props.midiOctaveOffset
}
Expand Down
4 changes: 0 additions & 4 deletions src/components/modals/export/MtsSysexExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -11,8 +11,6 @@ import type { Interval } from 'sonic-weave'
const props = defineProps<{
newline: string
scaleName: string
baseMidiNote: number
baseFrequency: number
midiOctaveOffset: number
relativeIntervals: Interval[]
scale: Scale
Expand Down Expand Up @@ -58,8 +56,6 @@ function doExport() {
newline: props.newline,
scale: props.scale,
filename: sanitizeFilename(props.scaleName),
baseMidiNote: props.baseMidiNote,
baseFrequency: props.baseFrequency,
relativeIntervals: props.relativeIntervals,
midiOctaveOffset: props.midiOctaveOffset,
labels: props.labels,
Expand Down
4 changes: 0 additions & 4 deletions src/components/modals/export/ReaperExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,6 @@ import type { Interval } from 'sonic-weave'
const props = defineProps<{
newline: string
scaleName: string
baseMidiNote: number
baseFrequency: number
midiOctaveOffset: number
relativeIntervals: Interval[]
scale: Scale
Expand Down Expand Up @@ -39,8 +37,6 @@ function doExport() {
newline: props.newline,
scale: props.scale,
filename: sanitizeFilename(props.scaleName),
baseMidiNote: props.baseMidiNote,
baseFrequency: props.baseFrequency,
midiOctaveOffset: props.midiOctaveOffset,
relativeIntervals: props.relativeIntervals,
labels: props.labels,
Expand Down
6 changes: 3 additions & 3 deletions src/components/modals/generation/ConcordanceShell.vue
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ function generate(shell = true, expand = true) {
}
let postfix = `\\${modal.largeDivisions}`
if (modal.equave.compare(OCTAVE)) {
postfix += `<${linear(modal.equave).toString()}>`
postfix += `ed ${linear(modal.equave).toString()}`
}
for (const [degree, label] of data) {
source += `${degree}${postfix} "${label}"\n`
Expand Down Expand Up @@ -111,11 +111,11 @@ function generate(shell = true, expand = true) {
<label>Error model</label>
<span>
<input type="radio" id="error-rooted" value="rooted" v-model="modal.errorModel" />
<label for="error-rooted"> Rooted </label>
<label for="error-rooted">Rooted</label>
</span>
<span>
<input type="radio" id="error-free" value="free" v-model="modal.errorModel" />
<label for="error-free"> Free </label>
<label for="error-free">Free</label>
</span>
</div>
<div class="control">
Expand Down
Loading

0 comments on commit 754ed9a

Please sign in to comment.