Skip to content
View in the app

A better way to browse. Learn more.

Opusmodus

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Recursive Function for finding complementary set of notes in Chord/Scale relationship

Featured Replies

Hey, people !

 

I´m doing a function to extract the complementary set of notes.

For example:

 

1) Specify a set of notes, like a chord, Dm7

 

(setf note-list '(d5 f5 a5 c6))

 

Specify a tonality, like Cmajor or D dorian (same notes)

(expand-tonality '(c5 major))

 

Now, I want a function that gives me all the other available notes from the mode, except the chord tones (the first set of notes).

 

So, this function gives me exactly what I need (for ONE tonality at a time and ONE chord at a time):

 

(let ((rem (expand-tonality '(c5 major)))
      (super (ambitus '(c5 b5) note-list)))
  (loop for i in super
    do (setf rem (remove i rem))
    finally (return rem)))

 

Ok, this give me the right result, I.E., the complementary set of notes of C major in relation to Dm7

=> (e5 g5 b5)

 

The question is simple:

 

How can I do it for a list with many tonalities and many chords. How to do this recursively in nested lists, like

 

(setf note-list '((d5 f5 a5 c6)(eb4 gb4 bb4 db4)(fs4 as4 cs4)))

 

to sucessive tonalities, like:

(expand-tonality '((c5 major) (db4 major) (gb4 major)))

 

Since this WON´T work

 

(let ((rem (ambitus '(c5 b5) (expand-tonality '((c5 major) (db5 major) (gb5 major)))))
      (super (ambitus '(c5 b5) '((d5 f5 a5 c6)(eb4 gb4 bb4 db4)(fs4 as4 cs4)))))
  (loop for i in super
    do (setf rem (remove i rem))
    finally (return rem)))

 

The expected result, if the above worked would be:

 

 ((e5 g5 b5)  (f5 ab5 c5) (gs4 cb5 ds5))

 

Thanks in advance !!

 

Best !

Julio

Loop in the loop:

 

(let ((rem (ambitus '(c5 b5) (expand-tonality '((c5 major) (db5 major) (gb5 major)))))
      (super (ambitus '(c5 b5) '((d5 f5 a5 c6) (eb4 gb4 bb4 db4) (fs4 as4 cs4)))))
  (loop for s in super
    for r in rem
    collect (loop for i in s
              do (setf r (remove i r))
              finally (return r))))
  • Author

Thanks, Janusz

 

This could implemented as a native function, like

 

FILTER-SET

 

A general function to filter sets out of sets.

 

Best,

Julio

  • 4 years later...
  • Author

This function FILTER-SET would be interesting in the core set of functions !

Still coming back to this from time to time when working with pcs sets.

Best !

Julio

Here’s one of my functions that I use for that:

;;; FIND-PITCH-COMPLEMENT

;;; ------------------------

(defun find-pitch-complement (omn &key (keep-octaves nil))

"Renvoie le complement de hauteurs d'une expression omn."

(do-verbose ("find-pitch-complement")

(let* ((pch (ambitus '(0 11) (melodize (omn :pitch omn))))

(itg (pitch-to-integer pch))

(cpl (find-complement itg :low 0 :high 11))

(pcpl (integer-to-pitch cpl))

)

(if keep-octaves

(octave-map omn pcpl)

pcpl))))

#| USAGE EXAMPLE

(setf omn1 (length-legato

(gen-filter-euclidean

12

16

7 14

(vector-to-pitch '(c4 c6)(gen-noise 32))

's :seed 34)))

(setf omn2

(make-omn

:pitch (chordize (find-pitch-complement omn1))

:length (length-span (get-span omn1) '((w)))

:velocity '(mf)))

(ps 'gm

:fl (list omn1)

:pg (list omn2)

)

|#

Create an account or sign in to comment


Copyright © 2014-2026 Opusmodus™ Ltd. All rights reserved.
Product features, specifications, system requirements and availability are subject to change without notice.
Opusmodus, the Opusmodus logo, and other Opusmodus trademarks are either registered trademarks or trademarks of Opusmodus Ltd.
All other trademarks contained herein are the property of their respective owners.

Powered by Invision Community

Important Information

Terms of Use Privacy Policy

Account

Navigation

Search

Search

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.