You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
91 lines
1.9 KiB
91 lines
1.9 KiB
#include <stdio.h>
|
|
#include <unistd.h>
|
|
#include <syslog.h>
|
|
#include <string.h>
|
|
#include <math.h>
|
|
|
|
#include "SDL.h"
|
|
#include "SDL_mixer.h"
|
|
#include "SDL_image.h"
|
|
|
|
#define NUM_WAVEFORMS 4
|
|
#define PATTERN_ROWS 10
|
|
#define PATTERN_COLS 32
|
|
|
|
Mix_Chunk* samples[NUM_WAVEFORMS];
|
|
SDL_Window* window;
|
|
SDL_Renderer* renderer;
|
|
|
|
int pattern[PATTERN_ROWS][PATTERN_COLS];
|
|
int matrix[] = {PATTERN_ROWS, PATTERN_COLS};
|
|
bool play = false;
|
|
bool setErease = false;
|
|
int step = 0;
|
|
|
|
#include "draw.cpp"
|
|
#include "players.cpp"
|
|
#include "loaders.cpp"
|
|
#include "inputs.cpp"
|
|
#include "actions.cpp"
|
|
|
|
int main(int argc, char** argv) {
|
|
|
|
bool done = false;
|
|
int timer = 0;
|
|
int stepDuration = 200;
|
|
|
|
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO );
|
|
atexit(SDL_Quit);
|
|
|
|
window = SDL_CreateWindow("Sonquencer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 600, 300, 0);
|
|
renderer = SDL_CreateRenderer(window, -1, 0);
|
|
|
|
SDL_SetRenderDrawColor(renderer, 100, 100, 100, 255);
|
|
SDL_Delay(1000);
|
|
|
|
SDL_RenderClear(renderer);
|
|
SDL_RenderPresent(renderer);
|
|
SDL_Event event;
|
|
|
|
if(loadBank(1) == false) {return -1;}
|
|
loadPattern(1);
|
|
|
|
while (!done) {
|
|
bool gotEvent = SDL_PollEvent(&event);
|
|
|
|
while (!done && gotEvent) {
|
|
switch (event.type) {
|
|
case SDL_KEYDOWN:
|
|
if(event.key.keysym.sym == SDLK_ESCAPE) {
|
|
Mix_CloseAudio();
|
|
SDL_Quit();
|
|
return 0;
|
|
} else {
|
|
inputActions(event);
|
|
}
|
|
break;
|
|
case SDL_QUIT:
|
|
done = true;
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
|
|
if( !done ) { gotEvent = SDL_PollEvent(&event); }
|
|
|
|
}
|
|
|
|
if(play) {
|
|
playPattern(&timer, stepDuration, &step);
|
|
}
|
|
}
|
|
|
|
for( int i = 0; i < NUM_WAVEFORMS; i++ ) {
|
|
Mix_FreeChunk(samples[i]);
|
|
}
|
|
|
|
Mix_CloseAudio();
|
|
SDL_Quit();
|
|
return 0;
|
|
}
|
|
|