~rabbits/noton

cd739ed7be79976d90c836b4c8a8a0c2aaf46ec2 — neauoire 4 years ago 7c3c499
Added speed controls
2 files changed, 19 insertions(+), 11 deletions(-)

M README.md
M noton.c
M README.md => README.md +4 -2
@@ 17,8 17,10 @@ cc noton.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -L/usr/local/lib -lSDL2 -lportmidi
- `BACKSPACE` Erase
- `SPACE` Toggle play
- `1-9` Select channel
- `<` Octave down
- `>` Octave up
- `up` Octave up
- `down` Octave down
- `right` Speed up
- `left` Speed down

### Paint


M noton.c => noton.c +15 -9
@@ 202,6 202,14 @@ modoct(Noton *n, int mod)
}

void
modspeed(Noton *n, int mod)
{
	if((n->speed > 10 && mod < 0) || (n->speed < 100 && mod > 0))
		n->speed += mod;
	printf("Select speed #%d\n", n->speed);
}

void
toggle(Noton *n)
{
	n->alive = !n->alive;


@@ 211,7 219,7 @@ toggle(Noton *n)
void
destroy(Noton *n)
{
	int i, locked;
	int i, locked = 0;
	for(i = 0; i < n->wlen; i++)
		n->wires[i].len = 0;
	for(i = 0; i < n->glen; i++) {


@@ 221,7 229,7 @@ destroy(Noton *n)
			locked++;
	}
	n->wlen = 0;
	n->glen = n->wlen;
	n->glen = locked;
	n->alive = 1;
}



@@ 442,11 450,10 @@ setup(Noton *n)
	Gate *gtrue, *gfalse;
	int sharps[12] = {0, 1, 0, 1, 0, 0, 1, 0, 1, 0, 1, 0};
	for(i = 0; i < INPUTMAX; ++i) {
		int x = i % 2 == 0 ? 27 : 20;
		int x = i % 2 == 0 ? 20 : 27;
		n->inputs[i] = addgate(n, INPUT, 0, Pt2d(x, 30 + i * 6));
		n->inputs[i]->locked = 1;
	}

	for(i = 0; i < CHANNELS; ++i) {
		for(j = 0; j < OUTPUTMAX; ++j) {
			int x = WIDTH - (j % 2 == 0 ? 47 : 40) - (i * 15);


@@ 457,7 464,6 @@ setup(Noton *n)
			n->outputs[j]->shrp = sharps[abs(n->outputs[j]->note) % 12];
		}
	}

	gfalse = addgate(n, INPUT, 0, Pt2d((10 % 2 == 0 ? 26 : 20), 30 + 10 * 6));
	gfalse->locked = 1;
	gtrue = addgate(n, INPUT, 1, Pt2d((11 % 2 == 0 ? 26 : 20), 30 + 11 * 6));


@@ 537,10 543,10 @@ dokey(Noton *n, SDL_Event *event, Brush *b)
	case SDLK_ESCAPE: quit(); break;
	case SDLK_BACKSPACE: destroy(n); break;
	case SDLK_SPACE: toggle(n); break;
	case SDLK_MINUS:
	case SDLK_LESS: modoct(n, -1); break;
	case SDLK_EQUALS:
	case SDLK_GREATER: modoct(n, 1); break;
	case SDLK_UP: modoct(n, 1); break;
	case SDLK_DOWN: modoct(n, -1); break;
	case SDLK_LEFT: modspeed(n, 5); break;
	case SDLK_RIGHT: modspeed(n, -5); break;
	case SDLK_1: modchan(n, 0); break;
	case SDLK_2: modchan(n, 1); break;
	case SDLK_3: modchan(n, 2); break;