From: slack Date: Mon, 7 Dec 2009 02:44:25 +0000 (+0100) Subject: begin work on fov120 X-Git-Url: http://slack.codemaniacs.com/git/?a=commitdiff_plain;h=refs%2Fheads%2Ffov120;p=lolailo.git begin work on fov120 --- diff --git a/Makefile b/Makefile index 5acfe1b..d849a79 100644 --- a/Makefile +++ b/Makefile @@ -1,11 +1,9 @@ CC=gcc -m32 CFLAGS=-std=c99 -Os -Wall -g \ - -march=pentium4 -ffast-math -nodefaultlibs \ - -fomit-frame-pointer -fno-strict-aliasing -fno-common \ - -fpeephole2 -fexpensive-optimizations -frerun-cse-after-loop \ + -march=core2 -ffast-math \ $(shell sdl-config --cflags) -LDFLAGS=-lSDL-1.2 -nostartfiles +LDFLAGS=-lSDL-1.2 all: lolailo bash print_sizes.sh diff --git a/lolailo.c b/lolailo.c index 5b1834f..f7abcf5 100644 --- a/lolailo.c +++ b/lolailo.c @@ -31,11 +31,7 @@ extern float current_time; extern float row_duration; extern Voice voices[NUM_CHANNELS]; -#ifdef DEBUG int main(int argc, char *argv[]) -#else -void _start() -#endif { #ifdef OUTFILE fout = fopen(OUTFILE, "wb"); @@ -120,7 +116,7 @@ void _start() if (ev.type == SDL_QUIT) goto end; } - if (!paused) + if (!paused && argc == 1) { memset(video->pixels, 0, video->pitch*video->h); uint32 *p = (uint32*) video->pixels; @@ -142,7 +138,6 @@ void _start() y0=y1; } SDL_Flip(video); - SDL_Delay(20); if ((current_time - last) > 1.0f) { last = current_time; @@ -150,6 +145,7 @@ void _start() fflush(stdout); } } + SDL_Delay(20); } end: diff --git a/play.c b/play.c index 91a79bb..a871dd6 100644 --- a/play.c +++ b/play.c @@ -6,7 +6,7 @@ #include -float row_duration=60.0f/340.0f; // denominator == RPM +float row_duration=60.0f/240.0f; // denominator == RPM Voice voices[NUM_CHANNELS]; float mix_buf[BUFFER_SIZE]={0}; uint8 last_voice_used=0; @@ -59,7 +59,7 @@ void play(void *s, uint8 *stream, int len) uint8 cell=cur_trk->notes[cur_row]; if (cell) { - float vol = (cell>>4) * 0.125f; + float vol = (cell>>4) * 0.0625f; unsigned int note = cell & 0x0F; note+=trans; diff --git a/song.h b/song.h index 012735a..4a56c36 100644 --- a/song.h +++ b/song.h @@ -13,8 +13,8 @@ #define NUM_CHANNELS 8 #define NUM_TRACKS 16 #define TRACK_LENGTH 12 -#define INSTRUMENT_DATA_LENGTH 193 -#define PLAYLIST_LENGTH 49 +#define INSTRUMENT_DATA_LENGTH 400 +#define PLAYLIST_LENGTH 200 typedef struct { diff --git a/synth.c b/synth.c index f65971b..1c5ea43 100644 --- a/synth.c +++ b/synth.c @@ -33,19 +33,18 @@ void synth(Voice *v, int len, float *mix_buf) uint8 op1 = v->ins[iPC++]; uint8 op2 = v->ins[iPC++]; //printf("wave %d, ins=%d (%d, %d)\n", wave, ins, op1, op2); + float pitch = detune(v->pitch, (int8) op1, 0); + float pw = op2/100.0f; + float period = 1.0f/pitch; // wave period (in seconds) for (int i=0; ipitch, (int8) op1, 0); float time=(v->pos+i)*invSAMPLE_RATE; - float pw = op2/100.0f; - float period = 1.0f/pitch; // wave period (in seconds) float op1_sample = v->waves[wave-op1][i]; float prev_sample = v->waves[wave-1][i]; switch (ins) { case CONST: { // op1: integer part, op2: decimal part * 100 - float value = ((int8) op1) + ((int8) op2/100.0f); - v->waves[wave][i] = value; + v->waves[wave][i] = ((int8) op1) + ((int8) op2/100.0f); break; } diff --git a/thesong.c b/thesong.c index 48b3a95..fa8dc79 100644 --- a/thesong.c +++ b/thesong.c @@ -3,69 +3,31 @@ Song thesong={ { // begin patterns - {0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0 - wind 1 - {0x01, 0x00, 0x03, 0x00, 0x00, 0x00, 0x00, 0x00}, // 1 - wind 2 - {0x00, 0x02, 0x00, 0x04, 0x00, 0x00, 0x00, 0x00}, // 2 - wind 3 - {0x02, 0x01, 0x05, 0x00, 0x00, 0x00, 0x00, 0x00}, // 3 - bongo+wind - {0x07, 0x0c, 0x01, 0x02, 0x05, 0x00, 0x00, 0x00}, // 4 - bongo+bass1 - {0x07, 0x0b, 0x01, 0x03, 0x05, 0x00, 0x00, 0x00}, // 5 - bongo+bass2 - {0x07, 0x0b, 0x01, 0x02, 0x05, 0x00, 0x00, 0x00}, // 6 - bongo+bass1 - {0x07, 0x03, 0x02, 0x05, 0x00, 0x00, 0x00, 0x00}, // 7 - bongo+bass2 - {0x07, 0x06, 0x06, 0x06, 0x08, 0x09, 0x0c, 0x05}, // 8 - bongo+piano+bass1+melody1 - {0x07, 0x06, 0x06, 0x06, 0x00, 0x00, 0x0b, 0x05}, // 9 - bongo+piano+bass1+melody2 - {0x07, 0x06, 0x06, 0x06, 0x08, 0x0b, 0x00, 0x05}, // 10 - bongo+piano+bass1+melody3 - {0x07, 0x06, 0x06, 0x06, 0x0a, 0x00, 0x00, 0x05}, // 11 - bongo+piano+bass1+melody4 - {0x07, 0x06, 0x06, 0x06, 0x05, 0x00, 0x00, 0x00}, // 12 - bongo+bass1+piano - {0x07, 0x06, 0x06, 0x06, 0x05, 0x00, 0x00, 0x00}, // 13 - bongo+bass1+piano - {0x07, 0x06, 0x06, 0x06, 0x0d, 0x05, 0x00, 0x00}, // 14 - bongo+piano+bass1+melody5 - {0x07, 0x06, 0x06, 0x06, 0x0e, 0x05, 0x00, 0x00}, // 15 - bongo+piano+bass1+melody6 - {0x07, 0x06, 0x06, 0x06, 0x0f, 0x05, 0x00, 0x00}, // 16 - bongo+piano+bass1+melody7 + {0x01, 0x02, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}, // 0 + {0x00, 0x00, 0x01, 0x02, 0x00, 0x00, 0x00, 0x00}, // 0 }, // end patterns { // begin txpose - {-15,0}, // 0 - wind1 - {-9,0,-3}, // 1 - wind2 - {0,-20,0,-5}, // 2 - wind3 - {-15,0,0}, // 3 - bongo - {9,21,-15,-9,0}, // 4 - bongo+bass1 - {9,23,-15,-3,0}, // 5 - bongo+bass1 - {6,21,-15,-9,0}, // 6 - bongo+bass1 - {6,-3,-9,0}, // 7 - bongo+bass1 - {9,7,11,14,21,21,21,0}, // 8 - bongo+piano+bass1+melody1 - {9,7,11,14,23,23,23,0}, // 9 - bongo+piano+bass1+melody2 - {6,7,11,16,21,21,21,0}, // 10 - bongo+piano+bass1+melody3 - {6,7,11,16,21,21,21,0}, // 11 - bongo+piano+bass1+melody4 - {9,7,11,14,0}, // 12 - bongo+bass1+piano - {6,7,11,16,0}, // 13 - bongo+bass1+piano - {9,7,11,14,25,0}, // 14 - bongo+piano+bass1+melody5 - {9,7,11,14,25,0}, // 15 - bongo+piano+bass1+melody6 - {6,7,11,16,25,0}, // 16 - bongo+piano+bass1+melody6 + {-17, -10, -17, -10}, // 0 + {-17, -10, -17, -10}, // 0 }, // end txpose { // begin tracks {{0,0,0,0,0,0,0,0,0,0,0,0}, 0}, - {{0x44,0,0,0,0,0,0,0,0,0,0,0}, 19}, // 1 - wind - {{0,0,0,0,0,0,0x31,0,0,0,0,0}, 19}, // 2 - wind - {{0,0,0,0,0,0,0,0,0,0,0x21,0}, 19}, // 3 - wind - {{0,0,0,0x51,0,0,0,0,0,0,0,0}, 19}, // 4 - wind - {{0,0,0,0xb4,0x74,0xa4,0,0,0,0xa4,0,0xa4,}, 0}, // 5 - bongo rhythm - {{0,0,0,0xf1,0,0xb1,0,0,0,0xf1,0,0}, 53}, // 6 - piano rhythm - {{0x57,0,0x17,0x37,0,0,0x52,0,0,0x37,0,0,}, 93}, // 7 - bassline 1 - {{0x6b,0,0,0x6b,0,0,0x6b,0,0,0x6c,0,0}, 115}, // 8 - {{0,0,0,0,0,0,0,0,0,0,0,0x6e}, 143}, // 9 - {{0x6b,0,0x69,0,0,0x67,0,0,0,0,0,0}, 115}, // a - {{0,0,0,0,0,0,0,0,0,0,0,0x6e}, 171}, // b - {{0x6e,0,0,0,0,0x6c,0x6b,0,0x6c,0,0,0x6e}, 171}, // c - {{0x6f,0,0,0x6e,0,0,0x6c,0,0,0x6a,0,0}, 115}, // d - melody 5 - {{0x67,0,0,0x65,0,0x63,0,0,0,0,0,0}, 115}, // e - melody 6 - {{0x6c,0,0,0x60,0,0x60,0,0,0x62,0x63,0,0}, 115}, // f - melody 7 + {{0x84,0,0,0,0,0,0,0,0,0,0,0}, 0}, // 1 - wind + {{0x44,0,0,0,0,0,0,0,0,0,0,0}, 0}, // 1 - wind }, // end tracks { // begin instrument data // 0 (bongo) - SIGMOID,10,1, - TRIANGLE,24,50, - LPF,2,40, - MUL,3,0, - CONST,8,0, + SIGMOID,1,30, + SIGMOID,-5,11, MUL,2,0, + TRIANGLE,0,50, + SQUARE,12,50, + SUM,2,0, + MUL,4,0, + HPF,5,10, + SUM,2,0, + LPF,9,10, + MUL,8,0, END, // 19 (wind) SIGMOID,2,15, @@ -138,7 +100,7 @@ Song thesong={ }, // end instrument data { // begin playlist - 0,1,2,1, + 0,1,0,1, 3,3,3,3, 4,5,6,7, 4,5,6,7,