~rabbits/noton

0eef1642bde0d29ae03c57317ba75a0823e0b601 — neauoire 3 years ago a066911
Added octave mod
3 files changed, 37 insertions(+), 75 deletions(-)

M .clang-format
M README.md
M noton.c
M .clang-format => .clang-format +15 -61
@@ 1,65 1,19 @@
---
Language:        Cpp
# BasedOnStyle:  LLVM
AccessModifierOffset: -2
AlignAfterOpenBracket: true
AlignEscapedNewlinesLeft: false
AlignOperands:   true
AlignTrailingComments: false
AllowAllParametersOfDeclarationOnNextLine: true
AllowShortBlocksOnASingleLine: false
AllowShortCaseLabelsOnASingleLine: false
AlignAfterOpenBracket: DontAlign
AlignEscapedNewlines: DontAlign
AllowShortBlocksOnASingleLine: Empty
AllowShortCaseLabelsOnASingleLine: true
AllowShortIfStatementsOnASingleLine: false
AllowShortLoopsOnASingleLine: false
AllowShortFunctionsOnASingleLine: None
AlwaysBreakAfterDefinitionReturnType: true
AlwaysBreakTemplateDeclarations: false
AlwaysBreakBeforeMultilineStrings: false
BreakBeforeBinaryOperators: None
BreakBeforeTernaryOperators: true
BreakConstructorInitializersBeforeComma: false
BinPackParameters: true
BinPackArguments: true
ColumnLimit:     0
ConstructorInitializerAllOnOneLineOrOnePerLine: false
ConstructorInitializerIndentWidth: 4
DerivePointerAlignment: false
ExperimentalAutoDetectBinPacking: false
AlwaysBreakAfterDefinitionReturnType: TopLevel
BinPackArguments: false
BinPackParameters: false
BreakBeforeBraces: WebKit
IndentCaseLabels: false
IndentWrappedFunctionNames: false
IndentFunctionDeclarationAfterType: false
MaxEmptyLinesToKeep: 1
KeepEmptyLinesAtTheStartOfBlocks: true
NamespaceIndentation: None
ObjCBlockIndentWidth: 2
ObjCSpaceAfterProperty: false
ObjCSpaceBeforeProtocolList: true
PenaltyBreakBeforeFirstCallParameter: 19
PenaltyBreakComment: 300
PenaltyBreakString: 1000
PenaltyBreakFirstLessLess: 120
PenaltyExcessCharacter: 1000000
PenaltyReturnTypeOnItsOwnLine: 60
PointerAlignment: Left
SpacesBeforeTrailingComments: 1
Cpp11BracedListStyle: true
Standard:        Cpp11
IndentWidth:     8
TabWidth:        8
UseTab: ForIndentation
BreakBeforeBraces: Linux
SortIncludes: false
SpacesInParentheses: false
SpacesInSquareBrackets: false
SpacesInAngles:  false
SpaceInEmptyParentheses: false
SpacesInCStyleCastParentheses: false
SpaceAfterCStyleCast: false
SpacesInContainerLiterals: true
SpaceBeforeAssignmentOperators: true
TabWidth: 4
IndentWidth: 4
ContinuationIndentWidth: 4
CommentPragmas:  '^ IWYU pragma:'
ForEachMacros:   [ foreach, Q_FOREACH, BOOST_FOREACH ]
SpaceBeforeParens: Never
DisableFormat:   false
...
UseTab: ForContinuationAndIndentation
ColumnLimit: 0
ReflowComments: false
SortIncludes: false
SpaceBeforeParens: false
\ No newline at end of file

M README.md => README.md +2 -3
@@ 17,8 17,8 @@ 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(TODO)
- `>` Octave up(TODO)
- `<` Octave down
- `>` Octave up

### Paint



@@ 29,4 29,3 @@ cc noton.c -std=c89 -Os -DNDEBUG -g0 -s -Wall -L/usr/local/lib -lSDL2 -lportmidi

- Don't change polarity twice per frame.
- export image
- add change octave shortcut

M noton.c => noton.c +20 -11
@@ 187,13 187,20 @@ bang(Gate *g, int depth)
/* Options */

void
select(Noton *n, int channel)
modchan(Noton *n, int channel)
{
	n->channel = channel;
	printf("Select channel #%d\n", channel);
}

void
modoct(Noton *n, int mod)
{
	n->octave += mod;
	printf("Select octave #%d\n", mod);
}

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


@@ 448,7 455,7 @@ setup(Noton *n)
			n->outputs[j] = addgate(n, OUTPUT, 0, Pt2d(x, 30 + j * 6));
			n->outputs[j]->locked = 1;
			n->outputs[j]->note = j + (i % 2 * 24);
			n->outputs[j]->chan = i;
			n->outputs[j]->chan = n->channel + i;
			n->outputs[j]->shrp = sharps[abs(n->outputs[j]->note) % 12];
		}
	}


@@ 533,15 540,17 @@ 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_1: select(n, 0); break;
	case SDLK_2: select(n, 1); break;
	case SDLK_3: select(n, 2); break;
	case SDLK_4: select(n, 3); break;
	case SDLK_5: select(n, 4); break;
	case SDLK_6: select(n, 5); break;
	case SDLK_7: select(n, 6); break;
	case SDLK_8: select(n, 7); break;
	case SDLK_9: select(n, 8); break;
	case SDLK_LESS: modoct(n, -1); break;
	case SDLK_GREATER: modoct(n, 1); break;
	case SDLK_1: modchan(n, 0); break;
	case SDLK_2: modchan(n, 1); break;
	case SDLK_3: modchan(n, 2); break;
	case SDLK_4: modchan(n, 3); break;
	case SDLK_5: modchan(n, 4); break;
	case SDLK_6: modchan(n, 5); break;
	case SDLK_7: modchan(n, 6); break;
	case SDLK_8: modchan(n, 7); break;
	case SDLK_9: modchan(n, 8); break;
	}
}