I’m completely new to Python. 20 years ago, I was doing things like this in QBASIC; building waveforms and writing them as WAVE files to be used
in sampling synthesizers. They worked on my TRITON.
Recently, I got a compiler, FreeBASIC, and got some of my old programs to run on this Win10 machine.
I saw that there were people building synths with Raspberry Pi systems, so I decided to go that way. I’m keeping myself in that sandbox, because I’ve seen how an innocent mistake can swamp a system. (Back in the QBASIC days, I always wrote to a floppy. A 200 MB hard drive was huge.)
This site may not be suited to the problems I’m setting for myself. This little program is the beginning of something larger; to ‘add and average’ the interval strings and identify the results of that process; to convert the intervals to notes; and also build waveforms based on these scales.
I’m trying to get used to the Python data types.
‘’’ Octotonic.py
A model of an octotonic system of musical scales. There are 5 out of 8 notes
to make a scale. There are 12 possible scales. These are characterized as a
sequence of integers, the 1st 3 must add to 5, and the last 2 must add to 3,
so that the total is 8; and this is a check sum for the data.
‘’’
OctoStrings = (‘11312’, ‘11321’, ‘12212’, ‘12221’, ‘13112’, ‘13121’,
‘21212’, ‘21221’, ‘22112’, ‘22121’, ‘31112’, ‘31121’)
StringA = ‘’
ListA =
for i in range(12):
StringA = OctoStrings[i]
CheckSum = 0
ListA =
for j in range(5):
ListA = ListA + list(StringA[j])
CheckSum = CheckSum + int(StringA[j])
if (i + 1) < 10:
print((i+1),' ', StringA,' ', ListA,' ', CheckSum)
if (i + 1) >= 10:
print((i+1),' ', StringA,' ', ListA,' ', CheckSum)
Python 3.7.3 (/usr/bin/python3)
%Run Octotonic.py
1 11312 [‘1’, ‘1’, ‘3’, ‘1’, ‘2’] 8
2 11321 [‘1’, ‘1’, ‘3’, ‘2’, ‘1’] 8
3 12212 [‘1’, ‘2’, ‘2’, ‘1’, ‘2’] 8
4 12221 [‘1’, ‘2’, ‘2’, ‘2’, ‘1’] 8
5 13112 [‘1’, ‘3’, ‘1’, ‘1’, ‘2’] 8
6 13121 [‘1’, ‘3’, ‘1’, ‘2’, ‘1’] 8
7 21212 [‘2’, ‘1’, ‘2’, ‘1’, ‘2’] 8
8 21221 [‘2’, ‘1’, ‘2’, ‘2’, ‘1’] 8
9 22112 [‘2’, ‘2’, ‘1’, ‘1’, ‘2’] 8
10 22121 [‘2’, ‘2’, ‘1’, ‘2’, ‘1’] 8
11 31112 [‘3’, ‘1’, ‘1’, ‘1’, ‘2’] 8
12 31121 [‘3’, ‘1’, ‘1’, ‘2’, ‘1’] 8
Warnings
May be ignored if you are happy with your program.
Octotonic.py
Line 14 : Need type annotation for ‘ListA’
Was it helpful or confusing?