TomTolleson Posted November 11, 2024 Posted November 11, 2024 Hello! I've been coding in python for two weeks for work and I'm now having trouble figuring out what I'm doing wrong in my lisp loops. Cursor.ai isn't helping debug my lisp at all. I'm trying to loops through scales such as (setf a-pitches (loop for note in scalea collect (list note (+ note 4)))) And it's not evaluating. I was hoping to do this in OpusModus with a little help from cursor for lisp but that's not yielding good results. There's probably an OM function I'm not thinking of. Here's the whole set of functional code. Any advice is appreciated. ;;;--------------------------------------------------------- ;;; Parameters (setf scalea '(bb3 c4 cs4 ds4 F4 G4 gs4)) (setf scaleb '(bb3 c4 cs4 d4 F4 G4 gs4)) (setf scalec '(ds3 F3 G3 gs3 as3 c4 cs4)) ;;;-------------------------------------------------------- ;;; AI code (in-package :om) ;; Section A pitches and rhythms (setf a-pitches (loop for note in scalea collect (list note (+ note 4)))) (setf a-lengths '(q q. e q q. e q)) (setf a-dynamics '(mf mf mp mf mf mp mf)) (setf section-a-omn (make-omn :pitch a-pitches :length a-lengths :velocity a-dynamics)) ;; Section B pitches and rhythms (setf b-pitches (loop for note in scaleb collect (list note (+ note 3)))) (setf b-lengths '(h q q h q q)) (setf b-dynamics '(mp mf mf mp mf mf)) (setf section-b-omn (make-omn :pitch b-pitches :length b-lengths :velocity b-dynamics)) ;; Section C pitches and rhythms (setf c-pitches (loop for note in scalec collect (list note (+ note 5)))) (setf c-lengths '(q. q. q q h q)) (setf c-dynamics '(f mf mp p mp mf)) (setf section-c-omn (make-omn :pitch c-pitches :length c-lengths :velocity c-dynamics)) ;; Combine sections in ABABCABAB form (setf piano-rh (combine section-a-omn section-b-omn section-a-omn section-b-omn section-c-omn section-a-omn section-b-omn section-a-omn section-b-omn)) ;; Create left hand accompaniment (setf lh-pitches '((bb2 f3) (c3 g3) (cs3 gs3))) (setf lh-lengths '(h h h)) (setf lh-dynamics '(mp mp mp)) (setf piano-lh (make-omn :pitch lh-pitches :length lh-lengths :velocity lh-dynamics)) Quote
jesele Posted November 11, 2024 Posted November 11, 2024 + note 4 isn't going to work. Either convert the note to an integer + 4 then convert back again or use pitch-transpose. (setf a-pitches (loop for note in scalea collect (list note (integer-to-pitch (+ 4 (pitch-to-integer note)))))) Or (setf a-pitches (loop for note in scalea collect (cons note (pitch-transpose 4 (list note))))) Jesper TomTolleson 1 Quote
TomTolleson Posted November 12, 2024 Author Posted November 12, 2024 @jesele that did the trick! I'll keep the "cons" in mind next time. THT Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.