Commit 13e7189c authored by Erik Faye-Lund's avatar Erik Faye-Lund
Browse files

new python based lut generator. also moved the define for the amiga-lut to the...

new python based lut generator. also moved the define for the amiga-lut to the generator (and exporting it to the header)
added a place-holder for the example-player script to add tunes to gbfs

git-svn-id: https://pimpmobile.svn.sourceforge.net/svnroot/pimpmobile/trunk@163 3d5ecaf0-f903-0410-b953-c2c1a4d75763
parent b01d03b0
#!/usr/bin/python
# -*- coding: latin-1 -*-
# lut_gen.cpp -- Look-up table generator for Pimpmobile
# Copyright (C) 2005-2006 Jrn Nystad and Erik Faye-Lund
# For conditions of distribution and use, see copyright notice in LICENSE.TXT
import sys
AMIGA_DELTA_LUT_LOG_SIZE = 7
AMIGA_DELTA_LUT_SIZE = 1 << AMIGA_DELTA_LUT_LOG_SIZE
AMIGA_DELTA_LUT_FRAC_BITS = 15 - AMIGA_DELTA_LUT_LOG_SIZE
def print_lut(lut):
print 'const u16 linear_delta_lut[768] =\n{'
for e in lut:
print '%d,' % (e),
print '\n};\n'
def print_lut_to_file(file, lutname, lut):
file.write('const u16 %s[%d] =\n{\n\t' % (lutname, len(lut)))
line_start = file.tell()
for e in lut:
file.write('%d, ' % e)
if file.tell() > (line_start + 80):
file.write('\n\t')
line_start = file.tell()
file.write('\n};\n\n')
def gen_linear_delta_lut():
lut = []
for i in range(0, 12 * 64):
val = int(((2.0 ** (i / 768.0)) * 8363.0 / (1 << 8)) * float(1 << 9) + 0.5)
lut.append(val)
return lut
def gen_amiga_delta_lut():
lut = []
for i in range(0, (AMIGA_DELTA_LUT_SIZE / 2) + 1):
p = i + (AMIGA_DELTA_LUT_SIZE / 2);
val = int(((8363 * 1712) / float((p * 32768) / AMIGA_DELTA_LUT_SIZE)) * (1 << 6) + 0.5);
lut.append(val)
return lut
linear_delta_lut = gen_linear_delta_lut()
f = open('src/linear_delta_lut.h', 'w')
print_lut_to_file(f, 'linear_delta_lut', linear_delta_lut)
f.close()
amiga_delta_lut = gen_amiga_delta_lut()
f = open('src/amiga_delta_lut.h', 'w')
f.write('#define AMIGA_DELTA_LUT_LOG_SIZE %d\n' % (AMIGA_DELTA_LUT_LOG_SIZE))
print_lut_to_file(f, 'amiga_delta_lut', amiga_delta_lut)
f.close()
#!/bin/sh
bin/converter eye.mod
gbfs data.gbfs sample_bank.bin eye.mod.bin
copy /B example.bin+data.gbfs example.gba
#define AMIGA_DELTA_LUT_LOG_SIZE 7
const u16 amiga_delta_lut[65] =
{
55928, 55067, 54233, 53423, 52638, 51875, 51134, 50414, 49713, 49032, 48370, 47725,
......
......@@ -19,7 +19,7 @@ const u16 linear_delta_lut[768] =
19891, 19909, 19927, 19945, 19963, 19981, 19999, 20017, 20035, 20053, 20071, 20089,
20107, 20125, 20144, 20162, 20180, 20198, 20216, 20235, 20253, 20271, 20290, 20308,
20326, 20345, 20363, 20381, 20400, 20418, 20437, 20455, 20474, 20492, 20511, 20529,
20548, 20566, 20585, 20603, 20622, 20641, 20659, 20678, 20696, 20715, 20734, 20753,
20548, 20566, 20585, 20603, 20622, 20640, 20659, 20678, 20696, 20715, 20734, 20753,
20771, 20790, 20809, 20828, 20846, 20865, 20884, 20903, 20922, 20941, 20960, 20979,
20997, 21016, 21035, 21054, 21073, 21092, 21112, 21131, 21150, 21169, 21188, 21207,
21226, 21245, 21264, 21284, 21303, 21322, 21341, 21361, 21380, 21399, 21419, 21438,
......
......@@ -15,13 +15,6 @@
/* #define SAMPLERATE (16384) */
#define SAMPLERATE 15768.06
/* only 130 bytes big, quite damn pleasing results */
#define AMIGA_DELTA_LUT_LOG_SIZE 7
/* derivated settings. don't touch. */
#define AMIGA_DELTA_LUT_SIZE (1 << AMIGA_DELTA_LUT_LOG_SIZE)
#define AMIGA_DELTA_LUT_FRAC_BITS (15 - AMIGA_DELTA_LUT_LOG_SIZE)
/* enable / disable assert */
/*
#define DEBUG_PRINT_ENABLE
......
......@@ -87,6 +87,8 @@ unsigned __pimp_get_amiga_period(int note, int fine_tune)
}
#include "amiga_delta_lut.h"
#define AMIGA_DELTA_LUT_SIZE (1 << AMIGA_DELTA_LUT_LOG_SIZE)
#define AMIGA_DELTA_LUT_FRAC_BITS (15 - AMIGA_DELTA_LUT_LOG_SIZE)
unsigned __pimp_get_amiga_delta(unsigned period)
{
unsigned shamt = clz16(period) - 1;
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment