Jump 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.

Featured Replies

Is there a function that returns all intervals from a chord?

Thanks, Achim

just tried in 3min. ouput correct or perhaps some BUGs in thinking? 😁

greetings

andré

 

(defun get-all-intervals (alist)
  (let ((alist (sort-asc (flatten (pitch-to-midi (if (chordp alist)
                                            (melodize alist)
                                          alist))))))
    (rest (sort-asc (remove-duplicates
     (loop repeat (length alist)
           for cnt = 0 then (incf cnt)
           append (x-b (filter-last (- (length alist) cnt) alist) (nth cnt alist))))))))


(get-all-intervals '(c4 d4 e4))
=> (2 4)

(get-all-intervals '(c4d4e4f6))
=> (2 4 25 27 29)

 

(pitch-to-interval '(c4d4e4f6))

 

different approach...

 

(pitch-to-interval '(c4d4e4f6)) => intervals between neighbours

(get-all-intervals '(c4d4e4f6)) => all intervals INSIDE the chord (between all pitches)

 

Would this be okay, too?

 

For getting the intervals of  notes related to the first note.

 

(defun chordintervals (chord)
(x-b (pitch-to-midi (pitch-melodize chord)) 
     (pitch-to-midi (first (pitch-melodize chord))))
)

 

melodize instead of pitch-melodize works too, but is not listed under functions.

Is that LISPier?  Does the same as last post.

 

(defun chordintervals (chord)
  (let* ((midimelo (pitch-to-midi (pitch-melodize chord)))
            (chordroot (first midimelo)))
          (x-b midimelo chordroot)))

 

(chordintervals '(c4d4e4g4c5))
(chordintervals '(c4 d4 e4 g4 c5))

both return => (0 2 4 7 12)

And another way:

(defun chordintervals (chord &key ( named nil))
  (let* ((midimelo (pitch-to-midi (pitch-melodize chord)))
         (chordroot (first midimelo))
         (numbers (x-b midimelo chordroot))
         (names (cons 'base-note (rest (get-interval-name numbers)))))
      (if (equal named t) names numbers) ))

(chordintervals '(c4d4e4g4c5))
=>(0 2 4 7 12)

(chordintervals '(c4d4e4g4c5) :named t )
=>(base-note major-second major-third perfect-fifth perfect-octave)

(chordintervals '(c4 d4 e4 g4 c5))
=>(0 2 4 7 12)

(chordintervals '(c4 d4 e4 g4 c5) :named t)
=>(base-note major-second major-third perfect-fifth perfect-octave)

 

I hope I understood the original post correct.

Create an account or sign in to comment


Copyright © 2014-2025 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

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.