outsource sample generation

This commit is contained in:
Joachim Fenkes 2012-08-08 22:40:33 +02:00
parent 1eda2f81f9
commit c69b604480

View file

@ -135,23 +135,28 @@ static inline unsigned char voice_bass(unsigned long i)
return ((i >> 6) & 0xF) == 0xF ? 0 : ret; return ((i >> 6) & 0xF) == 0xF ? 0 : ret;
} }
void fill(char *data) static inline uint8_t next_sample()
{ {
static unsigned long i = 0;//x40000; static unsigned long i = 0;//x40000;
uint8_t ret = (voice_lead(i, 0) >> 1) + THREEQUARTERS(voice_lead(i, 1) >> 2) + (voice_lead(i, 2) >> 3) + (voice_bass(i) >> 2) + (voice_arp(i) >> 2);
i++;
if ((i >> 13) == ARPSIZE)
i = 16 << 13;
return ret;
}
void fill(char *data)
{
static uint8_t max = 0; static uint8_t max = 0;
for (int j = 0; j < 4096; j++) for (int j = 0; j < 4096; j++)
{ {
unsigned char sample = (voice_lead(i, 0) >> 1) + THREEQUARTERS(voice_lead(i, 1) >> 2) + (voice_lead(i, 2) >> 3) + (voice_bass(i) >> 2) + (voice_arp(i) >> 2); data[j] = next_sample();
data[j] = sample; if (data[j] > max)
if (sample > max)
{ {
max = sample; max = data[j];
printf("%x\n", max); printf("%x\n", max);
} }
i++;
if ((i >> 13) == ARPSIZE)
i = 16 << 13;
} }
} }