9 changed files with 133 additions and 35 deletions
@ -0,0 +1,27 @@ |
|||
|
|||
void setSample(int sample) { |
|||
if(setErease) { |
|||
|
|||
ereaseSample = sample; |
|||
|
|||
} else if(selectPattern) { |
|||
|
|||
loadPattern(sample); |
|||
selectPattern = false; |
|||
|
|||
} else if(selectBank) { |
|||
|
|||
loadBank(sample); |
|||
selectBank = false; |
|||
|
|||
} else { |
|||
|
|||
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"); |
|||
} |
|||
} |
|||
} |
@ -0,0 +1,36 @@ |
|||
void drawRects(int step){ |
|||
|
|||
SDL_RenderClear(renderer); |
|||
|
|||
int cols = matrix[1]; |
|||
int rows = matrix[0]; |
|||
int colWidth = ((600-5)/cols)-5; |
|||
int rowHeight = ((300-5)/rows)-5; |
|||
|
|||
for(int i=0; i<rows; i++) { |
|||
for(int y=0; y<cols; y++) { |
|||
SDL_Rect rect; |
|||
rect.x = (colWidth+5)*y+5; |
|||
rect.y = (rowHeight+5)*i+5; |
|||
rect.w = colWidth; |
|||
rect.h = rowHeight; |
|||
|
|||
if(pattern[i][y] == 1) { |
|||
SDL_SetRenderDrawColor(renderer, 50, 255, 50, 255); |
|||
} else { |
|||
SDL_SetRenderDrawColor(renderer, 50, 50, 50, 255); |
|||
} |
|||
SDL_RenderFillRect(renderer, &rect); |
|||
|
|||
if(step == y) { |
|||
SDL_SetRenderDrawColor(renderer, 200, 200, 200, 255); |
|||
SDL_RenderDrawRect(renderer, &rect); |
|||
} |
|||
|
|||
SDL_SetRenderDrawColor(renderer, 100, 100, 100, 255); |
|||
} |
|||
} |
|||
|
|||
SDL_RenderPresent(renderer); |
|||
} |
|||
|
@ -1,6 +1,6 @@ |
|||
bank 2 |
|||
rows 4 |
|||
10000101 |
|||
01000011 |
|||
00100001 |
|||
00010001 |
|||
1000010010000001 |
|||
0100001101000011 |
|||
0010000100100001 |
|||
0001000100010001 |
|||
|
@ -1,24 +1,23 @@ |
|||
|
|||
void playPattern(int *timer, int duration, int *step) { |
|||
void playPattern(int *timer, int duration) { |
|||
*timer = *timer >= duration ? 0 : *timer+1; |
|||
usleep(1000); |
|||
|
|||
if(*timer == 0) { |
|||
drawRects(step-1); |
|||
for(int i=0; i<matrix[0]; i++) { |
|||
if(pattern[i][*step-1] == 1) { |
|||
if(pattern[i][step-1] == 1) { |
|||
Mix_PlayChannel(-1, samples[i], 0); |
|||
} |
|||
} |
|||
*step = *step < matrix[1] ? *step+1 : 1; |
|||
} |
|||
} |
|||
|
|||
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]); |
|||
step = step < matrix[1] ? step+1 : 1; |
|||
|
|||
if(setErease && step == 1) { |
|||
for(int i=0; i<matrix[1]; i++) { |
|||
pattern[ereaseSample-1][i] = 0; |
|||
} |
|||
setErease = false; |
|||
} |
|||
printf("\n"); |
|||
} |
|||
} |
|||
|
Binary file not shown.
@ -1 +1,16 @@ |
|||
sonquencer |
|||
# Sonquencer |
|||
|
|||
#### Keys (C version) |
|||
|
|||
| Key | Options | Action | Description | |
|||
| ------- | ------- | ------------- | ------------------------------------------------------- | |
|||
| 1,2,3,4 | | Play sample n | Set the sample when sequencer is playing or set options | |
|||
| P | | Play/Stop | Play/Stop Sequencer | |
|||
| E | 1,2,3,4 | Erease | Erease the sample line | |
|||
| O | 1,2,3,4 | Open pattern | Open the pattern by number | |
|||
| B | 1,2,3,4 | Open bank | Open the bank by number | |
|||
| | | | | |
|||
| | | | | |
|||
| | | | | |
|||
| | | | | |
|||
|
|||
|
Loading…
Reference in new issue