mdedwards / slippery-chicken

slippery chicken: algorithmic composition software in common lisp and clos
http://michael-edwards.org/sc
72 stars 3 forks source link

pitch-or-chord= and events containing rests #61

Closed rubenphilipp closed 8 months ago

rubenphilipp commented 1 year ago

There appears to be an issue with the method pitch-or-chord= in the case one of the arguments is an event which holds a rest. Since, in this case, the pitch slot holds the value nil, the comparison does not succeed. It seems reasonable, at least to me, to include a test which handles this case.

(pitch-or-chord= (make-pitch 'b5) (make-rest 16))

  #<STANDARD-GENERIC-FUNCTION SLIPPERY-CHICKEN:PITCH-OR-CHORD= (5)>
when called with arguments
  (
PITCH: frequency: 987.767, midi-note: 83, midi-channel: 1 
       pitch-bend: 0.0 
       degree: 83, data-consistent: T, white-note: B5
       nearest-chromatic: B5
       src: 3.7754974, src-ref-pitch: C4, score-note: B5 
       qtr-sharp: NIL, qtr-flat: NIL, qtr-tone: NIL,  
       micro-tone: NIL, 
       sharp: NIL, flat: NIL, natural: T, 
       octave: 5, c5ths: 0, no-8ve: B, no-8ve-no-acc: B
       show-accidental: T, white-degree: 48, 
       accidental: N, 
       accidental-in-parentheses: NIL, marks: NIL, 
       marks-before: NIL, amplitude: NIL
LINKED-NAMED-OBJECT: previous: NIL, 
                     this: NIL, 
                     next: NIL
NAMED-OBJECT: id: B5, tag: NIL, 
data: B5
**************

EVENT: start-time: NIL, end-time: NIL, 
       duration-in-tempo: 0.000, 
       compound-duration-in-tempo: 0.000, 
       amplitude: 0.700 
       bar-num: -1, marks-before: NIL, 
       tempo-change: NIL 
       instrument-change: NIL 
       display-tempo: NIL, start-time-qtrs: -1.000, 
       midi-time-sig: NIL, midi-program-changes: NIL, 
       midi-control-changes: NIL, 
       8va: 0, player: NIL
       asco-label: NIL, asco-msgs: NIL
       set-ref: NIL
       pitch-or-chord: NIL
       written-pitch-or-chord: NIL
RHYTHM: value: 16.000, duration: 0.250, rq: 1/4, is-rest: T, 
        is-whole-bar-rest: NIL, 
        score-rthm: 16.0, undotted-value: 16, num-flags: 2, num-dots: 0, 
        is-tied-to: NIL, is-tied-from: NIL, compound-duration: 0.250, 
        is-grace-note: NIL, needs-new-note: NIL, beam: NIL, bracket: NIL, 
        rqq-note: NIL, rqq-info: NIL, marks: NIL, marks-in-part: NIL, 
        letter-value: 16, tuplet-scaler: 1, bar-pos: -1, 
        grace-note-duration: 0.05
LINKED-NAMED-OBJECT: previous: NIL, 
                     this: NIL, 
                     next: NIL
NAMED-OBJECT: id: 16, tag: NIL, 
data: 16
**************
).
   [Condition of type SB-PCL::NO-APPLICABLE-METHOD-ERROR]
See also:
  Common Lisp Hyperspec, 7.6.6 [:section]

Restarts:
 0: [RETRY] Retry calling the generic function.
 1: [RETRY] Retry SLIME REPL evaluation request.
 2: [*ABORT] Return to SLIME's top level.
 3: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {70052A9DB3}>)

Backtrace:
  0: ((:METHOD NO-APPLICABLE-METHOD (T)) #<STANDARD-GENERIC-FUNCTION SLIPPERY-CHICKEN:PITCH-OR-CHORD= (5)>  ..) [fast-method]
  1: (SB-PCL::CALL-NO-APPLICABLE-METHOD #<STANDARD-GENERIC-FUNCTION SLIPPERY-CHICKEN:PITCH-OR-CHORD= (5)> ( ..)
  2: (SB-INT:SIMPLE-EVAL-IN-LEXENV (PITCH-OR-CHORD= (MAKE-PITCH (QUOTE B5)) (MAKE-REST 16)) #<NULL-LEXENV>)
  3: (EVAL (PITCH-OR-CHORD= (MAKE-PITCH (QUOTE B5)) (MAKE-REST 16)))
 --more--
mdedwards commented 8 months ago

I'm sorry Ruben: I missed this :/ Feel free to reach out if something goes ignored. Anyway, I've added some methods to take care of this and other cases. Let me know if something still doesn't work otherwise feel free to close.

rubenphilipp commented 8 months ago

Ah, thanks Michael. I think, this was an issue we discussed in class. I am happy with your solution.