Jump to content

Featured Replies

Posted

Hi,

 

Does anyone know of a good way to sort a list of pitches so I get a list of all the quartertones and another list of all the semitones?

Or maybe a function that tests if a pitch is within the twelve semitones or not?

 

Thank you

Anders

one solution:

 

(defun split-decimals-and-wholes (lst)
  "Splits the given list into two sublists: one with decimal numbers and one with whole numbers."
  (midi-to-pitch
  (loop for number in (pitch-to-midi lst)
        if (equal (round number) number)
        collect number into wholes
        else
        collect number into decimals
        finally (return (list decimals wholes))))
)

;; Example usage:
(setf pitches '(c4 c4+ cs4 cs4+ d4 d4+ eb4 eb4+))
(split-decimals-and-wholes pitches)



you can maybe provide what exactly output you need:)

  • Author

Very useful. Thank you for your help, this is more or less exactly what I needed.

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