begin work on fov120 fov120
authorslack <slack@codemaniacs.com>
Mon, 7 Dec 2009 02:44:25 +0000 (03:44 +0100)
committerslack <slack@codemaniacs.com>
Mon, 7 Dec 2009 02:44:25 +0000 (03:44 +0100)
Makefile
lolailo.c
play.c
song.h
synth.c
thesong.c

index 5acfe1bf8aa01375cf1c96ef3d4b12ac695fe21f..d849a7978cc4bd3947f322c21deb3574f816a3ee 100644 (file)
--- 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
index 5b1834f6001cee6f83e02323b3a3874aaf1503a6..f7abcf5a532223a0175ebc665a0eef03b2a6b580 100644 (file)
--- 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 91a79bb98c44a7b5e2d2c1d3dcc93b365baea07f..a871dd682389b578047f8bea0e6c5c02439d6a12 100644 (file)
--- a/play.c
+++ b/play.c
@@ -6,7 +6,7 @@
 #include <string.h>
 
 
-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 012735aaad647d99507d81486d9b451a54520f6a..4a56c368ca1e3b600811c09ecc958d295b59a559 100644 (file)
--- 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 f65971b2f0af1cb2b9cdcd46d2563ddcc915d281..1c5ea43c249ca0983475d044d55fcb9f24c71d5e 100644 (file)
--- 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; i<len; i++) {
-            float pitch = detune(v->pitch, (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;
                     }
 
index 48b3a95aa32d0ffc98be40442828a724c9ddc665..fa8dc79ecee9f0e4252e13697390e78f43d7457a 100644 (file)
--- 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,