Hi!
There have been a handful of times in which I desired a ring chain that inverts the ring over a specified pitch axis. This would mainly work for rings that are intended as collections of pitches. Would there be interest in adding a feature like this? I have a prototype below, that I'm positive could be more thoughtfully implemented, but for what I typically need, it works well:
class SonicPi::Core::RingVector
def invert(n)
self.map {|e| n-e + self.min}
end
end
puts (scale :c, :major).invert(60)
this will return: (ring 60, 58, 56, 55, 53, 51, 49, 48)
At any rate, thanks so much for this fantastic environment. Much <3
This looks quite cool. I think there's a small bug in it though: should it be self.map {|e| 2*n-e}? Otherwise, as it is, you get things like:
(ring 60, 61, 62, 60).invert(60) -> (ring 60, 59, 58, 60), but
(ring 60, 61, 62, 58).invert(60) -> (ring 58, 57, 56, 60).
Also, I wonder if a different name might work better (maybe reflect?) as this one might get confused with chord inversions.
Yeah, conceptually, your solution self.map {|e| 2*n-e} makes more sense according to the way I described it. I like it, thanks :)
Regarding the name, ".reflect" is already in use (similar to .mirror), whereas invert is a term that describes this kind transformation in serialism. I agree that people might confuse it with chord invert though. hm.
Oh yes, I remembered .mirror, but forgot there's also .reflect. In that case maybe .invert is best (at least I can't think of anything better).
@xavriley any thoughts on this? :-)
Looks good to me - in music theory "inversion" has a specific meaning when applied to counterpoint/melodies (sadly the same word is used for something different when talking about chords).
For reference:
.reverse in our case.invert(pitch_axis).reverseI like the name .invert but it is confusing if people use rings for chords etc. Maybe .invert_around(pitch) instead?
For the implementation @emlyn's implementation looks good. We just need some good tests to make sure it all makes sense.
Most helpful comment
Looks good to me - in music theory "inversion" has a specific meaning when applied to counterpoint/melodies (sadly the same word is used for something different when talking about chords).
For reference:
.reversein our case.invert(pitch_axis).reverseI like the name
.invertbut it is confusing if people use rings for chords etc. Maybe.invert_around(pitch)instead?For the implementation @emlyn's implementation looks good. We just need some good tests to make sure it all makes sense.