Skip to content

Instantly share code, notes, and snippets.

@GRGSIBERIA
Last active September 12, 2021 08:46
Show Gist options
  • Save GRGSIBERIA/dd66862a0fe86a3e9cb6aa34e0f5ca09 to your computer and use it in GitHub Desktop.
Save GRGSIBERIA/dd66862a0fe86a3e9cb6aa34e0f5ca09 to your computer and use it in GitHub Desktop.
trumpet-prolog
note("C", 0).
note("Db", 1).
note("D", 2).
note("Eb", 3).
note("E", 4).
note("F", 5).
note("Gb", 6).
note("G", 7).
note("Ab", 8).
note("A", 9).
note("Bb", 10).
note("B", 11).
next(X, Y) :- note(X, _), note(Y, _).
next(X, NX) :- RES is (NX + 1) mod 12, note(X, RES).
breath(0, "C", 0).
breath(1, "F", 5).
breath(2, "C", 12).
breath(3, "E", 16).
breath(4, "G", 19).
breath(5, "C", 24).
perform(X, N, B) :-
breath(B, X, BN),
BN < N,
NewB is B - 1,
perform(X, N, NewB).
perform(X, N, B) :-
breath(B, X, BN),
BN >= N, !.
% perform(X, N, B).
% X is the Tone Name.
% N is the Pitch Number.
% B is the Breath Number.
% [Example]
% If the pitch number is 14, what would the tone name and the breath number be?
% perform(X, 14, B).
% X = "E", B = 3
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment