Update 2012/deckmyn - try.sh, bugs.md, formatting
The try.sh script is as usual. The bugs.md has some features, not bugs. The README.md file has been format/typo checked. The deckmyn.md file has been format/typo checked. A caveat with this entry is I was not able to verify as much when it comes to checking things as I do not have a musical background (despite the fact my family is full of musicians).
This commit is contained in:
1 parent
c626cd7321
commit
54cfecae4f
6 files changed
+150
-24
No files matched your search
+53
-17
@@ -5,19 +5,28 @@ make
|
||||
```
|
||||
|
||||
|
||||
### Bugs and (Mis)features:
|
||||
|
||||
The current status of this entry is:
|
||||
|
||||
```
|
||||
STATUS: INABIAF - please **DO NOT** fix
|
||||
```
|
||||
|
||||
For more detailed information see [2012 deckmyn in bugs.md](/bugs.md#2012-deckmyn).
|
||||
|
||||
|
||||
## To use:
|
||||
|
||||
A shell interpreter with proper backtick interpolation is required.
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat musicfile.txt`" > sheetmusic.pbm
|
||||
./deckmyn "$(cat deckmyn.c)" "$(cat musicfile.txt)" > sheetmusic.pbm
|
||||
```
|
||||
|
||||
|
||||
### Try:
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
./try.sh
|
||||
```
|
||||
|
||||
|
||||
@@ -26,15 +35,21 @@ A shell interpreter with proper backtick interpolation is required.
|
||||
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
|
||||
In addition to sheet music, this program is also able to, given the right input,
|
||||
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](https://en.wikipedia.org/wiki/C_shell).
|
||||
|
||||
### Historical remarks:
|
||||
|
||||
We previously wrote that 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.
|
||||
|
||||
... but in 2023 we changed the backticks to be the bash `$(..)` construct. This
|
||||
is not done in the author's remarks, however.
|
||||
|
||||
|
||||
## Author's remarks:
|
||||
|
||||
@@ -42,18 +57,36 @@ run this entry.
|
||||
|
||||
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).
|
||||
format](https://en.wikipedia.org/wiki/Netpbm) images.
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "`cat example_greensleeves`" > greensleeves.pbm
|
||||
```
|
||||
|
||||
If you have macOS you can open the image like:
|
||||
|
||||
```sh
|
||||
open greensleeves.pbm
|
||||
```
|
||||
|
||||
... otherwise, you'll have to open it in your viewer of choice how you would
|
||||
normally open an image.
|
||||
|
||||
|
||||
```sh
|
||||
./deckmyn "`cat deckmyn.c`" "KF m44c4 c4 g4 g4 : a4 a4 g2 :; " > short_bass.pbm
|
||||
```
|
||||
|
||||
If you have macOS you can open the image like:
|
||||
|
||||
```sh
|
||||
open short_bass.pbm
|
||||
```
|
||||
|
||||
... otherwise, you'll have to open it in your viewer of choice how you would
|
||||
normally open an image.
|
||||
|
||||
|
||||
### Description
|
||||
|
||||
Every major C competition should have an entry capable of producing C major.
|
||||
@@ -70,7 +103,7 @@ 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"`.
|
||||
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.
|
||||
@@ -78,21 +111,23 @@ 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.
|
||||
are cast as `int` 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
|
||||
not part of the font definition, as this memory space will be 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,
|
||||
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
|
||||
@@ -107,17 +142,18 @@ 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.
|
||||
`char` (`signed` or `unsigned`) and two's complement negatives.
|
||||
|
||||
The limitations of using char as counters for e.g. the number of music staves
|
||||
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.
|
||||
are cast to `int` 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.
|
||||
@@ -133,7 +169,7 @@ 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+
|
||||
- The actual output of the music is done by one `printf(3)` call including a 800+
|
||||
character nested conditional expression.
|
||||
- `printf()` is also used for its return value.
|
||||
|
||||
|
||||
Reference in new issue
Block a user