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.

95 lines
2.0 KiB

5 years ago
#include <stdio.h>
#include <unistd.h>
#include <syslog.h>
#include <string.h>
#include <math.h>
5 years ago
#include "SDL.h"
#include "SDL_mixer.h"
#include "SDL_image.h"
#define NUM_WAVEFORMS 4
#define PATTERN_ROWS 10
#define PATTERN_COLS 32
5 years ago
5 years ago
Mix_Chunk* samples[NUM_WAVEFORMS];
5 years ago
SDL_Window* window;
SDL_Renderer* renderer;
int pattern[PATTERN_ROWS][PATTERN_COLS];
int matrix[] = {PATTERN_ROWS, PATTERN_COLS};
5 years ago
bool play = false;
bool setErease = false;
5 years ago
bool selectPattern = false;
5 years ago
bool selectBank = false;
5 years ago
int ereaseSample = 0;
5 years ago
int step = 0;
5 years ago
5 years ago
#include "draw.cpp"
#include "loaders.cpp"
5 years ago
#include "actions.cpp"
5 years ago
#include "players.cpp"
5 years ago
#include "inputs.cpp"
5 years ago
int main(int argc, char** argv) {
bool done = false;
int timer = 0;
5 years ago
int stepDuration = 200;
5 years ago
SDL_Init(SDL_INIT_VIDEO | SDL_INIT_AUDIO );
atexit(SDL_Quit);
5 years ago
window = SDL_CreateWindow("Sonquencer", SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED, 600, 300, 0);
renderer = SDL_CreateRenderer(window, -1, 0);
5 years ago
SDL_SetRenderDrawColor(renderer, 100, 100, 100, 255);
SDL_Delay(1000);
5 years ago
5 years ago
SDL_RenderClear(renderer);
SDL_RenderPresent(renderer);
SDL_Event event;
5 years ago
5 years ago
if(loadBank(1) == false) {return -1;}
5 years ago
loadPattern(1);
5 years ago
5 years ago
while (!done) {
bool gotEvent = SDL_PollEvent(&event);
5 years ago
while (!done && gotEvent) {
switch (event.type) {
5 years ago
case SDL_KEYDOWN:
5 years ago
if(event.key.keysym.sym == SDLK_ESCAPE) {
Mix_CloseAudio();
SDL_Quit();
return 0;
} else {
5 years ago
inputActions(event);
5 years ago
}
break;
case SDL_QUIT:
done = true;
break;
default:
break;
5 years ago
}
if( !done ) { gotEvent = SDL_PollEvent(&event); }
}
5 years ago
if(play) {
5 years ago
playPattern(&timer, stepDuration);
}
5 years ago
}
5 years ago
for( int i = 0; i < NUM_WAVEFORMS; i++ ) {
5 years ago
Mix_FreeChunk(samples[i]);
5 years ago
}
Mix_CloseAudio();
SDL_Quit();
return 0;
}