Skip to content

Commit

Permalink
Format python
Browse files Browse the repository at this point in the history
  • Loading branch information
superusercode committed May 13, 2018
1 parent 64be547 commit 9a9e906
Show file tree
Hide file tree
Showing 5 changed files with 81 additions and 87 deletions.
35 changes: 17 additions & 18 deletions LUT/frequencyTable.py
Expand Up @@ -7,31 +7,30 @@
output.write("frequencyTableL: ; ftab[0..192] = (32767/2) * 2^(i/192)\n")
output.write(";---------------------------------------------------------------------------------------------")

for i in range(0,193):
if( (i % 16) == 0 ):
output.write( "\n\t.byte " )

value = int(round( (32767/2) * 2**(i/192.0) )) % 256
for i in range(0, 193):
if ((i % 16) == 0):
output.write("\n\t.byte ")

output.write( hex( int(value) ).replace("0x","").upper().zfill(3) + "h" )
if( (i % 16) != 15 ):
output.write( ", " )
value = int(round((32767 / 2) * 2 ** (i / 192.0))) % 256

output.write(hex(int(value)).replace("0x", "").upper().zfill(3) + "h")
if ((i % 16) != 15):
output.write(", ")

output.write("\n;---------------------------------------------------------------------------------------------\n")
output.write("frequencyTableH:\n")
output.write(";---------------------------------------------------------------------------------------------")

for i in range(0,193):
if( (i % 16) == 0 ):
output.write( "\n\t.byte " )

value = int(round( (32767/2) * 2**(i/192.0) )) >> 8
for i in range(0, 193):
if ((i % 16) == 0):
output.write("\n\t.byte ")

output.write( hex( int(value) ).replace("0x","").upper().zfill(2) + "h" )
if( (i % 16) != 15 ):
output.write( ", " )
value = int(round((32767 / 2) * 2 ** (i / 192.0))) >> 8

output.write( "\n\n" )
output.write(hex(int(value)).replace("0x", "").upper().zfill(2) + "h")
if ((i % 16) != 15):
output.write(", ")

output.close()
output.write("\n\n")

output.close()
37 changes: 17 additions & 20 deletions LUT/periodTable.py
Expand Up @@ -6,35 +6,32 @@
output.write("periodTableL: ; ptab[0..191] = 4095 / 2^(i/192)\n")
output.write(";---------------------------------------------------------------------------------------------")

NES_CLK = 21477270.0/12.0
NES_CLK = 21477270.0 / 12.0

for i in range(0,193):
if( (i % 16) == 0 ):
output.write( "\n\t.byte " )
for i in range(0, 193):
if ((i % 16) == 0):
output.write("\n\t.byte ")

value = int(round( 4095 / 2.0**(i/192.0) )) % 256
output.write( hex( int(value) ).replace("0x","").upper().zfill(3) + "h" )
if( (i % 16) != 15 ):
output.write( ", " )
value = int(round(4095 / 2.0 ** (i / 192.0))) % 256

output.write(hex(int(value)).replace("0x", "").upper().zfill(3) + "h")
if ((i % 16) != 15):
output.write(", ")

output.write("\n;---------------------------------------------------------------------------------------------\n")
output.write("periodTableH:\n")
output.write(";---------------------------------------------------------------------------------------------")

for i in range(0, 193):
if ((i % 16) == 0):
output.write("\n\t.byte ")

for i in range(0,193):
if( (i % 16) == 0 ):
output.write( "\n\t.byte " )

value = int(round( (NES_CLK/8363.0) * 2.0**5.0 / 2.0**(i/192.0) )) >> 8

output.write( hex( int(value) ).replace("0x","").upper().zfill(2) + "h" )
if( (i % 16) != 15 ):
output.write( ", " )
value = int(round((NES_CLK / 8363.0) * 2.0 ** 5.0 / 2.0 ** (i / 192.0))) >> 8

output.write(hex(int(value)).replace("0x", "").upper().zfill(2) + "h")
if ((i % 16) != 15):
output.write(", ")

output.write( "\n\n" )
output.write("\n\n")

output.close()

26 changes: 13 additions & 13 deletions LUT/sawVolumeMap.py
@@ -1,20 +1,20 @@
# hello world of python
# vrc6 sawtooth volume map (0..15 -> 0..42)

output = open( "sawVolumeMap.txt", "w" )
output.write( ";--------------------------------------------------------------------------------------------\n" )
output.write( "@sawVolumeMap:\n" )
output.write( ";--------------------------------------------------------------------------------------------\n" )
output.write( "\t.byte " )
output = open("sawVolumeMap.txt", "w")
output.write(";--------------------------------------------------------------------------------------------\n")
output.write("@sawVolumeMap:\n")
output.write(";--------------------------------------------------------------------------------------------\n")
output.write("\t.byte ")

for i in range( 0, 16 ):

value = int( round( i * 42.0 / 15.0 ) )

output.write( hex( int(value) ).replace("0x","").upper().zfill(2) + "h" )
for i in range(0, 16):

if( i != 15 ):
output.write( ", " )
value = int(round(i * 42.0 / 15.0))

output.write( "\n" )
output.write(hex(int(value)).replace("0x", "").upper().zfill(2) + "h")

if (i != 15):
output.write(", ")

output.write("\n")
output.close()
50 changes: 24 additions & 26 deletions LUT/tempoTable.py
@@ -1,40 +1,38 @@
# hello world of python
# tempo table tab[32..255] = round(4096 * 150 / i)

output = open( "tempoTable.txt", "w" )
output.write( ";--------------------------------------------------------------------------------------------\n" )
output.write( "tempoTableL:\n" )
output.write( ";--------------------------------------------------------------------------------------------" )
output = open("tempoTable.txt", "w")
output.write(";--------------------------------------------------------------------------------------------\n")
output.write("tempoTableL:\n")
output.write(";--------------------------------------------------------------------------------------------")

for i in range(32, 256):

for i in range( 32, 256 ):
if ((i - 32) % 16 == 0):
output.write("\n\t.byte ")

if( (i-32) % 16 == 0 ):
output.write( "\n\t.byte " )

value = int( round( 4096.0 * 150.0 / i ) ) % 256

output.write( hex( int(value) ).replace("0x","").upper().zfill(3) + "h" )
value = int(round(4096.0 * 150.0 / i)) % 256

if( (i-32) % 16 != 15 ):
output.write( ", " )
output.write(hex(int(value)).replace("0x", "").upper().zfill(3) + "h")

output.write( "\n;--------------------------------------------------------------------------------------------\n" )
output.write( "tempoTableH:\n" )
output.write( ";--------------------------------------------------------------------------------------------" )
if ((i - 32) % 16 != 15):
output.write(", ")

output.write("\n;--------------------------------------------------------------------------------------------\n")
output.write("tempoTableH:\n")
output.write(";--------------------------------------------------------------------------------------------")

for i in range( 32, 256 ):
for i in range(32, 256):

if( (i-32) % 16 == 0 ):
output.write( "\n\t.byte " )

value = int( round( 4096.0 * 150.0 / i ) ) / 256

output.write( hex( int(value) ).replace("0x","").upper().zfill(3) + "h" )
if ((i - 32) % 16 == 0):
output.write("\n\t.byte ")

if( (i-32) % 16 != 15 ):
output.write( ", " )
value = int(round(4096.0 * 150.0 / i)) / 256

output.write( "\n" )
output.write(hex(int(value)).replace("0x", "").upper().zfill(3) + "h")

if ((i - 32) % 16 != 15):
output.write(", ")

output.write("\n")
output.close()
20 changes: 10 additions & 10 deletions LUT/vibratoTable.py
Expand Up @@ -4,17 +4,17 @@

from math import *

output = open( "vibratoTable.txt", "w" );
output.write( ";---------------------------------------------------------------------------------------------\n" );
output.write( "vibratoTable:\n" )
output.write( ";---------------------------------------------------------------------------------------------" );
output = open("vibratoTable.txt", "w");
output.write(";---------------------------------------------------------------------------------------------\n");
output.write("vibratoTable:\n")
output.write(";---------------------------------------------------------------------------------------------");

for i in range(0, 256):
pos = (i >> 4)
depth = (i & 15)
if( depth == 0 ):
output.write( "\n\t.byte " )
value = round(sin( pos * pi*2 / 4 / 16 ) * 64 * depth / 16)
output.write( hex( int(value) ).replace("0x","").upper().zfill(2) + "h" )
if( (i % 16) != 15 ):
output.write( ", " )
if (depth == 0):
output.write("\n\t.byte ")
value = round(sin(pos * pi * 2 / 4 / 16) * 64 * depth / 16)
output.write(hex(int(value)).replace("0x", "").upper().zfill(2) + "h")
if ((i % 16) != 15):
output.write(", ")

0 comments on commit 9a9e906

Please sign in to comment.