Browse Source

optimize erease

develop^2
Carmine De Rosa 5 years ago
parent
commit
fed671225e
  1. 8
      C/actions.cpp
  2. 8
      C/inputs.cpp
  3. 3
      C/main.cpp
  4. 16
      C/players.cpp
  5. BIN
      C/sonquencer
  6. 10
      README.md

8
C/actions.cpp

@ -1,10 +1,8 @@
void setSample(int sample, int step) {
void setSample(int sample) {
if(setErease) {
for(int i=0; i<matrix[1]; i++) {
pattern[sample-1][i] = 0;
}
setErease = false;
ereaseSample = sample;
} else if(selectPattern) {

8
C/inputs.cpp

@ -1,16 +1,16 @@
void inputActions(SDL_Event e) {
switch (e.key.keysym.sym) {
case SDLK_1:
setSample(1, step);
setSample(1);
break;
case SDLK_2:
setSample(2, step);
setSample(2);
break;
case SDLK_3:
setSample(3, step);
setSample(3);
break;
case SDLK_4:
setSample(4, step);
setSample(4);
break;
case SDLK_p:

3
C/main.cpp

@ -22,6 +22,7 @@ bool play = false;
bool setErease = false;
bool selectPattern = false;
bool selectBank = false;
int ereaseSample = 0;
int step = 0;
#include "draw.cpp"
@ -78,7 +79,7 @@ int main(int argc, char** argv) {
}
if(play) {
playPattern(&timer, stepDuration, &step);
playPattern(&timer, stepDuration);
}
}

16
C/players.cpp

@ -1,15 +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);
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;
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;
}
}
}

BIN
C/sonquencer

Binary file not shown.

10
README.md

@ -2,13 +2,13 @@
#### Keys (C version)
| Key | Key + | Action | Description |
| ------- | ------- | ------------- | ---------------------------------------- |
| 1,2,3,4 | | Play sample n | Set the sample when sequencer is playing |
| 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…
Cancel
Save