tidy up shit

This commit is contained in:
Joachim Fenkes 2012-08-11 00:18:27 +02:00
parent ff006c66b0
commit b38c9c7c04

View file

@ -46,13 +46,10 @@ const uint8_t arpseq1[4][4] = {
}; };
#endif #endif
const int arpseq2[] = { 0, 1, 0, 1, 0, 1, 0, 2, 3, 3 }; const int arpseq2[] = { 0, 1, 0, 1, 0, 1, 0, 2, 3, 3 };
//int arptiming[32] = { 4, 2, 4, 2, 4, 2, 4, 5, 1, 2, 2 }
const uint32_t arptiming = B32(00001100,00110000,11111011,00001100); const uint32_t arptiming = B32(00001100,00110000,11111011,00001100);
#define BASSSIZE ARPSIZE
const int bassbeat[8] = { 0, 0, 1, 0, 0, 1, 0, 1 }; const int bassbeat[8] = { 0, 0, 1, 0, 0, 1, 0, 1 };
const int bassline[BASSSIZE] = { const int bassline[] = {
12, 12, 15, 10, 12, 12, 17, 10, 12, 12, 15, 7, 8, 8, 3, 7, 12, 12, 15, 10, 12, 12, 17, 10, 12, 12, 15, 7, 8, 8, 3, 7,
8, 8, 10, 10, 12, 12, 5, 5, 8, 8, 10, 10, 8, 8, 10, 10, 12, 12, 5, 5, 8, 8, 10, 10,
}; };
@ -64,28 +61,6 @@ const uint8_t leadnotes[] = {
const uint8_t leadtimes[] = { const uint8_t leadtimes[] = {
1, 2, 3, 4, 5, 6, 28, 14 1, 2, 3, 4, 5, 6, 28, 14
}; };
const int leadmelody[] = {
12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14,
0, 12, 0, 14, 10, 0, 7, 0, 5, 7, 3, 1, 0, 0, 0, 0,
12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14,
0, 15, 0, 17, 19, 0, 22, 0, 24, 26, 27, 24, 0, 0, 0, 0,
12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14,
0, 12, 0, 14, 10, 0, 7, 0, 5, 7, 3, 1, 0, 0, 0, 0,
12, 7, 0, 12, 0, 14, 15, 0, 14, 0, 12, 0, 14, 15, 0, 14,
0, 15, 0, 17, 19, 0, 22, 0, 24, 26, 24, 20, 0, 0, 0, 0,
8, 3, 0, 8, 10, 12, 0, 14, 15, 19, 17, 0, 12, 7, 0, 12, 14, 15, 0, 14, 15, 19, 17, 0,
8, 3, 0, 8, 10, 12, 14, 0, 15, 19, 17, 15, 0, 14, 15, 17, 19, 0, 15, 14, 15, 12,
};
const int leadtiming[] = {
4, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 3, 1, 4, 2, 4, 6, 14, 14, 14, 14,
4, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 3, 1, 4, 2, 4, 6, 14, 14, 14, 14,
4, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 3, 1, 4, 2, 4, 6, 14, 14, 14, 14,
4, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 2, 2, 2, 2, 2, 5, 1, 3, 1, 4, 2, 4, 6, 14, 14, 14, 14,
4, 2, 2, 4, 2, 5, 1, 4, 4, 2, 6, 28, 4, 2, 2, 4, 2, 5, 1, 4, 4, 2, 6, 28,
4, 2, 2, 4, 2, 6, 2, 2, 4, 2, 6, 2, 2, 4, 2, 6, 2, 2, 4, 2, 4, 4,
};
const uint8_t leaddata[] = { const uint8_t leaddata[] = {
0x67, 0x24, 0x20, 0x27, 0x20, 0x28, 0x89, 0x0, 0x28, 0x20, 0x27, 0x20, 0x28, 0x89, 0x0, 0x28, 0x67, 0x24, 0x20, 0x27, 0x20, 0x28, 0x89, 0x0, 0x28, 0x20, 0x27, 0x20, 0x28, 0x89, 0x0, 0x28,
0x20, 0x27, 0x20, 0x28, 0x86, 0x0, 0x44, 0x0, 0x63, 0x24, 0x62, 0xA1, 0xE0, 0xE0, 0xE0, 0xE0, 0x20, 0x27, 0x20, 0x28, 0x86, 0x0, 0x44, 0x0, 0x63, 0x24, 0x62, 0xA1, 0xE0, 0xE0, 0xE0, 0xE0,
@ -102,9 +77,9 @@ struct leadvoice_s {
uint8_t ptr, timer; uint8_t ptr, timer;
uint16_t osc; uint16_t osc;
} leads[3] = { } leads[3] = {
{ LEADSIZE, 1, 0 }, { LEADSIZE, 0, 0 },
{ LEADSIZE, 3, 1601 }, { LEADSIZE, 0, 1601 },
{ LEADSIZE, 5, 3571 }, { LEADSIZE, 0, 3571 },
}; };
uint8_t boosts; uint8_t boosts;
@ -139,12 +114,8 @@ static unsigned char voice_lead(unsigned long i, int voice_nr)
uint8_t melody = leadnotes[leaddata[(leadseq[leadptr >> 4] << 4) | (leadptr & 0xF)] & 0x1F]; uint8_t melody = leadnotes[leaddata[(leadseq[leadptr >> 4] << 4) | (leadptr & 0xF)] & 0x1F];
int note = notes[melody]; // TODO remove this hack by using note table lead_osc += notes[melody];
lead_osc += note; uint8_t sample = ((lead_osc >> 6) & 0x7F) + ((lead_osc >> 6) & 0x3F);
// lead_flange += note + (i & 1);
uint8_t sample = ((lead_osc >> 6) & 0x7F) + ((lead_osc >> 6) & 0x3F);// + ((lead_flange >> 6) & 0x3F); // xor also sounds cool
//return (!melody) ? 0 : ((lead_osc >> 5) & 0x80) + ((lead_flange >> 6) & 0x3F);
//return (!melody) ? 0 : ((lead_osc & 0x1000) ? ((lead_osc >> 6) & 0x3F) | 0xC0 : 0x40 - ((lead_osc >> 6) & 0x3F));
return (melody == 0xFF) ? 0 : ((boosts & (1 << voice_nr)) ? sample : THREEQUARTERS(sample)); return (melody == 0xFF) ? 0 : ((boosts & (1 << voice_nr)) ? sample : THREEQUARTERS(sample));
} }
@ -162,7 +133,6 @@ static inline unsigned char voice_arp(unsigned long i)
int note = notes[arpnotes[arpptr & 0xF]]; int note = notes[arpnotes[arpptr & 0xF]];
arp_osc += note; arp_osc += note;
return ((arptiming & (1 << (31 - (i >> 9)))) && (arp_osc & (1 << 12)) && ((i >> 13) > 15)) ? 0 : 140; return ((arptiming & (1 << (31 - (i >> 9)))) && (arp_osc & (1 << 12)) && ((i >> 13) > 15)) ? 0 : 140;
//return ((arp_osc >> 5) & 128) - 1;
} }
static inline unsigned char voice_bass(unsigned long i) static inline unsigned char voice_bass(unsigned long i)
@ -182,7 +152,7 @@ static inline unsigned char voice_bass(unsigned long i)
static inline uint8_t next_sample() static inline uint8_t next_sample()
{ {
static unsigned long i = 0x40000; 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); 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++; i++;
if ((i >> 13) == ARPSIZE) if ((i >> 13) == ARPSIZE)
@ -211,18 +181,6 @@ static const WAVEFORMATEX fmt = {
int main(int argc, char *argv[]) int main(int argc, char *argv[])
{ {
for (int i = 0; i < LEADSIZE; i++)
{
int note, time;
for (note = 0; note < 17; note++)
if (leadnotes[note] == leadmelody[i])
break;
for (time = 0; time < 8; time++)
if (leadtimes[time] == leadtiming[i])
break;
printf("0x%X, ", note | (time << 5));
}
HWAVEOUT out; HWAVEOUT out;
HRESULT rc = waveOutOpen(&out, WAVE_MAPPER, &fmt, NULL, NULL, CALLBACK_NULL); HRESULT rc = waveOutOpen(&out, WAVE_MAPPER, &fmt, NULL, NULL, CALLBACK_NULL);
if (rc != MMSYSERR_NOERROR) if (rc != MMSYSERR_NOERROR)