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

Return correct 7th chords from musicutil.generate_chord_scale_degree #1688

Merged
merged 7 commits into from
Jul 15, 2023

Conversation

Dewb
Copy link
Collaborator

@Dewb Dewb commented Jul 13, 2023

Summary:

The musicutil function generate_chord_scale_degree produces incorrect results when you ask for 7th chords, and returns intervals outside the scale. This PR fixes the issue and returns the correct chords, but it makes some breaking changes to the Roman-notation parsing function generate_chord_roman in the process.

Longer explanation:

Yesterday @dstroud mentioned on Discord that he thought some of the 7th chords in the SCALE_CHORD_DEGREES table ought to be half-diminished instead of diminished. I started looking into the issue and found several other problems with the 7th chord sections of this table.

When I added generate_chord_scale_degree to musicutil, the 7th chords feature was kind of an afterthought; I relied on the chord parsing function present in the WesternMusicElements library that musicutil is largely adapted from. Its Roman notation parsing was comprehensive for triads but was incomplete for 7ths, limited to major, minor, diminished, and augmented 7ths, so it wasn't suitable for building a scale degree system without modification of the original algorithm.

In order to generate the correct chords, generate_chord_roman also needs to support half-diminished 7ths (e.g. "viø7"), minor major 7ths ("i♮7"), augmented major 7ths ("III+M7"), and dominant 7ths ("V7"). This necessitates some new notation for the first three ("ø", "♮", "M") and a breaking interpretation of existing notation for the last one.

The current behavior treats all augmented chords as augmented minor, and all capital-letter 7ths as major (rather than major or dominant depending on context, as a lot of notation styles do.) The new behavior allows upper/lowercase to determine major or minor for augmented chords as it does for other chord forms, and assumes that uppercase 7th chords with no aug/dim symbols are dominant unless a "M" suffix is added to specify major. The "M" suffix on an augmented 7th chord now signifies that it's "Augmented Major 7" instead of a regular "Augmented 7" chord. (Both are major triads, but the 7th is raised an additional half-step in the former.)

The new notation is relatively uncontroversial. The natural sign already exists in the default font, but half-diminished needs the O-with-slash glyph to be added.

The breaking changes are a little more concerning. Initial consensus of Discord stakeholders seems to be that since the existing results are not musically correct, breaking it is not an issue.

Another possible solution strategy would be to keep roman chord parsing as is, but make it more contextually aware, so that III7 could return either a major or dominant chord depending on the scale requested. However, it does seem friendlier to users who aren't deeply versed in western music theory, and also friendlier to UI programmers, to have the Roman chord labels be explicit and deterministic.

@Dewb
Copy link
Collaborator Author

Dewb commented Jul 13, 2023

The change to 04B_03__.TTF adds U+00D8 and U+00F8, the uppercase and lowercase O-slash glyphs. I think it is 70% smaller because I used PixelForge instead of FontForge this time around, and it replaced empty glyphs with blank characters rather than boxes. This is probably not desirable so I'll re-apply the changes with FontForge.

@Dewb
Copy link
Collaborator Author

Dewb commented Jul 15, 2023

In a side discussion with @dstroud we came to the conclusion that it made sense to require an M to disambiguate Augmented Major 7 from Augmented 7th, like the M to disambiguate Major 7 from Dominant 7. In addition to being consistent it also eliminates one of the two breaking changes to generate_chord_roman (requests for chords like "III+" will continue to return Augmented 7 like they did before.) Updated the PR description a bit to reflect this.

Also reprocessed the font glyph additions with FontForge instead of PixelForge to restore the missing box-glyphs for unused characters, and re-ran the internal offline script to update the chord tables inside SCALES (since CHORDS was modified to add the Augmented Major 7 chord.)

@tehn
Copy link
Member

tehn commented Jul 15, 2023

thank you for putting the time in on this!

@tehn tehn merged commit ab42654 into monome:main Jul 15, 2023
tehn added a commit that referenced this pull request Sep 27, 2023
* add PSET number to PSET actions + add delete action (#1544)

* add PSET number to callbacks + add delete callback

* fix passing pset_number in delete action

* Revert "fix passing pset_number in delete action"

This reverts commit 7f98bb2.

* fix pset_number in read action

* clean up formatting

* remove unnecessary nil checks

* update paramset docs

* fix parameter name passing to params:delete

* add pset_number to docs

* releases.txt

* remove nonexistent post_filter_fc_mod command from softcut param factory

* Update pmap.lua

* typo fix (#1560)

* fix registration for screen_display_image_region

* Update readme.md

* add note to readme regarding release flag

* use abl_link C API for link clock

* init session state

* add param separators to lookup table (#1539)

* add param separators to lookup table for hide/show

* add unnamed failsafe

* add visibility lookup for strings

* fix name forcing

* cleanup DSP 'lab work' folder (#1580)

* add script-definable action for when clock tempo changes (#1575)

* add clock.temo_changed callback

* clean up naming

* reset handler when clocks are cleaned up

* fold in artem's feedback

* remove 'source' pass, remove redundant nils

* params: align 'add_separator' and 'add_group' flow with other paramtypes (#1584)

* protect against casual param naming

* protect groups, too

* add error message

* change separator and group addition

* specify overwrite conditions

* overwrite flag allows for continuity for param count

* allow hidden param to be registered

* add parameter-based lfo scripting library (#1585)

* initial upload + unload lfo's after use

* default = 'param action' and track fn mapping

* add function type lookup table

* add ldoc notes

* bars -> clocked

* no spaces in param IDs

* remove 'frm', not used

* rename library to 'param_lfo'

* rename to 'param-lfo'

* p_lfo -> plfo

just cosmetic, but looks way better

* apply menu password entry to SMB + hotspot (#1570)

* unify smb + hotspot password change

* Update link

* Revert "Update link"

This reverts commit 55fff78.

* Revert "Merge branch 'main' into password-helper"

This reverts commit 66fe798, reversing
changes made to 651d7c0.

* Revert "Revert "Merge branch 'main' into password-helper""

This reverts commit b797f04.

* maiden inaccessible

* robust message for hotspot password change

* fix to add midi data when device is removed (issue #1557)  (#1562)

* typo fix

* fix to add midi data when device is removed (issue #1557)

code fixed and doc info updated for issue #1557: #1557

* Place downbeats correctly.

Without this change, a swing of 66 will shift some events early and some events late from where they would otherwise be. With this change, a swing of 66 leaves some beats alone, and shifts other beats late from where they would otherwise be. 

Example to evaluate change, run as a norns script:

```
engine.name = "PolyPerc"
local lattice = require("lattice")

function init()
    l = lattice:new()
    p1 = l:new_pattern{
        enabled = true,
        division = 1/4,
        action = function(t)
            print("q", t)
            engine.hz(440) 
        end,
    }
    p2 = l:new_pattern{
        enabled = true,
        division = 1/8,
        swing = 66,
        action = function(t)
            print("e", t)
            engine.hz(660)
        end,
    }
    l:start()
end
```

In this example, the expected behavior is that two events (440 and 660) fall on the "down" beat, and then one (660) falls on the "up" beat, but with a "triplet feel". Without the change we get the "eighth notes" falling before and after the quarter note, but not on it.

* Revert "add parameter-based lfo scripting library (#1585)" (#1588)

This reverts commit 221531a.

* Revert "fix to add midi data when device is removed (issue #1557)  (#1562)" (#1589)

This reverts commit a808394.

* add 'lfo' (#1591)

* add lib/lfospec

a general-purpose scripting library for establishing LFOs, with optional parameter UI control

* add lfospec attributions

* protect against nil IDs

* add note about clocks + start/stop with parameter menu

* update params per entry

* Use lattice for LFOs, so they share clocks, and allow setting ppqn

* attribution and unused var cleanup

* change name and fold in feedback

* register 'norns.lfo' table, manage from script.lua

* Update script.lua

* check for nil norns.lfo

* remove note about clocks

since using lattice, there's no worry about counting clocks

* add API text to LFO:add

okay, this is the last touch! sorry for all the final countdown updates 😬

Co-authored-by: Naomi Seyfer <naomi@seyfer.org>

* execute global Midi.remove callback (#1590)

this runs the global, customizable midi device removal callback when a device is unplugged (if the device is registered by the norns midi system), in addition to and without affecting the per-device removal callback (if defined.)

alternative to PR #1562, addressing issue #1557

* 220802

* releases.txt

* hotfix: lfo `:add` (#1593)

* hotfix: lfo `:add`

gah! the `:add` method wasn't properly invoking the `.new` function

* Update lfo.lua

* rest of the lfo hotfix (#1594)

* hotfix: lfo `:add`

gah! the `:add` method wasn't properly invoking the `.new` function

* Update lfo.lua

* Update lfo.lua

* releases.txt

* gamepad support (#1439)

* basic gamepad support w/ whitelist

* basic support for gamepad in global menu

* fix missing clear callback

* handling of analog joysticks & numeric dpads

* optim: faster lookup of event code 2 axis

* (cont.)

* fix bad name for axis properties

* bug fixes, catchall axis callback vs dpad/apad

* rename `apad` into `astick` (analog stick)

* mark dpad as naalog for bufalo model, fix typo

* do not debug log

* do not add separators to PSET file (#1598)

* fixed screen curve param descriptions (#1603)

* Update paramset.lua (#1605)

* expand acceptable accum CC values (#1606)

a tiny change that allows controllers to send any CC value above 64 for "up" and any below for "down". previously it had to just be 65 and 63 which isn't supported by all controllers.

* add TAPE previewing to fileselect (#1607)

* add previewing to fileselect

* working

* stop previewing on key and always on left scroll

* Tweaks to the keyboard (#1611)

* handle osc messages for the keyboard

* change parameters with +/- keys

* allow holding key to scroll menu

* toggle menu with F5 key

* goto menu if F1-4 are pressed

* add version error (#1613)

* add previewing to fileselect

* working

* stop previewing on key and always on left scroll

* add version error message

* working

* address issue #1612 (#1617)

adds a call to the script-defined `clock.tempo_change_handler` function whenever the `clock_tempo` parameter is changed in the parameters UI from an external source

* work on lattice v2 (#1616)

* work on v2

* preserve 'new_pattern' for backwards-compatibility

* quarter note is good actually lol

* incorporate tyler's comments

* docblock, comments, and semantic changes

Co-authored-by: Tyler Etters <tyler@etters.co>

* fix `_menu.keychar` not getting called (#1619)

* prevent global menu shortcut messing up w/ sub-menu's (#1620)

* fix undefined `gamepad` when `script.clear` gets called (#1621)

* fix: document sprocket ordering (#1625)

* update lfo lib to use lattice sprockets (#1626)

* add password length failsafes for WPA-PSK (#1627)

WPA-PSK requires a sequence between 8 and 63 ASCII characters, so if a user uses this prompt to change their password to something shorter, then they won't be able to access hotspot (due to the conveniences added by #1570).

to help guardrail, this commit adds:
- an on-screen `textentry` check which shows a countdown to 8 characters and a warning if the password goes beyond 63
- a character count check to `m.passdone`, which will only change all passwords if the string length is >= 8 and < 64, otherwise it prints warnings to maiden that the password has not been changed

* 221214

* releases.txt

* update.sh fix

* update docs

* releases.txt

* `new_pattern` was missing return keyword (#1629)

* lfo fixes + improvements (#1630)

fixed locally global variables for `scaled_min` / `scaled_max`, `mid`, and `rand_value`, which interfered with square and random waves when multiple LFOs were running with different min/max values.

added `mid: rising` and `mid: falling` as options for the `reset_target`, which allows more control over how the reset affects the starting value

* add osc.cleanup() to script.lua (#1643)

* allow sending midi clock to all devices simultaneously (#1642)

* Add files via upload

* toggles for targeting device clock out

builds out @tehn's feedback from #1642 :
- any currently-ported midi device will populate in the 'midi clock out' section of 'PARAMS > CLOCK'
- each visible entry has a toggle to receive norns clock
- toggles get saved/restored as part of `system.state` during clean reboots

follow the approach brian outlined actually saves us from doing any if's during each clock tick!

* longer short name

cleaned up formatting to match the SYSTEM > DEVICES > MIDI syntax, which allows for up to 20 characters to display comfortably before aliasing

Co-authored-by: dan derks <derks.dan@gmail.com>

* fix lattice transport value getting increased in steps of 5 (#1638)

* fix lattice ppqn resolution divded by 5

* order sprockets once per pulse

* Make maiden-repl compile on macOS 13.1 Ventura (#1645)

* Change wrap to use math instead of iteration, and happen in constant time (#1577)

* clean up device callbacks (#1646)

* remove unnecessary _menu.rebuild_params() (#1647)

this gets called elsewhere throughout the stack (including MIDI device add/remove), which makes this unnecessary -- it also seems to cause race-condition conflicts as the rebuild attempts to index parameters which don't yet exist

* Update device_midi.c

blind fix attempt for dropped sysex bytes

* fix typo (want stop byte not start byte)

* Add UK keyboard option. (#1651)

* Remove error from unknown key press. (#1654)

* fix argument indices for buffer_clear_region_channel (#1656)

this is a blind fix attempt for issue #1652

* lua NRT processing function (#1634)

* not working

* still not working

* first draft

* fix typo

* refactor: attempt to pass buffer data rather than function

* catch silly typo

* process_chunk should match OscInterface.cpp

* working! refactor to allow longer sections to be processed

* fix errors

* catch typos

* refactor to use shared memory

* attempt to not cause stack overflow, fix wscript so norns ./wafs correctly

* catch typo, add debug prints

* attempt to prevent poke failing to open shared memory

* strange not-working place

* catch small typo, add debug print

* attempt to prevent error on second call to process

* working

* refactor to use clocks to chunk up softcut_process

* fix weaver bugs, change lua API

* fix: catch typo

* Update docs for screen.fill() and screen.stroke(). (#1660)

* new crow4 features on norns (#1662)

* run ldoc

* regenerate docs

* better separator labeling in core params (#1665)

* better separator labeling

* Update audio.lua

* reduce 'send_midi_clock' var scope (#1666)

during release testing, i realized that after my ~40th script load, `clock.sync` calls were off by a tenth of a beat, compounding as i continued to load scripts.

when i verified #b932b0d sparked the issue's emergence, i realized that the `send_midi_clock` table was being added to each time `clock.add_params()` was called, but never emptied out. so, eventually, the clock was doing 24ppqn calls on a table with *tons* of entries.

i guess nice to accidentally stress-test that a lot of devices could receive MIDI clock before timing issues emerged? anyway, fixed now!

* Implement character/key conversion (#1659)

* Implement character/key conversion.

* Remove char_to_code().

* [mergeable] rework `gamepad` to handle more edge-cases (#1624)

* rework gamepad to handle more edge-cases

* woops

* SDL-format GUID generation for HID devices

* (cont., missed this one binding)

* use this new GUID as id in known controller models table

* add guid in controller conf, some 8bitdo masquerade as xbox 360

* log guid

* actually use guid in `gamepad.process` callback

* analog btn support, fix std order X axis, no meta btn state

* fix value of sign in gamepad.axis() when analog button

* remove dead code

* re-introduce denoize for analog buttons, comments

* call gamepad.analog after computing state

* on sensors, negative half is generally 1+ bigger than positive one

* tweak submenu integration

* disable verbose mode

* prevent trigger script cb if in menu, add _menu.analog

* prefix all new `menu` callbacks w/ `gamepad_`

* rounding the half-reso may be counter-intuitive, document instead

* sometimes lower half bigger, sometimes upper one...

* fix actual resolution for this controller

* be resilient against "lean" config files (w/ empty maps ommited)

* add system/settings menu, move items, add battery_warning (#1668)

* add system/settings menu, move items, add battery_warning

* yikes booleans

* fixes

* export png (#1669)

* changelog

* norns.expand_filesystem() (#1670)

* Update norns.lua

* Update norns.lua

* releases.txt

* allow user to add gamepad profiles without tempering w/ core (#1671)

* allow user to add gamepad models without tempering w/ core

* more explicit var names

* Revert "lua NRT processing function (#1634)" (#1673)

This reverts commit 0c06b09.

* changelog

* releases.txt

* Update settings.lua (#1675)

* revert export_png and rename export_screenshot (#1676)

* changelog, version, releases.txt

* releases.txt

* fix: softcut.voice_sync order documentation

softcut's `voice_sync` command has its arguments reversed in the API docs

* add fade_time correction, as well!

* fix fade_time parameter names

* add filters to fileselect (#1678)

* add filters to fileselect

* Update fileselect.lua

* remove whitespace

* fix midi clock double-tap (#1680)

* changelog, version

* update.sh ancient typo

* Update releases.txt

* fix #1681 (#1682)

ah! i had totally spaced on the auto-shortening of long filenames by appending '...', which confused the "is this a file or is this a folder?" mechanism! this is now fixed + and i will ask for community testing!

* 230614

* changelog

* releases.txt beta

* releases.txt stable

* Return correct 7th chords from musicutil.generate_chord_scale_degree  (#1688)

* Support half-diminished chords and correct scale degrees

* Add remaining missing 7th chords to roman notation: dominant, minor major, augmented major

* Use M decorator for Augmented Major 7, expand docs

* More docstring tweaks

* Update scale chord tables for Augmented Major 7 (27)

* Add new glyphs with FontForge instead of PixelForge

* Add alt_names Min7b5 and Maj7#5 for consistency w/teletype

* Ensure that disk field can represent size of larger sd cards (#1690)

Co-authored-by: Chris Aquino <aquino.chris@pm.me>

* lfo library: v2 (#1692)

* 'saw' -> 'tri', add 'up' and 'down', fix init

* build params from lfo spec

* add phase

* tune 'RESTART' (#1695)

* midi mapping touchups (#1696)

* fix user gamepad profile lookup + new model (#1697)

* fix: user-defined gamepad profile lookup

* new gamepad model: Retrolink B00GWKL3Y4

* more info

* disable hciuart in update (#1700)

* make variable y in util.wrap local (#1704)

* fix: debounce tape preview in fileselect (closes #1628) (#1703)

---------

Co-authored-by: dan derks <derks.dan@gmail.com>
Co-authored-by: brian crabtree <tehn@nnnnnnnn.co>
Co-authored-by: zbs <86270534+zjb-s@users.noreply.github.com>
Co-authored-by: Jonathan Snyder <52048666+jaseknighter@users.noreply.github.com>
Co-authored-by: Greg Wuller <greg@afofo.com>
Co-authored-by: Tyler Etters <tyleretters@users.noreply.github.com>
Co-authored-by: Artem Popov <artfwo@gmail.com>
Co-authored-by: Naomi Seyfer <naomi@seyfer.org>
Co-authored-by: Jordan Besly <11557146+p3r7@users.noreply.github.com>
Co-authored-by: Tom Waters <github@random-works.co.uk>
Co-authored-by: Rylee Alanza Lyman <46907231+ryleelyman@users.noreply.github.com>
Co-authored-by: Zack <zack.scholl@gmail.com>
Co-authored-by: Tyler Etters <tyler@etters.co>
Co-authored-by: kasperbauer <kasperbauer@users.noreply.github.com>
Co-authored-by: Anders Östlin <anders.ostlin@gmail.com>
Co-authored-by: Nik Silver <nik@niksilver.com>
Co-authored-by: trent <trent.gill@gmail.com>
Co-authored-by: brian crabtree <tehn@monome.org>
Co-authored-by: Michael Dewberry <michael.dewberry@gmail.com>
Co-authored-by: Chris Aquino <chris@thunderbird.net>
Co-authored-by: Chris Aquino <aquino.chris@pm.me>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants