diff --git a/converter/05 African Mines.vgz b/converter/05 African Mines.vgz new file mode 100644 index 0000000..81a1287 Binary files /dev/null and b/converter/05 African Mines.vgz differ diff --git a/converter/CONVERT_VGZ_TO_ARDUINO.bat b/converter/CONVERT_VGZ_TO_ARDUINO.bat index ed3c83e..50db807 100644 --- a/converter/CONVERT_VGZ_TO_ARDUINO.bat +++ b/converter/CONVERT_VGZ_TO_ARDUINO.bat @@ -1 +1,2 @@ -"c:\Python27\python.exe" vgm_to_arduino.py %1 \ No newline at end of file +python.exe ./vgm_to_arduino.py %1 +pause \ No newline at end of file diff --git a/converter/vgm_to_arduino.py b/converter/vgm_to_arduino.py index 1f611a0..286fcad 100644 --- a/converter/vgm_to_arduino.py +++ b/converter/vgm_to_arduino.py @@ -4,36 +4,43 @@ import sys dropped_file = sys.argv[1] -print dropped_file +print(dropped_file) try: - with gzip.open(dropped_file, mode='r', compresslevel=9) as f: - data = f.read() + with gzip.open(dropped_file, mode='rb', compresslevel=9) as f: + data = f.read() - out_array = ""; - - iter = 0 - for i in range(len(data)): - hex_item = hex(ord(data[i])) - if len(hex_item) < 4: - hex_item = hex_item[0]+hex_item[1]+"0"+hex_item[2] - - out_array += hex_item - out_array += ", " - - iter+=1 - if iter == 150: - iter = 0 - out_array += "\n " - - out_array = out_array[:-2] - out_array = out_array.upper() - out_array = out_array.replace('X','x') - - out_array = "uint8_t music[] = {\n " + out_array + "\n};" - - with open("vgm_arduino.txt.","w+") as f: - f.write(out_array) + out_array = ""; + + iter = 0 + for i in range(len(data)): + hex_item = hex(data[i]) + if len(hex_item) < 4: + hex_item = hex_item[0]+hex_item[1]+"0"+hex_item[2] + + out_array += hex_item + out_array += ", " + + iter+=1 + if iter == 150: + iter = 0 + out_array += "\n " + + out_array = out_array[:-2] + out_array = out_array.upper() + out_array = out_array.replace('X','x') + + out_array = "uint8_t music[] = {\n " + out_array + "\n};" + + print(out_array) + + with open("vgm_arduino.txt.","w+") as f: + f.write(out_array) + + print("\n------------------------------------------------------"); + print( "Conversion complete, output stored in vgm_arduino.txt!") + print( "------------------------------------------------------"); + except: - traceback.print_exc() - time.sleep(10) \ No newline at end of file + traceback.print_exc() + time.sleep(10) \ No newline at end of file diff --git a/src/Cartridge.cpp b/src/Cartridge.cpp index b0b75ae..6e303b3 100644 --- a/src/Cartridge.cpp +++ b/src/Cartridge.cpp @@ -20,20 +20,16 @@ void Cartridge::frame_counter_cb(void (*action)()){ } void Cartridge::init(){ - sigmaDeltaSetup(p1_channel, 88200); - sigmaDeltaAttachPin(p1_pin, p1_channel); + sigmaDeltaSetup(p1_pin, p1_channel, 88200); sigmaDeltaWrite(p1_channel, 0); - sigmaDeltaSetup(p2_channel, 88200); - sigmaDeltaAttachPin(p2_pin, p2_channel); + sigmaDeltaSetup(p2_pin, p2_channel, 88200); sigmaDeltaWrite(p2_channel, 0); - sigmaDeltaSetup(n_channel, 88200); - sigmaDeltaAttachPin(n_pin, n_channel); + sigmaDeltaSetup(n_pin, n_channel, 88200); sigmaDeltaWrite(n_channel, 0); - sigmaDeltaSetup(t_channel, 88200); - sigmaDeltaAttachPin(t_pin, t_channel); + sigmaDeltaSetup(t_pin, t_channel, 88200); sigmaDeltaWrite(t_channel, 0); }