Jump to content

Featured Replies

Posted

Hello,

 

I have a lisp function called convert-chord-symbols-to-notes which works but is outputting backslashes.

The function for D#/Eb is as follows

 

(defun convert-chord-symbol-to-notes (chord-symbol)
  (cond
  ;; D# / Eb chords
    ((or (equal chord-symbol 'd#sus2) (equal chord-symbol 'ebsus2)) '(d#4 f4 a#4))
    ((or (equal chord-symbol 'd#maj) (equal chord-symbol 'ebmaj)) '(d#4 g4 a#4))
    ((or (equal chord-symbol 'd#m) (equal chord-symbol 'ebm)) '(d#4 f#4 a#4))
    ((or (equal chord-symbol 'd#7) (equal chord-symbol 'eb7)) '(d#4 g4 a#4 c#5))
    ((or (equal chord-symbol 'd#m7) (equal chord-symbol 'ebm7)) '(d#4 f#4 a#4 c#5))
    ((or (equal chord-symbol 'd#maj7) (equal chord-symbol 'ebmaj7)) '(d#4 g4 a#4 d5))
    ((or (equal chord-symbol 'd#9) (equal chord-symbol 'eb9)) '(d#4 g4 a#4 c#5 f5))
 ;; Error handling for unrecognized chords
    (t (error "Chord symbol not recognized"))))

 

If I use the function, I would expect the follwing:

 

(setf notes (convert-chord-symbol-to-notes 'ebmaj7))
>(d#4 g4 a#4 d5)

However, what I'm getting is:
 

(setf notes (convert-chord-symbol-to-notes 'ebmaj7))
>(d\#4 g4 a\#4 d5)

 

I've added another function:
 

(defun remove-backslashes (string)
  (remove #\\ string))

And used that on the output as a new variable. There were no errors and the code evaluated fine but the output still had backslashes.
I also added the remove-backlslashes function into the convert-chord-symbols-to-notes. Again, it evaluated without errors but the backslashes were still there.

Any ideas what's causing this or, more importantly, how to fix it?

Thanks!

Tom Tolleson

OM don't use # but s for sharps.

 

Jesper

 

(defun convert-chord-symbol-to-notes (chord-symbol)
  (cond
  ;; D# / Eb chords
    ((or (equal chord-symbol 'd#sus2) (equal chord-symbol 'ebsus2)) '(ds4 f4 as4))
    ((or (equal chord-symbol 'd#maj) (equal chord-symbol 'ebmaj)) '(ds4 g4 as4))
    ((or (equal chord-symbol 'd#m) (equal chord-symbol 'ebm)) '(ds4 fs4 as4))
    ((or (equal chord-symbol 'd#7) (equal chord-symbol 'eb7)) '(ds4 g4 as4 cs5))
    ((or (equal chord-symbol 'd#m7) (equal chord-symbol 'ebm7)) '(ds4 fs4 as4 cs5))
    ((or (equal chord-symbol 'd#maj7) (equal chord-symbol 'ebmaj7)) '(ds4 g4 as4 d5))
    ((or (equal chord-symbol 'd#9) (equal chord-symbol 'eb9)) '(ds4 g4 as4 cs5 f5))
 ;; Error handling for unrecognized chords
    (t (error "Chord symbol not recognized"))))
 
 
(setf notes (convert-chord-symbol-to-notes 'ebmaj7))
(setf notes (convert-chord-symbol-to-notes 'd#maj7))

 

 

Or 

 

(defun convert-chord-symbol-to-notes (chord-symbol)
  (cond
  ;; D# / Eb chords
    ((or (equal chord-symbol 'dssus2) (equal chord-symbol 'ebsus2)) '(ds4 f4 as4))
    ((or (equal chord-symbol 'dsmaj) (equal chord-symbol 'ebmaj)) '(ds4 g4 as4))
    ((or (equal chord-symbol 'dsm) (equal chord-symbol 'ebm)) '(ds4 fs4 as4))
    ((or (equal chord-symbol 'ds7) (equal chord-symbol 'eb7)) '(ds4 g4 as4 cs5))
    ((or (equal chord-symbol 'dsm7) (equal chord-symbol 'ebm7)) '(ds4 fs4 as4 cs5))
    ((or (equal chord-symbol 'dsmaj7) (equal chord-symbol 'ebmaj7)) '(ds4 g4 as4 d5))
    ((or (equal chord-symbol 'ds9) (equal chord-symbol 'eb9)) '(ds4 g4 as4 cs5 f5))
 ;; Error handling for unrecognized chords
    (t (error "Chord symbol not recognized"))))
 
 
(setf notes (convert-chord-symbol-to-notes 'ebmaj7))
(setf notes (convert-chord-symbol-to-notes 'dsmaj7))
 

  • Author

Ah! Of course. I generated this with the LLM and lost my ability to recognize basic OMN! LOL

 

Thanks Jesele!

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