From ce94f17c3905b5d3d8d4e802d8f970bb500f2ff3 Mon Sep 17 00:00:00 2001 From: Lumi Pakkanen Date: Wed, 14 Aug 2024 15:32:26 +0300 Subject: [PATCH] Admit cents as the equave when generating equal temperaments ref #803 --- CHANGELOG.md | 3 +++ cypress/e2e/basic.cy.ts | 16 +++++++++++++++- .../modals/generation/EqualTemperament.vue | 12 +++++++++--- 3 files changed, 27 insertions(+), 4 deletions(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 54870206..5dacf404 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,8 @@ # Change log +## 3.0.2 + * Bug fix: Admit cents as the equave when generating equal temperaments [#803](https://github.com/xenharmonic-devs/scale-workshop/issues/803) + ## 3.0.1 * Feature: Apply CS margin to variety signature on Analysis tab [#796](https://github.com/xenharmonic-devs/scale-workshop/issues/796) * Feature: Approximate Tenney-tall fractions on Analysis tab [#796](https://github.com/xenharmonic-devs/scale-workshop/issues/796) diff --git a/cypress/e2e/basic.cy.ts b/cypress/e2e/basic.cy.ts index 98e369c1..224123e6 100644 --- a/cypress/e2e/basic.cy.ts +++ b/cypress/e2e/basic.cy.ts @@ -52,4 +52,18 @@ describe("Scale generation/modification", () => { cy.get("button").contains("Done").click(); cy.get("#scale-data").should("contain.value", "8/7"); }); -}); \ No newline at end of file + + it("generates and displays 5 equal divisions of 1234.5 cents", () => { + cy.visit("/"); + + cy.get("a").contains("New scale").click(); + cy.get("a").contains("Equal temperament").click(); + cy.get("#equave").clear(); + cy.get("#equave").type('1234.5'); + cy.get("button").contains("OK").click(); + cy.get("#scale-data").should("contain.value", "1\\5 ed 1234.5"); + + // This is how SonicWeave formats "3\5 ed 1234.5" + cy.get('.tuning-table').should("contain", "2469\\4000"); + }) +}); diff --git a/src/components/modals/generation/EqualTemperament.vue b/src/components/modals/generation/EqualTemperament.vue index 2b1c6e95..e7b5aa5d 100644 --- a/src/components/modals/generation/EqualTemperament.vue +++ b/src/components/modals/generation/EqualTemperament.vue @@ -47,11 +47,17 @@ function generate(expand = true) { } } else { const ed = modal.divisions - const ji = modal.equave.toString() if (expand || !modal.simpleEd) { - source = modal.degrees.map((steps) => `${steps}\\${ed}<${ji}>`).join('\n') + try { + // Prefer restricted 7\13<3> form + const ji = modal.equave.toFraction().toFraction() + source = modal.degrees.map((steps) => `${steps}\\${ed}<${ji}>`).join('\n') + } catch { + // Fall back to generic 7\13 ed 1912.3456 form + source = modal.degrees.map((steps) => `${steps}\\${ed} ed ${modal.equave}`).join('\n') + } } else { - source = `tet(${ed}, ${ji})` + source = `tet(${ed}, ${modal.equave})` } } emit('update:source', source)