Skip to content

Instantly share code, notes, and snippets.

@skyl skyl/gist:866920
Created Mar 12, 2011

Embed
What would you like to do?
shruti system
In [35]: shrutis = {
....: 0: (1/Decimal('1'),),
....: 1: (256/Decimal('243'), 16/Decimal('15')),
....: 2: (10/Decimal('9'), 9/Decimal('8')),
....: 3: (32/Decimal('27'), 6/Decimal('5')),
....: 4: (5/Decimal('4'), 81/Decimal('64')),
....: 5: (4/Decimal('3'),),
....: # 27/Decimal('20'),
....: 6: (45/Decimal('32'), 729/Decimal('512')),
....: 7: (3/Decimal('2'),),
....: 8: (128/Decimal('81'), 8/Decimal('5')),
....: 9: (5/Decimal('3'), 27/Decimal('16')),
....: 10: (16/Decimal('9'), 9/Decimal('5')),
....: 11: (15/Decimal('8'), 243/Decimal('128')),
....: }
In [36]:
In [37]:
In [38]: offsets = {}
In [39]:
In [40]: for k, v in shrutis.iteritems():
....: offsets[k] = []
....: for val in v:
....: offsets[k].append(440*val/twelve_tone_equal_440[57+k])
....:
In [41]:
In [42]: offsets
Out[42]:
{0: [Decimal('1')],
1: [Decimal('0.9943696462819487042811924613'),
Decimal('1.006799266860473063084707367')],
2: [Decimal('0.9898874646003770052669180057'),
Decimal('1.002261057907881717832754481')],
3: [Decimal('0.9966179736340320509998524158'),
Decimal('1.009075698304457451637350571')],
4: [Decimal('0.9921256574801246717198160247'),
Decimal('1.004527228198626230116313725')],
5: [Decimal('0.9988713845844543325328538213')],
6: [Decimal('0.9943689110435824561886873843'),
Decimal('1.006798522431627236891045977')],
7: [Decimal('1.001129890627525773623123911')],
8: [Decimal('0.9954931752255787968531046778'),
Decimal('1.007936839915898531813768486')],
9: [Decimal('0.9910059291689342222645833093'),
Decimal('1.003393503283545900042890600')],
10: [Decimal('0.9977440429416648723853627111'),
Decimal('1.010215843478435683290179745')],
11: [Decimal('0.9932466509618393105267112142'),
Decimal('1.005662234098862301908295104')]}
So then:
>>> A = MidiNote(9)
>>> A.freq()
Decimal('27.5000')
>>> A.freq(4)
Decimal('440')
>>> A.freq(4, tonality="3rd")
Decimal('436.5352892912548555567190509')
>>> F = MidiNote(5)
>>> F.freq(4)
Decimal('349.2282314330038844453752407')
>>> F.freq(4)*5/Decimal(4)
Decimal('436.535289291254855556719051')
@skyl

This comment has been minimized.

Copy link
Owner Author

skyl commented Mar 12, 2011

A = MidiNote(9)
A.freq()
Decimal('27.5000')
A.freq(4)
Decimal('440')
A.freq(4, tonality="3rd")
Decimal('436.5352892912548555567190509')
F = MidiNote(5)
F.freq(4)
Decimal('349.2282314330038844453752407')
F.freq(4)*5/Decimal(4)
Decimal('436.535289291254855556719051')

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.