Updates to 2012/deckmyn
Format fixes in README.md. It should be noted that in at least deckmyn.md I was unclear about some things. It appeared the author was using regexps but some of it looked off so I might have improperly placed '`'s. I also am not remotely familiar with music theory or even the terms so I could have easily missed something. I'd certainly welcome a musician looking at and if necessary fixing it! Renamed MANUAL to deckmyn.md. Updated .gitignore. Typo fixes.
This commit is contained in:
1 parent
6ab1d60c1f
commit
a65c28df54
5 files changed
+172
-86
No files matched your search
@@ -4,3 +4,4 @@ greensleeves.pbm
|
||||
sheetmusic.pbm
|
||||
sheetmusic.pbm
|
||||
sheetmusic.pbm
|
||||
output.pbm
|
||||
@@ -1,58 +0,0 @@
|
||||
USER MANUAL
|
||||
===========
|
||||
|
||||
Calling the program
|
||||
-------------------
|
||||
|
||||
./prog "`cat prog.c`" "`cat musicfile`" > output.pbm
|
||||
display output.pbm
|
||||
|
||||
This minimalistic music notator expects two command line arguments. The first is the font description embedded in the source code. Notice that you don't pass the file name, but the actual content as one long character string! If you want to define your personal music font, you can of course do so. The file layout must be exactly the same as prog.c though, only the locations of space (" ") may differ.
|
||||
|
||||
The second argument is the actual music. Again it is one long string, not a file name. But it is possible to save your music in a file, of course.
|
||||
|
||||
Output should be redirected to a file. Afterwards, this file can be visualised with various viewers.
|
||||
|
||||
|
||||
Music input
|
||||
-----------
|
||||
|
||||
Every element in the music is given by a string of *exactly* 3 characters. Any violation of this will result in the rest of the music being interpreted in some randomly wrong way. Notice that in a file, the newline is also a character! Therefore, when preparing music in a file, care shold be taken that the last musical element of a line is only 2 characters!
|
||||
|
||||
1. Basic notes:
|
||||
A single note is input by a letter [A-Ga-g] followed by a duration [1,2,4,8] and possibly a dot [.]. The notes cover 2 octaves, from C (lowest) to b (highest). The possible durations are 1 (whole note), 2 (half note), 4 (quaver), 8 (semi-quaver). So a dotted quaver A followed by a semi quaver G is input as "A4.G8 "
|
||||
|
||||
2. Rests:
|
||||
A rest is given by the letter [r] followed by a duration [1,2,4,8].
|
||||
|
||||
3. Bar lines:
|
||||
There are three possible barline types: single (": "), double (":: ") and final (":; ").
|
||||
|
||||
4. Accidentals:
|
||||
Chromatic changes (sharp, flat, natural) are entered separately from the note that folows them! They are a three-character sequence by themselves. The first character is the chromatic change [+-=]. The second is the pitch at which it should be drawn. Thus "+G G4 " will draw a G sharp quaver. Notice that these signs do not necessarily have to be followed by a note. "+f +c +g B2 " is perfectly legal.
|
||||
|
||||
5. Space (formatting):
|
||||
To manually change the spacing of the music, you can add space between different musical elements. This is given by a [s] followed by the amount of space."s3 " is the space taken by one note. This length is given in 1 character. However, to get a value larger than 9, you can just continue along the ASCII table. So "sz " gives you quite a lot of space on a staff. "s0 " is not only meaningless, it can cause nasty results.
|
||||
|
||||
6. New staff:
|
||||
A token "x " signifies to start a new staff of music. A music staff may never be empty! Even if you just put some blank space ("s1 "), you should always have an entry for every staff. "x x " may give nasty results.
|
||||
|
||||
All staves in the output are extended to the length of the longest staff. To have nicely formatted music, though, you will probably have to add spaces manually.
|
||||
|
||||
7. Time signatures:
|
||||
A time signature is given by [m][234][234]. For example, "m24" will give you a two fourth signature. Notice that there are only three available numbers. Especially "6" and "8" are dearly missed.
|
||||
|
||||
8. Clef:
|
||||
The clef (G or F) can only be changed at the beginning of the music input. If the music starts with "KF ", the music will be written in a bass cleff. "K" followed by any other letter will just default to a standard G clef.
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
Blank music paper (with G cleff):
|
||||
./prog "`cat prog.c`" "sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
with an F cleff:
|
||||
./prog "`cat prog.c`" "KF sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
|
||||
Notice how only the first staff (or any staff) needs to have the full length.
|
||||
|
||||
Some files with well-known melodies are included as examples.
|
||||
@@ -110,7 +110,7 @@ ENTRY= deckmyn
|
||||
PROG= ${ENTRY}
|
||||
#
|
||||
OBJ= ${PROG}.o
|
||||
DATA= MANUAL example_beethoven example_greensleeves
|
||||
DATA= deckmyn.md example_beethoven example_greensleeves
|
||||
TARGET= ${PROG}
|
||||
#
|
||||
ALT_OBJ=
|
||||
|
||||
+72
-27
@@ -1,7 +1,7 @@
|
||||
# Most notable and best tool
|
||||
|
||||
Alex Deckmyn
|
||||
<alex.deckmyn@gmail.com>
|
||||
Alex Deckmyn
|
||||
<alex.deckmyn@gmail.com>
|
||||
|
||||
## To build:
|
||||
|
||||
@@ -29,16 +29,21 @@ The C of this entry is definitely sharp. The program cleverly uses its own
|
||||
source at runtime to define the notes, time signature and accidental bitmaps.
|
||||
|
||||
In addition to sheet music, this program is also able, given the right input,
|
||||
to generate an image of a 10-pin DIP chip (a sound processor?).
|
||||
to generate an image of a 10-pin [DIP
|
||||
chip](https://en.wikipedia.org/wiki/Dual_in-line_package) (a sound processor?).
|
||||
|
||||
Ironically, the way this entry is called from the command line is an abuse of C Shell.
|
||||
Please use Bourne-family shells to run this entry.
|
||||
Ironically, the way this entry is called from the command line is an abuse of [C
|
||||
Shell](https://en.wikipedia.org/wiki/C_shell).
|
||||
Please use [Bourne-family shells](https://en.wikipedia.org/wiki/Bourne_shell) to
|
||||
run this entry.
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
### Example use
|
||||
|
||||
You need the source code and example input (either one of the example files, or manual input as below) ready. And a program capable of showing .pbm bitmap format.
|
||||
You need the source code and example input (either one of the example files, or
|
||||
manual input as below) ready and a program capable of showing [.pbm bitmap
|
||||
format](https://en.wikipedia.org/wiki/Netpbm).
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
@@ -50,48 +55,88 @@ open greensleeves.pbm
|
||||
open short_bass.pbm
|
||||
```
|
||||
|
||||
## Judges' remarks:
|
||||
|
||||
### Description
|
||||
|
||||
Every major C competition should have an entry capable of producing C major.
|
||||
This is a music notation program. It produces bitmaps (.pbm) of music based on ASCII input. A full manual is added as a separate file. Some musical examples are also included.
|
||||
This is a music notation program. It produces
|
||||
[bitmaps](https://en.wikipedia.org/wiki/Netpbm) (`.pbm`) of music based on ASCII
|
||||
input. A full manual is added as a [separate file](deckmyn.md). Some musical
|
||||
examples are also included.
|
||||
|
||||
The program is capable of printing notes, rests, (double) bar lines and accidentals on a single melodic line (multiple staves). No chords, polyphony etc.
|
||||
The program is capable of printing notes, rests, (double) bar lines and
|
||||
accidentals on a single melodic line (multiple staves). No chords, polyphony
|
||||
etc.
|
||||
|
||||
The program expects *two command line arguments*. The first is a (very long) string that contains the complete music font. Note that it should *not* be given as a file name! The default music font is encoded in the (whitespace of the) source code deckmyn.c itself. Therefore, the first argument should be "`cat deckmyn.c`".
|
||||
The program expects *two command line arguments*. The first is a (very long)
|
||||
string that contains the complete music font. Note that it should *not* be given
|
||||
as a file name! The default music font is encoded in the (whitespace of the)
|
||||
source code [deckmyn.c](deckmyn.c) itself. Therefore, the first argument should
|
||||
be `"cat deckmyn.c"`.
|
||||
|
||||
The second command line argument is the music itself. This is, again, a string, not a file name. All music signs are entered as tokens of exactly 3 characters. The code is very sensitive to bad spacing! So for instance, if you use a file to write the music (e.g. example\_greensleeves), you should keep in mind that newline is also a character!
|
||||
The second command line argument is the music itself. This is, again, a string,
|
||||
not a file name. All music signs are entered as tokens of exactly 3 characters.
|
||||
The code is very sensitive to bad spacing! So for instance, if you use a file to
|
||||
write the music (e.g. [example\_greensleeves](example_greensleeves)), you should
|
||||
keep in mind that newline is also a character!
|
||||
|
||||
### Internals
|
||||
|
||||
To minimise the memory footprint, this program has *no variable declarations at all*, except for the arguments to main(). The only available memory space is from the command line arguments and count (argv and argc). Parts of argv are cast as integer when values under 0 or beyond 127 are expected.
|
||||
To minimise the memory footprint, this program has *no variable declarations at
|
||||
all*, except for the arguments to `main()`. The only available memory space is
|
||||
from the command line arguments and count (`argv` and `argc`). Parts of `argv`
|
||||
are cast as integer when values under 0 or beyond 127 are expected.
|
||||
|
||||
The "music font" is defined by the source code itself. The first few lines are not part of the font definition, as this memory space will modified by the program. (So as required by the rules, it is only a (memory) copy of the source code that is modified.)
|
||||
The "music font" is defined by the source code itself. The first few lines are
|
||||
not part of the font definition, as this memory space will modified by the
|
||||
program. (So as required by the rules, it is only a (memory) copy of the source
|
||||
code that is modified.)
|
||||
|
||||
As there is no memory available, output is directly to stdout, byte by byte, from the top left to the bottom right pixel.
|
||||
As there is no memory available, output is directly to stdout, byte by byte,
|
||||
from the top left to the bottom right pixel.
|
||||
|
||||
### LIMITATIONS
|
||||
|
||||
The memory locations of argv are used for various purposes. Therefore, the program name (default "deckmyn") must be *at least 4 characters long*, including possibly the path. This, along with the ending '\0', gives minimum 5 bytes of useful memory space. Otherwise, the program may attempt to write outside the string.
|
||||
The memory locations of `argv` are used for various purposes. Therefore, the
|
||||
program name (default `deckmyn`) must be *at least 4 characters long*, including
|
||||
possibly the path. This, along with the ending `'\0'`, gives minimum 5 bytes of
|
||||
useful memory space. Otherwise, the program may attempt to write outside the
|
||||
string.
|
||||
|
||||
The code is quite sensitive. Errors in the input can lead to strange results. The code does not read beyond the end of the music input, but that is about the only error checking available. Any input that is not according to the rules in the MANUAL, may cause errors.
|
||||
The code is quite sensitive. Errors in the input can lead to strange results.
|
||||
The code does not read beyond the end of the music input, but that is about the
|
||||
only error checking available. Any input that is not according to the rules in
|
||||
the [manual](deckmyn.md), may cause errors.
|
||||
|
||||
The program has no special hardware limitations or requirements, other than 8bit char (signed or unsigned) and two's complement negatives.
|
||||
The program has no special hardware limitations or requirements, other than 8bit
|
||||
char (signed or unsigned) and two's complement negatives.
|
||||
|
||||
The limitations of using char as counters for e.g. the number of music staves are minor. 127 staves to a page is rather a lot.
|
||||
The limitations of using char as counters for e.g. the number of music staves
|
||||
are minor. 127 staves to a page is rather a lot.
|
||||
|
||||
### Obfuscations
|
||||
|
||||
The code has no declared variables other than the command line variables. Not even pointers (we all know how messy code can get with too many pointers!). As more than one variable needs values beyond 127, parts of the command line memory are cast as integer using a macro.
|
||||
The code has no declared variables other than the command line variables. Not
|
||||
even pointers (we all know how messy code can get with too many pointers!). As
|
||||
more than one variable needs values beyond 127, parts of the command line memory
|
||||
are cast as integer using a macro.
|
||||
|
||||
- The formatting of the code is in fact necessary, as this is the definition of the music font. It is therefore not an obfuscation.
|
||||
- The use of only argv/argc as memory locations is a matter of reducing the memory footprint. Again, it is not an obfuscation.
|
||||
- Calling the only remaining variables, and the two defined macros, c and C, is merely a matter of conforming to the standard WYSIWYG paradigm common in commercial notation programs (What You C is What You Get). So once again it is not an obfuscation. Anyway, it's a C coding contest, right?
|
||||
- Randomly using the numerical (ASCII) value for characters is compensated for by replacing some numbers by a character representation. On average, therefore, it is not an obfuscation.
|
||||
- Randomly changing the way the elements of argv are addressed is a matter of maintaining a diversified code base. It is therefore not... Oh allright.
|
||||
- The actual output of the music is done by one print command including a 800+ character nested conditional expression.
|
||||
- printf is also used for its return value.
|
||||
- The formatting of the code is in fact necessary, as this is the definition of
|
||||
the music font. It is therefore not an obfuscation.
|
||||
- The use of only `argv`/`argc` as memory locations is a matter of reducing the
|
||||
memory footprint. Again, it is not an obfuscation.
|
||||
- Calling the only remaining variables, and the two defined macros, `c` and `C`,
|
||||
is merely a matter of conforming to the standard
|
||||
[WYSIWYG](https://en.wikipedia.org/wiki/WYSIWYG) paradigm common in commercial
|
||||
notation programs ('What You `C` is What You Get). So once again it is not an
|
||||
obfuscation. Anyway, it's a C coding contest, right?
|
||||
- Randomly using the numerical (ASCII) value for characters is compensated for
|
||||
by replacing some numbers by a character representation. On average, therefore,
|
||||
it is not an obfuscation.
|
||||
- Randomly changing the way the elements of `argv` are addressed is a matter of
|
||||
maintaining a diversified code base. It is therefore not... Oh all right.
|
||||
- The actual output of the music is done by one print command including a 800+
|
||||
character nested conditional expression.
|
||||
- `printf()` is also used for its return value.
|
||||
|
||||
## Copyright and CC BY-SA 4.0 License:
|
||||
|
||||
|
||||
@@ -0,0 +1,98 @@
|
||||
# USER MANUAL
|
||||
|
||||
## Calling the program
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat musicfile`" > output.pbm
|
||||
```
|
||||
|
||||
Then display `output.pbm`.
|
||||
|
||||
This minimalistic music notator expects two command line arguments. The first is
|
||||
the font description embedded in the source code. Notice that you don't pass the
|
||||
file name, but the actual content as one long character string! If you want to
|
||||
define your personal music font, you can of course do so. The file layout must
|
||||
be exactly the same as [deckmyn.c](deckmyn.c) though, only the locations of
|
||||
space (`" "`) may differ.
|
||||
|
||||
The second argument is the actual music. Again it is one long string, not a file
|
||||
name. But it is possible to save your music in a file, of course.
|
||||
|
||||
Output should be redirected to a file. Afterwards, this file can be visualised
|
||||
with various viewers.
|
||||
|
||||
|
||||
## Music input
|
||||
|
||||
Every element in the music is given by a string of *exactly* 3 characters. Any
|
||||
violation of this will result in the rest of the music being interpreted in some
|
||||
randomly wrong way. Notice that in a file, the newline is also a character!
|
||||
Therefore, when preparing music in a file, care should be taken that the last
|
||||
musical element of a line is only 2 characters!
|
||||
|
||||
1. Basic notes:
|
||||
A single note is input by a letter `[A-Ga-g]` followed by a duration
|
||||
[1,2,4,8] and possibly a dot [`.`]. The notes cover 2 octaves, from `C`
|
||||
(lowest) to `b` (highest). The possible durations are 1 (whole note), 2
|
||||
(half note), 4 (quaver), 8 (semi-quaver). So a dotted quaver `A` followed by
|
||||
a semi quaver `G` is input as `"A4.G8 "`.
|
||||
|
||||
2. Rests:
|
||||
A rest is given by the letter [`r`] followed by a duration [1,2,4,8].
|
||||
|
||||
3. Bar lines:
|
||||
There are three possible bar line types: single (`": "`), double (`":: "`)
|
||||
and final (`":; "`).
|
||||
|
||||
4. Accidentals:
|
||||
Chromatic changes (sharp, flat, natural) are entered separately from the
|
||||
note that follows them! They are a three-character sequence by themselves.
|
||||
The first character is the chromatic change [`+-=`]. The second is the pitch
|
||||
at which it should be drawn. Thus `"+G G4 "` will draw a G sharp quaver.
|
||||
Notice that these signs do not necessarily have to be followed by a note.
|
||||
`"+f +c +g B2 "` is perfectly legal.
|
||||
|
||||
5. Space (formatting):
|
||||
To manually change the spacing of the music, you can add space between
|
||||
different musical elements. This is given by a `[s]` followed by the amount
|
||||
of space. `"s3 "` is the space taken by one note. This length is given in 1
|
||||
character. However, to get a value larger than 9, you can just continue
|
||||
along the ASCII table. So `"sz "` gives you quite a lot of space on a staff.
|
||||
`"s0 "` is not only meaningless, it can cause nasty results.
|
||||
|
||||
6. New staff:
|
||||
A token `"x "` signifies to start a new staff of music. A music staff may
|
||||
never be empty! Even if you just put some blank space (`"s1 "`), you should
|
||||
always have an entry for every staff. `"x x "` may give nasty results.
|
||||
|
||||
All staves in the output are extended to the length of the longest staff. To
|
||||
have nicely formatted music, though, you will probably have to add spaces
|
||||
manually.
|
||||
|
||||
7. Time signatures:
|
||||
A time signature is given by `[m][234][234]`. For example, `"m24"` will give
|
||||
you a two fourth signature. Notice that there are only three available
|
||||
numbers. Especially "6" and "8" are dearly missed.
|
||||
|
||||
8. Clef:
|
||||
The clef (`G` or `F`) can only be changed at the beginning of the music
|
||||
input. If the music starts with `"KF "`, the music will be written in a bass
|
||||
clef. `"K"` followed by any other letter will just default to a standard G clef.
|
||||
|
||||
## Examples
|
||||
|
||||
Blank music paper (with G clef):
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
```
|
||||
|
||||
With an F clef:
|
||||
|
||||
```
|
||||
./deckmyn "`cat deckmyn.c`" "KF sz sa x s1 x s1 x s1 x s1 x s1 "> blank.pbm
|
||||
```
|
||||
|
||||
Notice how only the first staff (or any staff) needs to have the full length.
|
||||
|
||||
Some files with well-known melodies are included as examples.
|
||||
Reference in new issue
Block a user