Commit 3b6d55eb authored by Erik Faye-Lund's avatar Erik Faye-Lund
Browse files

pimp-config: change parameterization of herts to periods

parent 1d0a1cab
...@@ -9,10 +9,20 @@ ...@@ -9,10 +9,20 @@
/* 32 is the maximum amount of channels in fasttracker2. a nice default. */ /* 32 is the maximum amount of channels in fasttracker2. a nice default. */
#define PIMP_CHANNEL_COUNT 32 #define PIMP_CHANNEL_COUNT 32
/* check the sample-rate calculator at http://www.pineight.com/gba/samplerates/ for more glitch-free samplerates */ /* check the sample-rate calculator at http://www.pineight.com/gba/samplerates/ for more glitch-free periods */
/* 0x4000100 = 0xFFFF, 0x4000102 = 0x0083 */
#define PIMP_GBA_SAMPLERATE (18157.16) #if 0
/* #define PIMP_SAMPLERATE (31536.12) */ #define PIMP_GBA_PERIOD (532) /* 31536.12 */
#define PIMP_GBA_PERIOD (627) /* 26757.92 */
#define PIMP_GBA_PERIOD (798) /* 21024.08 */
#define PIMP_GBA_PERIOD (836) /* 20068.44 */
#endif
#define PIMP_GBA_PERIOD (924) /* 18157.16 */
#if 0
#define PIMP_GBA_PERIOD (1254) /* 13378.96 */
#define PIMP_GBA_PERIOD (1463) /* 11467.68 */
#define PIMP_GBA_PERIOD (1596) /* 10512.04 */
#endif
/* enable / disable assert */ /* enable / disable assert */
/* #define DEBUG_PRINT_ENABLE */ /* #define DEBUG_PRINT_ENABLE */
......
...@@ -58,21 +58,21 @@ static struct pimp_mixer pimp_gba_mixer IWRAM_DATA; ...@@ -58,21 +58,21 @@ static struct pimp_mixer pimp_gba_mixer IWRAM_DATA;
static struct pimp_mod_context pimp_gba_ctx EWRAM_DATA; static struct pimp_mod_context pimp_gba_ctx EWRAM_DATA;
/* setup some constants */ /* setup some constants */
static const float samplerate = (float)(1 << 24) / PIMP_GBA_PERIOD;
#define CYCLES_PR_FRAME 280896 #define CYCLES_PR_FRAME 280896
#define CYCLES_PR_SAMPLE ((int)((1 << 24) / ((float)PIMP_GBA_SAMPLERATE))) #define SOUND_BUFFER_SIZE (CYCLES_PR_FRAME / PIMP_GBA_PERIOD)
#define SOUND_BUFFER_SIZE ((int)((float)CYCLES_PR_FRAME / CYCLES_PR_SAMPLE))
/* mix and playback-buffers */ /* mix and playback-buffers */
static s8 pimp_gba_sound_buffers[2][SOUND_BUFFER_SIZE] IWRAM_DATA; static s8 pimp_gba_sound_buffers[2][SOUND_BUFFER_SIZE];
static u32 pimp_gba_sound_buffer_index = 0; static u32 pimp_gba_sound_buffer_index = 0;
static s32 pimp_gba_mix_buffer[SOUND_BUFFER_SIZE] IWRAM_DATA; static s32 pimp_gba_mix_buffer[SOUND_BUFFER_SIZE];
void pimp_gba_init(const struct pimp_module *module, const void *sample_bank) void pimp_gba_init(const struct pimp_module *module, const void *sample_bank)
{ {
u32 zero = 0; u32 zero = 0;
pimp_gba_mixer.mix_buffer = pimp_gba_mix_buffer; pimp_gba_mixer.mix_buffer = pimp_gba_mix_buffer;
pimp_mod_context_init(&pimp_gba_ctx, (const pimp_module*)module, (const u8*)sample_bank, &pimp_gba_mixer, PIMP_GBA_SAMPLERATE); pimp_mod_context_init(&pimp_gba_ctx, (const pimp_module*)module, (const u8*)sample_bank, &pimp_gba_mixer, samplerate);
/* call BIOS-function CpuFastSet() to clear buffer */ /* call BIOS-function CpuFastSet() to clear buffer */
CpuFastSet(&zero, &pimp_gba_sound_buffers[0][0], DMA_SRC_FIXED | ((SOUND_BUFFER_SIZE / 4) * 2)); CpuFastSet(&zero, &pimp_gba_sound_buffers[0][0], DMA_SRC_FIXED | ((SOUND_BUFFER_SIZE / 4) * 2));
REG_SOUNDCNT_H = SNDA_VOL_100 | SNDA_L_ENABLE | SNDA_R_ENABLE | SNDA_RESET_FIFO; REG_SOUNDCNT_H = SNDA_VOL_100 | SNDA_L_ENABLE | SNDA_R_ENABLE | SNDA_RESET_FIFO;
...@@ -81,7 +81,7 @@ void pimp_gba_init(const struct pimp_module *module, const void *sample_bank) ...@@ -81,7 +81,7 @@ void pimp_gba_init(const struct pimp_module *module, const void *sample_bank)
DEBUG_PRINT(DEBUG_LEVEL_INFO, ("samples pr frame: 0x%x\nsound buffer size: %d\n", SAMPLES_PR_FRAME, SOUND_BUFFER_SIZE)); DEBUG_PRINT(DEBUG_LEVEL_INFO, ("samples pr frame: 0x%x\nsound buffer size: %d\n", SAMPLES_PR_FRAME, SOUND_BUFFER_SIZE));
/* setup timer */ /* setup timer */
REG_TM0CNT_L = (1 << 16) - CYCLES_PR_SAMPLE; REG_TM0CNT_L = (1 << 16) - PIMP_GBA_PERIOD;
REG_TM0CNT_H = TIMER_START; REG_TM0CNT_H = TIMER_START;
} }
......
Markdown is supported
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