float drawbuf[BUFFER_SIZE];
+#ifdef OUTFILE
+FILE *fout;
+#endif
+
+
#ifdef DEBUG
int main(int argc, char *argv[])
#else
void _start()
#endif
{
+ #ifdef OUTFILE
+ fout = fopen(OUTFILE, "wb");
+ #endif
+
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO);
SDL_Surface *video = SDL_SetVideoMode(BUFFER_SIZE,480,32,SDL_SWSURFACE | SDL_DOUBLEBUF);
SDL_OpenAudio(&desired, NULL);
}
end:
+ #ifdef OUTFILE
+ fclose(fout);
+ #endif
SDL_Quit();
_exit(0);
//return error;
#include <string.h>
-#define NUM_VOICES 3
+#define NUM_VOICES 20
-float row_duration=60.0f/570.0f; // denominator == RPM
+float row_duration=60.0f/320.0f; // denominator == RPM
Voice voices[NUM_VOICES];
float mix_buf[BUFFER_SIZE]={0};
uint8 last_voice_used=0;
float current_time=0.0f;
uint32 rows_played=0; // total of rows played
-uint8 cur_pos= 0; // current position in the pattern playlist
-uint8 cur_row=-1; // current row in the current pattern
+uint8 cur_pos= 255; // current position in the pattern playlist
+int8 cur_row=-1; // current row in the current pattern
extern float drawbuf[BUFFER_SIZE];
+#ifdef OUTFILE
+extern FILE *fout;
+#endif
+
void play(void *s, uint8 *stream, int len)
{
Song *song = (Song*) s;
}
uint8 cur_ptn=song->playlist[cur_pos];
+ //printf("rows_played=%d, cur_pos=%d, cur_ptn=%d, cur_row=%d\n", rows_played, cur_pos, cur_ptn, cur_row);
/*
for (i=0; i<NUM_RHYTHM_CHANNELS; ++i) {
unsigned int note = (cur_trk->notes[cur_row] & 0x0F);
if (note) {
- float vol = ((cur_trk->notes[cur_row])>>4) * 0.0625f;
+ float vol = ((cur_trk->notes[cur_row])>>4) * 0.125f;
note+=trans;
uint8 j = last_voice_used;
voices[j].pitch = detune(440.0f,note-21,0);
voices[j].pos = buf_start;
voices[j].ins = &song->instrument_data[cur_trk->instrument];
- voices[j].vol = 0.19921875f*vol;
+ voices[j].vol = vol;
voices[j].active = 1;
}
}
#include "sizedtypes.h"
void play(void *songdata, uint8 *stream, int len);
+//#define OUTFILE "salida.raw"
#endif // PLAY_H
// + PLAYLIST_LENGTH
#define NUM_PATTERNS 20
-#define NUM_CHANNELS 4
+#define NUM_CHANNELS 8
#define NUM_TRACKS 15
-#define TRACK_LENGTH 16
-#define INSTRUMENT_DATA_LENGTH 100
+#define TRACK_LENGTH 12
+#define INSTRUMENT_DATA_LENGTH 200
#define PLAYLIST_LENGTH 50
typedef struct
typedef struct
{
uint8 patterns[NUM_PATTERNS][NUM_CHANNELS];
- int8 transpose[NUM_PATTERNS][NUM_CHANNELS];
+ int8 transpose[NUM_PATTERNS][NUM_CHANNELS];
Track tracks[NUM_TRACKS];
uint8 instrument_data[INSTRUMENT_DATA_LENGTH];
uint8 playlist[PLAYLIST_LENGTH];
switch (ins) {
case CONST:
{
- float value = ((int8) op1/10.0);
+ float value = ((int8) op1) + ((int8) op2/100.0);
v->waves[wave][i] = value;
break;
}
v->waves[wave][i] = 1.0f - 1.0f/(1.0f+expf(-f*(time-d)));
break;
}
-
+
default:
goto end;
}
end:
v->pos+=len;
for (int i=0; i<len; i++)
- mix_buf[i] += v->waves[wave-1][i];
+ mix_buf[i] += v->waves[wave-1][i]*v->vol;
return 1;
}
#define HPF 7
#define NOISE 8
#define SIGMOID 9
+#define ENDI 254
#define END 255
extern uint8 synth(Voice *v, int len, float *mix_buf);
Song thesong={
{ // begin patterns
- {0x01, 0x02, 0x03, 0x00},
+ {0x01, 0x01, 0x01, 0x03, 0x04, 0x02, 0x00, 0x00},
+ {0x00, 0x00, 0x00, 0x03, 0x04, 0x02, 0x00, 0x00},
}, // end patterns
{ // begin txpose
- {-12, 0, 0, 0},
+ {0, -9, -5, 24, -12},
+ {0, -9, -5, 24, -12},
}, // end txpose
{ // begin tracks
- {{45,0,0,0,45,0,0,0,45,0,0,0,45,0,0,0}, 0},
+ {{0x14,0,0,0,0,0,0,0,0,0,0,0}, 0},
+ {{45,0,0,45,0,0,45,0,0,45,0,0}, 46},
+ {{0xF4,0x74,0x24,0xF4,0x74,0x24,0xF4,0x74,0x24,0xF4,0x74,0x24,}, 65},
+ {{0xf4,0,0,0,0,0xfb,0xf4,0,0,0xf2,0,0}, 65},
}, // end tracks
{ // begin instrument data
- SIGMOID,15,0,
- NOISE,0,30,
+ CONST,0,35,
+ CONST,0,25,
+ SUM,1,2,
+ SINE,0,0,
+ SQUARE,12,50,
+ SINE,-12,1,
+ SUM,2,3,
+ SUM,1,2,
+ CONST,0,13,
+ MUL,1,2,
+ LPF,8,10,
+ LPF,10,0,
+ SIGMOID,-10,5,
+ SIGMOID,1,10,
+ MUL,1,2,
+ MUL,1,4,
+ ENDI,
+ // 43
+ SIGMOID,12,0,
+ NOISE,0,0,
LPF,2,40,
- END,
+ MUL,1,3,
+ CONST,100,0,
+ MUL,1,2,
+ ENDI,
+ //19
+ SIGMOID,10,1,
+ SQUARE,0,20,
+ LPF,2,20,
+ MUL,1,3,
+ END,
}, // end instrument data
{ // begin playlist
- 0,255,
+ 1,255,
}, // end playlist
};