Skip to content
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

Use SonicWeave scale title #665

Merged
merged 1 commit into from
Apr 25, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 5 additions & 5 deletions package-lock.json

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

4 changes: 2 additions & 2 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.17",
"version": "3.0.0-beta.18",
"scripts": {
"dev": "vite",
"build": "run-p type-check \"build-only {@}\" --",
Expand All @@ -21,7 +21,7 @@
"moment-of-symmetry": "^0.4.2",
"pinia": "^2.1.7",
"qs": "^6.12.0",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.22",
"sonic-weave": "github:xenharmonic-devs/sonic-weave#v0.0.23",
"sw-synth": "^0.1.0",
"temperaments": "^0.5.3",
"values.js": "^2.1.1",
Expand Down
14 changes: 7 additions & 7 deletions src/character-palette.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,10 +11,8 @@
"½": "Semi-prefix. E.g. G semisharp four <code>G½♯4</code>, semimajor third <code>½M3</code>, neutral sesquith <code>n1½</code>.",
"¼": "Quarter-prefix. E.g. E quarter flat four <code>E¼♭4</code>.",
"¾": "Sesqui-semi-prefix. E.g. D sesqui semisharp four <code>D¾♯4</code>.",
"⅛": "Eighth-prefix. E.g. Gamma eighth flat four <code>γ⅛♭4</code>.",
"⅜": "Three eighths-prefix. E.g. Three eighths diminished third and a halfth <code>⅜d3.5</code>.",
"⅝": "Five eighths-prefix.",
"⅞": "Seven eighths-prefix.",
"⅓": "One-third-prefix. E.g. Third-major second <code>⅓M2</code>.",
"⅔": "Two-thirds-prefix. E.g. E two-thirds flat four <code>E⅔♭4</code>.",
"×": "Times symbol. E.g. <code>4/3 × 4/3</code> is <code>16/9</code>.",
"÷": "Division symbol. E.g. <code>9/8 ÷ 81/80</code> is <code>10/9</code>.",
"·": "Dot product. E.g. <code>3/2 · 12@</code> is <code>7</code> i.e. a fifth is seven steps of 12-tone equal temperament.",
Expand All @@ -34,7 +32,9 @@
"ω": "Semiquartal nominal omega. <code>ω4</code> is a semifourth below <code>D5</code>.",
"¤": "Semiquartal accidental scarab ≈ +158.8¢. <code>F¤4</code> is a semifourth below <code>A4</code>.",
"£": "Semiquartal accidental pound ≈ -158.8¢. <code>A£4</code> is a semifourth above <code>F4</code>.",
"¢": "Cent. <code>¢</code> is equal to <code>1\\1200</code>.",
"€": "Reciprocal cent. <code>¢ · €</code> is <code>1</code>.",
"µ": "Metric prefix micro. E.g. Period of oscillation <code>2000 µs</code> corresponds to frequency of oscillation <code>500 Hz</code>."
"¢": "Cent. <code>1¢</code> is equal to <code>1\\1200</code>.",
"€": "Reciprocal cent. <code>1¢ · €</code> is <code>1</code>.",
"µ": "Metric prefix micro. E.g. Period of oscillation <code>2000 µs</code> corresponds to frequency of oscillation <code>500 Hz</code>.",
"⟨": "Val angle bracket. <code>⟨12 19 28]</code>.",
"⟩": "Monzo angle bracket. <code>[-4 4 -1⟩</code>."
}
8 changes: 2 additions & 6 deletions src/components/ExporterButtons.vue
Original file line number Diff line number Diff line change
Expand Up @@ -42,14 +42,13 @@ function copyToClipboard() {
function doExport(exporter: ExporterKey) {
const params: ExporterParams = {
newline: state.newline,
name: scale.name,
scaleUrl: window.location.href,
filename: sanitizeFilename(scale.name),
filename: sanitizeFilename(scale.scale.title),
relativeIntervals: scale.relativeIntervals,
scale: scale.scale,
labels: scale.labels,
midiOctaveOffset: -1,
description: scale.name,
description: scale.scale.title,
sourceText: scale.sourceText,
appTitle: APP_TITLE,
date: new Date()
Expand All @@ -65,7 +64,6 @@ function doExport(exporter: ExporterKey) {
@confirm="showKorgExportModal = false"
@cancel="showKorgExportModal = false"
:newline="state.newline"
:scaleName="scale.name"
:relativeIntervals="scale.relativeIntervals"
:midiOctaveOffset="-1"
:scale="scale.scale"
Expand All @@ -77,7 +75,6 @@ function doExport(exporter: ExporterKey) {
@confirm="showMtsSysexExportModal = false"
@cancel="showMtsSysexExportModal = false"
:newline="state.newline"
:scaleName="scale.name"
:relativeIntervals="scale.relativeIntervals"
:midiOctaveOffset="-1"
:scale="scale.scale"
Expand All @@ -89,7 +86,6 @@ function doExport(exporter: ExporterKey) {
@confirm="showReaperExportModal = false"
@cancel="showReaperExportModal = false"
:newline="state.newline"
:scaleName="scale.name"
:relativeIntervals="scale.relativeIntervals"
:midiOctaveOffset="-1"
:scale="scale.scale"
Expand Down
3 changes: 1 addition & 2 deletions src/components/modals/export/KorgExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type { Scale } from '@/scale'

const props = defineProps<{
newline: string
scaleName: string
midiOctaveOffset: number
relativeIntervals: Interval[]
labels: string[]
Expand Down Expand Up @@ -48,7 +47,7 @@ async function doExport() {
scale: props.scale,
relativeIntervals: props.relativeIntervals,
labels: props.labels,
filename: sanitizeFilename(props.scaleName),
filename: sanitizeFilename(props.scale.title),
midiOctaveOffset: props.midiOctaveOffset
}

Expand Down
8 changes: 3 additions & 5 deletions src/components/modals/export/MtsSysexExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ import type { Interval } from 'sonic-weave'

const props = defineProps<{
newline: string
scaleName: string
midiOctaveOffset: number
relativeIntervals: Interval[]
scale: Scale
Expand All @@ -27,14 +26,14 @@ function clampName(name: string): string {
return name.slice(0, 16)
}

const name = ref(clampName(props.scaleName))
const name = ref(clampName(props.scale.title))

function nameInputCallback(nameInput: string): void {
name.value = clampName(nameInput)
}

watch(
() => props.scaleName,
() => props.scale.title,
(newName) => nameInputCallback(newName),
{ immediate: true }
)
Expand All @@ -55,11 +54,10 @@ function doExport() {
const params: ExporterParams = {
newline: props.newline,
scale: props.scale,
filename: sanitizeFilename(props.scaleName),
filename: sanitizeFilename(props.scale.title),
relativeIntervals: props.relativeIntervals,
midiOctaveOffset: props.midiOctaveOffset,
labels: props.labels,
name: name.value,
presetIndex: parseInt(presetIndex.value)
}

Expand Down
3 changes: 1 addition & 2 deletions src/components/modals/export/ReaperExport.vue
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,6 @@ import type { Interval } from 'sonic-weave'

const props = defineProps<{
newline: string
scaleName: string
midiOctaveOffset: number
relativeIntervals: Interval[]
scale: Scale
Expand All @@ -36,7 +35,7 @@ function doExport() {
const params: ExporterParams = {
newline: props.newline,
scale: props.scale,
filename: sanitizeFilename(props.scaleName),
filename: sanitizeFilename(props.scale.title),
midiOctaveOffset: props.midiOctaveOffset,
relativeIntervals: props.relativeIntervals,
labels: props.labels,
Expand Down
2 changes: 1 addition & 1 deletion src/components/modals/generation/StackSteps.vue
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ function computeTotal() {
const updateTotal = debounce(computeTotal)

function generate(expand = true) {
const source = scaleData.value + '\nstack()\ni => simplify(i) if isLinear(i) else i'
const source = scaleData.value + '\nstack()'
if (expand) {
emit('update:source', expandCode(source))
} else {
Expand Down
12 changes: 6 additions & 6 deletions src/exporters/__tests__/korg.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,11 +11,11 @@ import { Interval, TimeReal } from 'sonic-weave'
describe('Korg exporters', () => {
it('can export a scale encountered while debugging issue #393', async () => {
const params = getTestData("Korg 'logue exporter unit test")
params.baseMidiNote = 60
params.scale = new Scale(
[...Array(12).keys()].map((i) => 24 / (23 - i)),
256,
60
60,
'Test Scale'
)

const exporter = new KorgExporter(params, KorgModels.MINILOGUE, false)
Expand Down Expand Up @@ -86,7 +86,7 @@ describe('Korg exporters', () => {
params.relativeIntervals.push(new Interval(TimeReal.fromCents(100.0), 'logarithmic'))
params.sourceText += '\n100.'
const ratios = params.relativeIntervals.map((i) => i.value.valueOf())
params.scale = new Scale(ratios, 440, 69)
params.scale = new Scale(ratios, 440, 69, 'Test Scale')
expect(() => new KorgExporter(params, KorgModels.MINILOGUE, true)).toThrowError(
KorgExporterError.OCTAVE_INVALID_EQUAVE
)
Expand All @@ -110,7 +110,7 @@ describe('Korg exporters', () => {
params.sourceText += '100.\n' + params.sourceText
}
const ratios = params.relativeIntervals.map((i) => i.value.valueOf())
params.scale = new Scale(ratios, 440, 69)
params.scale = new Scale(ratios, 440, 69, 'Test Scale')

expect(() => new KorgExporter(params, KorgModels.MINILOGUE, true)).toThrowError(
KorgExporterError.OCTAVE_INVALID_INTERVAL
Expand All @@ -127,7 +127,7 @@ describe('Korg exporters', () => {
params.sourceText += '100.\n' + params.sourceText
}
const ratios = params.relativeIntervals.map((i) => i.value.valueOf())
params.scale = new Scale(ratios, 440, 69)
params.scale = new Scale(ratios, 440, 69, 'Test Scale')

expect(() => new KorgExporter(params, KorgModels.MINILOGUE, true)).toThrowError(
KorgExporterError.OCTAVE_INVALID_INTERVAL
Expand All @@ -143,7 +143,7 @@ describe('Korg exporters', () => {
params.sourceText += '100.\n' + params.sourceText
}
const ratios = params.relativeIntervals.map((i) => i.value.valueOf())
params.scale = new Scale(ratios, 440, 69)
params.scale = new Scale(ratios, 440, 69, 'Test Scale')

const exporter = new KorgExporter(params, KorgModels.MINILOGUE, true)
const [zip, fileType] = exporter.getFileContents()
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/__tests__/mts.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ describe('MTS exporter', () => {

it('can gracefully handle invalid parameters', async () => {
const params = getTestData('MTS Sysex Bulk Tuning Dump exporter unit test v0.0.0')
params.name = 'Super Special Test Scale'
params.scale.title = 'Super Special Test Scale'
params.presetIndex = -1

const exporter = new MtsSysexExporter(params)
Expand Down
3 changes: 1 addition & 2 deletions src/exporters/__tests__/test-data.ts
Original file line number Diff line number Diff line change
Expand Up @@ -68,12 +68,11 @@ export function getTestData(appTitle: string) {
})
]
const ratios = relativeIntervals.map((i) => i.value.valueOf())
const scale = new Scale(ratios, 440, 69)
const scale = new Scale(ratios, 440, 69, 'Test Scale')
const params: ExporterParams = {
filename: 'test',
newline: process.platform === 'linux' ? UNIX_NEWLINE : WINDOWS_NEWLINE,
scaleUrl: 'https://scaleworkshop.plainsound.org/',
name: 'Test Scale',
relativeIntervals,
scale,
appTitle,
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/ableton.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ export default class AbletonAsclExporter extends BaseExporter {

constructor(params: ExporterParams) {
super(params)
this.name = params.name || 'Untitled tuning'
this.name = params.scale.title || 'Untitled tuning'
this.appTitle = params.appTitle || APP_TITLE
}

Expand Down
2 changes: 1 addition & 1 deletion src/exporters/anamark.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ class AnaMarkExporter extends BaseExporter {

// Comment section
let file = '; VAZ Plus/AnaMark softsynth tuning file' + newline
file += '; ' + this.params.name + newline
file += '; ' + this.params.scale.title + newline
file += ';' + newline

// If version 200 or higher, display the scale URL so user can easily get back to the original scale that generates this tun file.
Expand Down
1 change: 0 additions & 1 deletion src/exporters/base.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@ export type ExporterParams = {
midiOctaveOffset: number
scale: Scale
labels: string[]
name?: string
scaleUrl?: string
description?: string
sourceText?: string // May contain invalid lines
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/kontakt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class KontaktExporter extends BaseExporter {

// assemble the kontakt script contents
let file = '{**************************************' + newline
file += this.params.name + newline
file += this.params.scale.title + newline
file +=
'MIDI note ' +
baseMidiNote.toString() +
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/korg.ts
Original file line number Diff line number Diff line change
Expand Up @@ -178,7 +178,7 @@ export class KorgExporter extends BaseExporter {
const tuningInfo = this.getTuningInfoXml(
this.modelName,
'ScaleWorkshop',
this.params.name ?? ''
scale.title
)
const fileInfo = this.getFileInfoXml(this.modelName)
const [fileNameHeader, fileType] = this.useOctaveFormat
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/max-msp.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class MaxMSPExporter extends BaseExporter {
'# Tuning file for Max/MSP coll objects. - Created using ' +
this.appTitle +
this.params.newline
file += '# ' + this.params.name + this.params.newline
file += '# ' + this.params.scale.title + this.params.newline
file += '#' + this.params.newline
file += '# ' + this.params.scaleUrl + this.params.newline
file += '#' + this.params.newline
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/mts-sysex.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ export default class MtsSysexExporter extends BaseExporter {
}

getNameData() {
let name = this.params.name ?? ''
let name = this.params.scale.title
while (name.length < 16) {
name += ' '
}
Expand Down
2 changes: 1 addition & 1 deletion src/exporters/scala.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ export class ScalaSclExporter extends BaseExporter {

constructor(params: ExporterParams) {
super(params)
this.name = params.name || 'Untitled tuning'
this.name = params.scale.title || 'Untitled tuning'
this.appTitle = params.appTitle || APP_TITLE
}

Expand Down
4 changes: 3 additions & 1 deletion src/scale.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,17 +5,19 @@ export class Scale {
intervalRatios: number[]
baseFrequency: number
baseMidiNote: number
title: string

/**
* Construct a new musical scale.
* @param intervalRatios Intervals of the scale excluding 1/1, ending with the interval of equivalence.
* @param baseFrequency Base frequency of 1/1.
* @param baseMidiNote MIDI note corresponfing to base frequency
*/
constructor(intervalRatios: number[], baseFrequency: number, baseMidiNote: number) {
constructor(intervalRatios: number[], baseFrequency: number, baseMidiNote: number, title: string) {
this.intervalRatios = intervalRatios
this.baseFrequency = baseFrequency
this.baseMidiNote = baseMidiNote
this.title = title
}

/** Number of intervals in the scale. */
Expand Down
Loading
Loading