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.

harmonics function

Featured Replies

Using this expression

(harmonics 'a2 8 :quantize nil :type :hertz)

I am getting

(110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0)

but I am expecting

(110.0 220.0 330.0 440.0 550.0 660.0 770.0 880.0)

What am I understanding wrong?

Best, Achim

(setf harm (harmonics 'a2 8 :quantize 1/2 :type :hertz))
=> (110.0 220.0 329.62756 440.0 554.3653 659.2551 783.99085 880.0)

(hertz-to-pitch harm)
=> (a2 a3 e4 a4 cs5 e5 g5 a5)

(hertz-to-pitch '(110.0 220.0 330.0 440.0 550.0 660.0 770.0 880.0))
=> (a2 a3 e4 a4 c5.. e5 fs5.. a5)
  • Author

What is quantize NIL doing?

49 minutes ago, born said:

What is quantize NIL doing?

Nothing.

Jesper

  • Author

:quantize nil
(110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0)

:quantize 1/2
(110.0 220.0 329.62756 440.0 554.3653 659.2551 783.99085 880.0)

not exactly the same numbers ...
question remains.

Your first example doesn't quantize, and your second example quantizes to the closest semitone, I guess.

Sorry, didn't read carefully enough in my deleted answer.

Jesper

  • Author

Sorry to insist in this, but my first example is somehow quantizing because the result should be
(110.0 220.0 330.0 440.0 550.0 660.0 770.0 880.0)

when calculating a harmonic scale in frequencies and not
(110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0)

Achim

Only Janusz knows.

Could it be that the default is a tempered scale?

(harmonics 'a2 8 :quantize nil :type :hertz)

=>(110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0)

(* 220 (expt 2 7/12)) ;;tempered fifth

=>329.62756

Jesper

  • Author

Not quite. There ist still a difference in the 5. and 7. overtone compared to the semitone version of Janusz (5. and 7. overtone):

(setf harm (harmonics 'a2 8 :quantize 1/2 :type :hertz))

(110.0 220.0 329.62756 440.0 554.3653 659.2551 783.99085 880.0)

(setf harm (harmonics 'a2 8 :quantize nil :type :hertz))

(110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0)

  • Author

Then I would suggest to set :quantize NIL to not quantize at all.

And as a feature request: It would be nice to add a functionality to be able to start the harmonic scale from any arbitrary overtone.

Achim

Don't know if this simple function will be of use for now.

Jesper

;; for single pitches

(defun harmonics2 (start-pitch length &key (partial 1) quantize)

(let ((sp (pitch-to-hertz start-pitch)) (part (max partial 1)) res)

(setf res (loop for i from part to (+ length (1- part)) collect (* i sp)))

(if quantize (pitch-to-hertz (micro-quantize (hertz-to-pitch res) :quantize quantize)) res)))

(harmonics2 'a2 8)

=>(110.0 220.0 330.0 440.0 550.0 660.0 770.0 880.0)

(harmonics2 'a2 8 :partial 4)

=>(440.0 550.0 660.0 770.0 880.0 990.0 1100.0 1210.0)

(harmonics2 'a2 8 :partial 1 :quantize 1/8)

=>(110.0 220.0 329.62756 440.0 546.4174 659.2551 772.751 880.0)

(mapcar (lambda (x) (harmonics2 x 4)) '(a2 c3 d3))

=>((110.0 220.0 330.0 440.0) (130.81278 261.62555 392.43832 523.2511) (146.83238 293.66476 440.49713 587.3295))

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.