Jump to content
Sign in to follow this  

Help on WILDCARDS ? *

Recommended Posts

Dear All,


Some help needed in wildcard uses in Opusmodus Functions and OMN expressions...



The definition....


In computer (software) technology, a wildcard is a symbol used to replace or represent one or more characters.[2] Algorithms for matching wildcards have been developed in a number of recursive and non-recursive varieties.

In Unix-like and DOS operating systems, the question mark ? matches exactly one character.



I was in need of a wildcard to represent a pitch class in ANY register, like "cs?" meaning all C# pitch classes in any register/octave (cs0, cs1, cs2, cs3, cs4, cs5, cs6, cs7, etc).


There are other interesting uses for this wildcards inside functions, to generalize and make recursions possible elegantly.


Any Hints ?




Share this post

Link to post
Share on other sites

often helpful in PATTERN MATCH things... (like in OPMO pattern-match-functions)


here is a short IDEA for an octave-independent PITCH-PATTERN-MATCHP with possible WILDCARD, perhaps could help you...


;;; PITCH PATTERN-MATCHP octave-independent

;;; SUB
(defun convert-pitch (pitches)
  (loop for i in pitches
    when (pitchp i)
    collect (compress (butlast (explode i)))
    else collect i))

;;; MAIN

(defun pitch-pattern-matchp (pitchlist pattern)
  (let ((pitchlist (convert-pitch pitchlist))
        (pattern (convert-pitch pattern)))
    (pattern-matchp pitchlist pattern)))

(pitch-pattern-matchp '(c4 d4 eb4 f4 g4) '(c ? e))
=> nil

(pitch-pattern-matchp '(c4 d4 eb4 f4 g4) '(c ? eb))
=> t


Share this post

Link to post
Share on other sites

Thanks, André !


I was trying to solve this problem



(setf melody '(c5 c5 d5 e5 g5 a5 g5 c6 b5 c6))

(setf blkharm (pattern-map '(((c3) (e2g2a2c3))((d3) (f2gs2b2d3))((e3) (e3c3a2g2))((f3) (gs2b2d3f3))((g3) (g3e3c3a2))((gs3) (b2d3f3gs3))((ab3) (b2d3f3ab3))((a3) (c3e3g3a3))((b3) (d3f3ab3b3))((c4) (e3g3a3c4))((d4) (f3gs3b3d4))((e4) (e4c4a3g3))((f4) (gs3b3d4f4))((g4) (g4e4c4a3))((gs4) (b3d4f4gs4))((ab4) (b3d4f4ab4))((a4) (g4e4c4a4))((b4) (d4f4ab4b4))((c5) (e4g4a4c5))((d5) (f4gs4b4d5))((e5) (e5c5a4g4))((f5) (gs4b4d5f5))((g5) (g5e5c5a4))((gs5) (b4d5f5gs5))((ab5) (b4d5f5ab5))((a5) (g5e5c5a5))((b5) (d5f5ab5b5))((c6) (e5g5a5c6))((d6) (f5gs5b5d6))((e6) (e6c6a5g5))((f6) (gs5b5d6f6))((g6) (g6e6c6a5))((gs6) (b5d6f6gs6))((ab6) (b5d6f6ab6))((a6) (g6e6c6a6))((b6) (d6f6ab6b6)))
             melody :otherwise 'c4f4bb4eb5))

 :length '(q e e e e e e q q q)
 :pitch blkharm)


To make some block harmonizations, like this:




If you are curious, see this post:



Best !! Thank you ! You are the LOOPER MAN !




Share this post

Link to post
Share on other sites

You can use pitch-class within pattern-map function:

 '(((0 1 9 4 2 5) (0 4 2 1 9 5))
   ((11 8 10 3 7 6) (10 8 11 3 7 6)))
 '((c6 cs4 a4 e3 d6 f4) (b4 gs3 bb4 eb4 g5 fs6))
  :pcs t)
=> ((c6 e4 d4 cs3 a6 f4)
    (bb4 gs3 b4 eb4 g5 fs6))



Share this post

Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this