Auto-Format of (ring )

#1

Why does it look like this? Is there anything I can do to make it look neater?

chordprog = (ring chord( :c3, 'm7' ),
             chord( :g3, 'm7' ),
             chord( :f3, 'm7' ),
             chord( :ab3, 'major' ),
             chord( :c3, 'm7' ),
             chord( :g3, 'm7' ),
             chord( :eb3, 'major' ),
chord( :eb3, '6*9' ) ).repeat(3) +
  (ring chord( :c3, 'm7' ),
   chord( :g3, 'm7' ),
   chord( :f3, 'major' ),
   chord( :ab3, 'major' ),
   chord( :c3, 'm7' ),
   chord( :bb3, 'major' ),
   chord( :eb3, 'major' ),
   chord( :eb3, '6*9' ) )
1 Like
#2

I suppose this is a limitation of whatever library is doing the formatting, which is probably not programmed to handle Sonic Pi’s lisp-like syntax.
You can work around it by using standard Ruby function-call syntax:

chordprog = ring( chord( :c3, 'm7' ),
                  chord( :g3, 'm7' ),
                  chord( :f3, 'm7' ),
                  chord( :ab3, 'major' ),
                  chord( :c3, 'm7' ),
                  chord( :g3, 'm7' ),
                  chord( :eb3, 'major' ),
                  chord( :eb3, '6*9' )
).repeat(3) +
  ring( chord( :c3, 'm7' ),
        chord( :g3, 'm7' ),
        chord( :f3, 'major' ),
        chord( :ab3, 'major' ),
        chord( :c3, 'm7' ),
        chord( :bb3, 'major' ),
        chord( :eb3, 'major' ),
        chord( :eb3, '6*9' ) )

Or you could create an array and then use .ring on it, something like:

chordprog =
  [chord( :c3, 'm7' ),
   chord( :g3, 'm7' ),
   chord( :f3, 'm7' ),
   chord( :ab3, 'major' ),
   chord( :c3, 'm7' ),
   chord( :g3, 'm7' ),
   chord( :eb3, 'major' ),
   chord( :eb3, '6*9' )
   ].ring.repeat(3) +
  [chord( :c3, 'm7' ),
   chord( :g3, 'm7' ),
   chord( :f3, 'major' ),
   chord( :ab3, 'major' ),
   chord( :c3, 'm7' ),
   chord( :bb3, 'major' ),
   chord( :eb3, 'major' ),
   chord( :eb3, '6*9' )].ring
1 Like
#3

Thanks very much for this. I like things to look neat :slight_smile: