10 changed files with 131 additions and 54 deletions
Binary file not shown.
@ -1 +1 @@ |
|||||
g++ -o sonquencer -I/usr/include/SDL2 main.cpp -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer |
|
||||
|
g++ -o sonquencer -I/usr/include/SDL2 main.cpp -lSDL2 -lSDL2_image -lSDL2_ttf -lSDL2_mixer |
||||
|
@ -0,0 +1,18 @@ |
|||||
|
void inputActions(SDL_Event e, int step) { |
||||
|
switch (e.key.keysym.sym) { |
||||
|
case SDLK_1: |
||||
|
setSample(1, step); |
||||
|
break; |
||||
|
case SDLK_2: |
||||
|
setSample(2, step); |
||||
|
break; |
||||
|
case SDLK_3: |
||||
|
setSample(3, step); |
||||
|
break; |
||||
|
case SDLK_4: |
||||
|
setSample(4, step); |
||||
|
break; |
||||
|
default: |
||||
|
break; |
||||
|
} |
||||
|
} |
Binary file not shown.
@ -0,0 +1,6 @@ |
|||||
|
bank 1 |
||||
|
rows 4 |
||||
|
00000000 |
||||
|
00000000 |
||||
|
00000000 |
||||
|
00000000 |
@ -0,0 +1,6 @@ |
|||||
|
bank 2 |
||||
|
rows 4 |
||||
|
10000101 |
||||
|
01000011 |
||||
|
00100001 |
||||
|
00010001 |
@ -1,15 +1,24 @@ |
|||||
|
|
||||
void playStep(bool play, int *timer, int *step) { |
|
||||
*timer = *timer >= *step ? 0 : *timer+1; |
|
||||
|
void playPattern(int *timer, int duration, int *step) { |
||||
|
*timer = *timer >= duration ? 0 : *timer+1; |
||||
usleep(1000); |
usleep(1000); |
||||
|
|
||||
if(*timer == 0) { |
if(*timer == 0) { |
||||
printf("%d\n", *timer); |
|
||||
|
|
||||
Mix_PlayChannel(-1, _sample[1], 0); |
|
||||
|
for(int i=0; i<matrix[0]; i++) { |
||||
|
if(pattern[i][*step-1] == 1) { |
||||
|
Mix_PlayChannel(-1, samples[i], 0); |
||||
|
} |
||||
|
} |
||||
|
*step = *step < matrix[1] ? *step+1 : 1; |
||||
} |
} |
||||
} |
} |
||||
|
|
||||
void playSample(int sample) { |
|
||||
Mix_PlayChannel(-1, _sample[sample-1], 0); |
|
||||
|
void setSample(int sample, int step) { |
||||
|
pattern[sample-1][step-1] = 1; |
||||
|
for(int i=0; i<matrix[0]; i++) { |
||||
|
for(int y=0; y<matrix[1]; y++) { |
||||
|
printf("%d ", pattern[i][y]); |
||||
|
} |
||||
|
printf("\n"); |
||||
|
} |
||||
} |
} |
||||
|
Binary file not shown.
Loading…
Reference in new issue