Skip to content
View in the app

A better way to browse. Learn more.

Opusmodus Community

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.

Interpolation between integers with gen-transition

Featured Replies

Hello,

 

I'm hitting a brick wall with m thinking from object-oriented approaches. Basically, I want to create a melody line that "flutters"  pitches in a key corresponding to a bass pitch, and only when that bass pitch occurs. It's easy enough for an "If, then" statement but my attempt to solve this are leading me to take a first step of interpolating between bass pitches (as integers) and manually calculating the remains of the bar manually.
However this is not ideal as I would prefer to use euclidean-rhythm with a rotation, so finding a parametric approach this would be ideal. Here's the general approach I've begun. 

Any advice from people more experienced with LISP is appreciated.

 

(setf bass '((g2)(c3)(a2)(e3)(fs3)))
(setf bassint (pitch-to-integer bass))
=> ((-17) (-12) (-15) (-8) (-6))

;;; create a set of integers from interpolation 
;;; between bass integers (bassint), 
;;; then convert those to pitches

(setf melody (gen-transition 1 10 10 1))

Thanks,


Tom

May be this can help a bit, I've tried this:

 

(setf bass '(g2 c3 a2 e3 fs3))
(setf bassint (pitch-to-integer bass))
;=> (-17 -12 -15 -8 -6)

;;; create a set of integers from interpolation 
;;; between bass integers (bassint), 
;;; then convert those to pitches

(defun linear-interpolation (numbers steps)
  (let ((interpolated-numbers nil))
    (loop for i from 0 below (- (length numbers) 1)
          for number = (nth i numbers)
          for next-number = (nth (1+ i) numbers)
          do (loop for j from 0 to steps
                   do  (push (+ (* (- next-number number)
                                   (/ (float j) steps))
                                number)
                             interpolated-numbers)
                   )
             (push next-number interpolated-numbers))
    (filter-repeat 1 (nreverse interpolated-numbers))))


(setf n-steps 4)
(setf new-ints (mapcar 'round (linear-interpolation bassint n-steps)))


(setf melody (integer-to-pitch new-ints))

(setf sop (filter-tie
           (make-omn
            :pitch (pitch-transpose 24 melody)
            :length '(e)
            :span :pitch
            )))

(setf bas (make-omn
           :pitch bass
           :length '(h)
           :span :pitch
           ))

(ps 'gm :fl (list sop) :bn (list bas) :time-signature '(4 4))

SB.

  • Author

This is beautiful, @Stephane Boussuge! First use of a for loop and a defined function for me with OM. This opens up a whole new world.

 

Thank you so much!

 

THT
 

 

  • Author

One question @Stephane Boussuge - what is 'round ?
Context - 

 

(setf new-ints (mapcar 'round (linear-interpolation bassint n-steps)))

 

I'm unable to find that in the documentation.

Create an account or sign in to comment


© 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

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.