Magic Squares

Sitting in on some undergraduate composition lectured this year, using it as a chance to brush up on some things I was never formally taught. This is particularly beneficial to my knowledge of acoustic contemporary composition (as opposed to the electroacoustic side of things). Yesturday I sat in on a lecture on Maxwell Davies’ use of Magic Square number patterns in Ave Maris Stella (1975; chamber ensemble). I wrote a little python script to generate any odd-order sized square (n), and a the values with modulo wrap (where modulo = n):

# solves magic square for odd-ordered grid sizes
# owmtxy 17/10/2012
# for python v.2.6.6

n = int(input("Enter (odd) order size (n): "))
square = []
def calculateSquare(row,col):
val = n*((row+col-1+(n/2))%n) + ((row + (2*col)-2)%n)+1;
return val

#Create Array
print "Magic",n,"*",n,"Square Array:"
for i in range(n):
for j in range(n):

# Print array in a nice n*n grid
for k in range(n):
print square[k*n:(k*n)+n]

print "n Modulo",n,"Array:

#Create Array of modulo values
modSquare = []

for i in range(n):
for j in range(n):
modulo = (calculateSquare(i+1,j+1)%n)

# Print array in a nice n*n grid
for k in range(n):
print modSquare[k*n:(k*n)+n]

To model Maxwell Davies’ use somewhat, a regular n x n grid is drawn up, and a melody of length n is written to the top row of the grid. Each row is then transposed (using the interval of that top-line melody), the pitch of cell i comes from cell i-(n-1). In a 7×7 grid, the starting pitch of the second row (cell 8), comes from cell 2. Our magic square layout is then used to re-map these cells into a new order, giving us a magic square of pitch classes.

My plan is to use this grid in conjunction with some form of cellular automata to select or ‘activate’ cells of the magic square.

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.