The sections have been modified a fair amount. The Entries menu has been extended to have: Fixing entries, Updating author info, Thanks for the help. The first two were moved from FAQ and the last one from About. The rationale for these, in order: entries and authors have to do with entries and most of the help involves entries. It also has to do with website but in 'about' it does not seem the right place, unless maybe it is renamed to 'Credits' or something (I am not suggesting this one way or the other). This one is debatable but that was the rationale. The Status menu has been extended to have: Markdown guidelines and Security policy. The rationale is that the markdown guidelines are part of contest guidelines and the security policy is about the status of the entries and how if there are any security problems they will not be addressed (instead of about the IOCCC). The FAQ was extended to have: Compiling entries, Running entries, How to help. The reason to not have compiling and running entries under Entries is because this is 'how to' and also the menu was too long. How to help seems like a good idea under FAQ too (was in About). About was extended to have the new 'about.html' page (from about.md). This is a rare case where a new file is useful as it fits under 'About'. The menu now is: Home page, About the IOCCC, The Judges, Contact us. I was pondering the 'About [the IOCCC]' at the top and also naming it 'About us' but it seemed like a link to index.html was necessary and as for 'about us' it seemed less clear as to whether it was about the judges or the contest itself. The FAQ has been updated slightly for this. After further inspection the bin/index.html and the inc/index.html links were removed from the about section. With these changes, renaming an item or slight reordering notwithstanding, I believe that #2006 is probably in good shape.
733 lines
28 KiB
HTML
733 lines
28 KiB
HTML
<!DOCTYPE html>
|
||
<html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
|
||
<!-- START: two lines up starts content from: inc/top.default.html -->
|
||
|
||
<!-- END: this line ends content from: inc/top.default.html -->
|
||
<!-- START: this line starts content from: inc/head.default.html -->
|
||
|
||
<head>
|
||
<link rel="stylesheet" href="../../ioccc.css">
|
||
<link href="https://fonts.googleapis.com/css2?family=Outfit:wght@100..900&display=swap" rel="stylesheet">
|
||
<meta charset="utf-8">
|
||
<meta name="viewport" content="width=device-width, initial-scale=1.0, user-scalable=yes">
|
||
<title>2013/endoh3 - Most tweetable one liner</title>
|
||
<link rel="icon" type="image/x-icon" href="../../favicon.ico">
|
||
<meta name="description" content="2013 IOCCC entry endoh3 - Most tweetable one liner">
|
||
<meta name="keywords" content="IOCCC, 2013, IOCCC 2013, IOCCC entry, endoh3, Most tweetable one liner">
|
||
</head>
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!! DO NOT MODIFY THIS FILE - This file is generated by a tool !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- END: this line ends content from: inc/head.default.html -->
|
||
|
||
<!-- -->
|
||
<!-- This web page was formed via the tool: bin/readme2index.sh -->
|
||
<!-- The content of main section of this web page came from: 2013/endoh3/README.md -->
|
||
<!-- -->
|
||
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2013/endoh3/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2013/endoh3/README.md !!! -->
|
||
<!-- !!! Do not modify this web page, instead modify the file: 2013/endoh3/README.md !!! -->
|
||
<!-- !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! -->
|
||
|
||
<!-- Markdown content was converted into HTML via the tool: bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content from: inc/body.default.html -->
|
||
|
||
<body>
|
||
|
||
<!-- END: this line ends content from: inc/body.default.html -->
|
||
<!-- START: this line starts content from: inc/topbar.default.html -->
|
||
|
||
<div class="theader">
|
||
<nav class="topbar">
|
||
<div class="container">
|
||
<div class="logo">
|
||
<a href="../../index.html" class="logo-link">
|
||
IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="topbar-items">
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Entries
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../years.html" class="sub-item-link">
|
||
Winning entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../authors.html" class="sub-item-link">
|
||
Winning authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../location.html" class="sub-item-link">
|
||
Location of authors
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../bugs.html" class="sub-item-link">
|
||
Bugs and (mis)features
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_an_entry" class="sub-item-link">
|
||
Fixing entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#fix_author" class="sub-item-link">
|
||
Updating author info
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../thanks-for-help.html" class="sub-item-link">
|
||
Thanks for the help
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
Status
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../news.html" class="sub-item-link">
|
||
News
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../status.html" class="sub-item-link">
|
||
Contest status
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../next/index.html" class="sub-item-link">
|
||
Rules and guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../markdown.html" class="sub-item-link">
|
||
Markdown guidelines
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../SECURITY.html" class="sub-item-link">
|
||
Security policy
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
FAQ
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html" class="sub-item-link">
|
||
Frequently Asked Questions
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#submit" class="sub-item-link">
|
||
How to enter
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#compiling" class="sub-item-link">
|
||
Compiling entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#running_entries" class="sub-item-link">
|
||
Running entries
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../faq.html#help" class="sub-item-link">
|
||
How to help
|
||
</a>
|
||
</div>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="item">
|
||
<span class="item-header">
|
||
About
|
||
</span>
|
||
|
||
<div class="sub-item">
|
||
<div class="outfit-font">
|
||
<a href="../../index.html" class="sub-item-link">
|
||
Home page
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../about.html" class="sub-item-link">
|
||
About the IOCCC
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../judges.html" class="sub-item-link">
|
||
The Judges
|
||
</a>
|
||
</div>
|
||
|
||
<div class="outfit-font">
|
||
<a href="../../contact.html" class="sub-item-link">
|
||
Contact us
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</nav>
|
||
|
||
<div class="header-mobile-menu">
|
||
<noscript>
|
||
<a href="../../nojs-menu.html" class="topbar-js-label">
|
||
Please Enable JavaScript
|
||
</a>
|
||
</noscript>
|
||
|
||
<button id="header-open-menu-button" class="topbar-mobile-menu">
|
||
<img
|
||
src="../../png/hamburger-icon-open.png"
|
||
alt="hamburger style menu icon - open state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<button id="header-close-menu-button" class="hide-content">
|
||
<img
|
||
src="../../png/hamburger-icon-closed.png"
|
||
alt="hamburger style menu icon - closed state"
|
||
width=48
|
||
height=48>
|
||
</button>
|
||
|
||
<div id="mobile-menu-panel" class="hide-content">
|
||
<div class="mobile-menu-container">
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
Entries
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../years.html">
|
||
Winning entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../authors.html">
|
||
Winning authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../location.html">
|
||
Location of authors
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../bugs.html">
|
||
Bugs and (mis)features
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_an_entry">
|
||
Fixing entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#fix_author">
|
||
Updating author info
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../thanks-for-help.html">
|
||
Thanks for the help
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
|
||
<div class="mobile-menu-item">
|
||
Status
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../news.html">
|
||
News
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../status.html">
|
||
Contest status
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../next/index.html">
|
||
Rules and guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../markdown.html">
|
||
Markdown guidelines
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../SECURITY.html">
|
||
Security policy
|
||
</a>
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
FAQ
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html">
|
||
Frequently Asked Questions
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#submit">
|
||
How to enter
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#compiling">
|
||
Compiling entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#running_entries">
|
||
Running entries
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../faq.html#help">
|
||
How to help
|
||
</a>
|
||
|
||
</div>
|
||
</div>
|
||
|
||
<div class="mobile-menu-wrapper">
|
||
<div class="mobile-menu-item">
|
||
About
|
||
</div>
|
||
<div class="mobile-submenu-wrapper">
|
||
|
||
<a class="mobile-submenu-item" href="../../index.html">
|
||
Home page
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../about.html">
|
||
About the IOCCC
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../judges.html">
|
||
The Judges
|
||
</a>
|
||
|
||
<a class="mobile-submenu-item" href="../../contact.html">
|
||
Contact us
|
||
</a>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<script>
|
||
var headerOpenMenuButton = document.getElementById("header-open-menu-button");
|
||
var headerCloseMenuButton = document.getElementById("header-close-menu-button");
|
||
var mobileMenuPanel = document.getElementById("mobile-menu-panel");
|
||
|
||
headerOpenMenuButton.addEventListener("click", () => {
|
||
headerOpenMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.add("hide-content");
|
||
|
||
headerCloseMenuButton.classList.remove("hide-content");
|
||
headerCloseMenuButton.classList.add("topbar-mobile-menu");
|
||
|
||
mobileMenuPanel.classList.remove("hide-content");
|
||
mobileMenuPanel.classList.add("topbar-mobile-panel");
|
||
});
|
||
|
||
headerCloseMenuButton.addEventListener("click", () => {
|
||
headerCloseMenuButton.classList.remove("topbar-mobile-menu");
|
||
headerCloseMenuButton.classList.add("hide-content");
|
||
|
||
mobileMenuPanel.classList.add("hide-content");
|
||
mobileMenuPanel.classList.remove("topbar-mobile-panel");
|
||
|
||
headerOpenMenuButton.classList.add("topbar-mobile-menu");
|
||
headerOpenMenuButton.classList.remove("hide-content");
|
||
});
|
||
</script>
|
||
|
||
<!-- END: this line ends content from: inc/topbar.default.html -->
|
||
<!-- START: this line starts content from: inc/header.default.html -->
|
||
|
||
<div class="header">
|
||
<a href="../../2011/zucker/index.html">
|
||
<img src="../../png/ioccc.png"
|
||
alt="IOCCC image by Matt Zucker"
|
||
width=300
|
||
height=110>
|
||
</a>
|
||
<h1>The International Obfuscated C Code Contest</h1>
|
||
<h2>2013/endoh3 - Most tweetable one liner</h2>
|
||
<h3>play music with ABC notation</h3>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/header.default.html -->
|
||
<!-- START: this line starts content from: inc/navbar.mid.html -->
|
||
|
||
<div class="navbar">
|
||
<a class="Left" href="../endoh2/index.html">← 2013/endoh2</a>
|
||
<a class="Left" href="../index.html">↑ 2013 ↑</a>
|
||
<a class="Left" href="../endoh4/index.html">2013/endoh4 →</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/endoh3.c">C code</a>
|
||
<a class="Right" href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/Makefile">Makefile</a>
|
||
<a class="Right" href="#inventory">Inventory</a>
|
||
<a class="Right" href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2013%2Fendoh3%2Findex.html">✓</a>
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/navbar.mid.html -->
|
||
<!-- START: this line starts content from: inc/before-content.default.html -->
|
||
|
||
<div class="content" id="content">
|
||
|
||
<!-- END: this line ends content from: inc/before-content.default.html -->
|
||
<!-- START: this line starts content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-author.sh -->
|
||
|
||
<h2 id="author">Author:</h2>
|
||
<ul>
|
||
<li>Name: <a href="../../authors.html#Yusuke_Endoh">Yusuke Endoh</a><br>
|
||
Location: <a href="../../location.html#JP">JP</a> - <em>Japan</em></li>
|
||
</ul>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-author.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 20 by: bin/output-index-author.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
|
||
<!-- BEFORE: 1st line of markdown file: 2013/endoh3/README.md -->
|
||
<h2 id="to-build">To build:</h2>
|
||
<pre><code> make</code></pre>
|
||
<h3 id="bugs-and-misfeatures">Bugs and (Mis)features:</h3>
|
||
<p>The current status of this entry is:</p>
|
||
<blockquote>
|
||
<p><strong>STATUS: INABIAF - please DO NOT fix</strong></p>
|
||
</blockquote>
|
||
<p>For more detailed information see <a href="../../bugs.html#2013_endoh3">2013/endoh3 in bugs.html</a>.</p>
|
||
<h2 id="to-use">To use:</h2>
|
||
<pre><code> ./endoh3</code></pre>
|
||
<p>This program plays sound. See the
|
||
FAQ on “<a href="../../faq.html#sox">compile with sound</a>”
|
||
if you do not know how to set your
|
||
system up for this or if you want to verify that everything is oky.</p>
|
||
<h2 id="try">Try:</h2>
|
||
<pre><code> ./try.sh
|
||
|
||
./try.sh ABC
|
||
|
||
./try.sh test.abc yankee.abc
|
||
|
||
./try.sh *.abc</code></pre>
|
||
<p>The script will check for SoX first and next <code>padsp</code> from <code>PulseAudio</code> and
|
||
finally if neither are found if you have <code>ruby(1)</code> installed it’ll use the
|
||
included ruby script to convert it to a WAV file for you to play.</p>
|
||
<p>If no args are passed to the script it will play <a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/twinkle.abc">twinkle.abc</a> and
|
||
the string <code>ABC</code>. Otherwise while there’s a remaining arg if it’s a file it will
|
||
run the program on the file. If it’s not a file it’ll run it as a string.</p>
|
||
<p>The <code>*.abc</code> files are provided as music samples.</p>
|
||
<h2 id="judges-remarks">Judges’ remarks:</h2>
|
||
<p>This program can toot out a tune that is small enough to posted to most social
|
||
media platforms that have small message length limits.</p>
|
||
<p>This endoh3ram can toot out a tune that is small enough.</p>
|
||
<h3 id="a-modern-day-2023-note-about-the-award-most-tweetable-1-liner-and-twitter">A modern day (2023) note about the award ‘Most tweetable 1-liner’ and twitter:</h3>
|
||
<p>The IOCCC no longer endorses the use of what was once twitter, or whatever it
|
||
might be called today. We recommend that you pick a responsible social media
|
||
platform to post the program’s output on. Nevertheless the award of this entry
|
||
will remain the same for historical purposes.</p>
|
||
<h2 id="authors-remarks">Author’s remarks:</h2>
|
||
<h3 id="remarks">Remarks</h3>
|
||
<p>This is a sound synthesizer for a subset of <a href="http://en.wikipedia.org/wiki/ABC_notation">ABC music
|
||
notation</a>.</p>
|
||
<p>Try:</p>
|
||
<pre><code> cc -o endoh3 endoh3.c
|
||
echo "CDEFGABc" | ./endoh3 > /dev/dsp</code></pre>
|
||
<p>If <code>/dev/dsp</code> is not available on your system, use an OSS sound wrapper such
|
||
as <code>padsp</code> or <code>aoss</code>:</p>
|
||
<pre><code> echo "CDEFGABc" | ./endoh3 | padsp tee /dev/dsp > /dev/null</code></pre>
|
||
<p>If you are using Mac OS X, try <a href="http://sox.sourceforge.net/">sox</a> like so:</p>
|
||
<pre><code> echo "CDEFGABc" | ./endoh3 | sox -q -traw -r8000 -b8 -e unsigned-integer - -tcoreaudio</code></pre>
|
||
<p>If that does not work, use the attached script to convert the output into a wave
|
||
file format:</p>
|
||
<pre><code> echo "CDEFGABc" | ./endoh3 | ruby wavify.rb > cde.wav</code></pre>
|
||
<p>and play <code>cde.wav</code>.</p>
|
||
<p>You can also enjoy some music scores that I attached. With <code>/dev/dsp</code> you can
|
||
do so like:</p>
|
||
<pre><code> cat twinkle.abc | ./endoh3 > /dev/dsp
|
||
cat menuet.abc | ./endoh3 > /dev/dsp</code></pre>
|
||
<p>but you should be able to modify it a way to meet your system requirements as
|
||
described above.</p>
|
||
<h3 id="obfuscation">Obfuscation</h3>
|
||
<p>The following sequence of questions may be helpful to understand the <code>endoh3ram</code>
|
||
program:</p>
|
||
<ul>
|
||
<li>How does it convert ABC notes into the frequency?</li>
|
||
<li>What is <code>89/84.</code>? I found it by using the <a href="https://en.wikipedia.org/wiki/Stern-Brocot_tree">Stern-Brocot
|
||
tree</a>.</li>
|
||
<li>How does it generate a wave? Hint: it generates a saw wave.</li>
|
||
</ul>
|
||
<h3 id="limitation">Limitation</h3>
|
||
<p>The following features are supported:</p>
|
||
<ul>
|
||
<li>Notes:
|
||
<ul>
|
||
<li><code>C</code> <code>D</code> <code>E</code> <code>F</code> <code>G</code> <code>A</code> <code>B</code> (in low octave)</li>
|
||
<li><code>c</code> <code>d</code> <code>e</code> <code>f</code> <code>g</code> <code>a</code> <code>b</code> (in high octave)</li>
|
||
</ul></li>
|
||
<li>Rests: <code>z</code></li>
|
||
<li>Note lengths:
|
||
<ul>
|
||
<li><code>A</code> (an eighth note)</li>
|
||
<li><code>A2</code> (a quarter note)</li>
|
||
<li><code>A3</code> (a dotted quarter note)</li>
|
||
<li><code>A4</code> (a half note)</li>
|
||
</ul></li>
|
||
</ul>
|
||
<p>The following features are <em>NOT</em> supported:</p>
|
||
<ul>
|
||
<li>Sharp and flat: <code>^C</code> <code>_C</code>
|
||
<ul>
|
||
<li>But it is possible to emit the half tones. Do you see how?</li>
|
||
</ul></li>
|
||
<li>Shorter note lengths than 1: <code>C1/2</code>
|
||
<ul>
|
||
<li>But you can use <code>C0.5</code> instead.</li>
|
||
</ul></li>
|
||
<li>Higher and lower notes: <code>c'</code> <code>C,</code></li>
|
||
<li>Any meta fields: <code>T:title</code> <code>L:1/4</code></li>
|
||
<li>Bar line, repeat, ties and slurs, and everything else.</li>
|
||
</ul>
|
||
<h3 id="known-bugs">Known Bugs</h3>
|
||
<p>You can <em>NOT</em> write a note length immediately followed by a note <code>E</code>,
|
||
such as <code>C2E2</code>.</p>
|
||
<p>Can you figure out why?</p>
|
||
<p>A workaround is inserting a whitespace: <code>C2 E2</code>.</p>
|
||
<h3 id="portability">Portability</h3>
|
||
<p>I tested it on:</p>
|
||
<ul>
|
||
<li>Ubuntu 13.10 with gcc 4.7.3, clang 3.2, and tcc 0.9.25.</li>
|
||
<li>Mac OS X 10.6 with gcc 4.2.1 and clang 1.7.</li>
|
||
</ul>
|
||
<h3 id="legal">Legal</h3>
|
||
<p>I believe that all the scores that I attached are out-of-copyright.</p>
|
||
<p>I did write a score of the Happy Birthday song too.
|
||
(It does not matter because the song is out-of-copyright in my country.)
|
||
But I do not attach it to protect you from W****r.</p>
|
||
<p>For the same reason, do not post a score that contains only <code>z1092</code>.
|
||
You know, it is <a href="http://en.wikipedia.org/wiki/4%E2%80%B233%E2%80%B3">“the famous song”</a>.</p>
|
||
<h3 id="notice-to-those-who-wish-for-a-greater-challenge">NOTICE to those who wish for a greater challenge:</h3>
|
||
<p><strong>If you want a greater challenge, don’t read any further</strong>:
|
||
just try to understand the program via the source.</p>
|
||
<p>If you get stuck, come back and read below for additional hints and information.</p>
|
||
<h3 id="how-this-entry-works">How this entry works:</h3>
|
||
<p>Here is a magical expression which I found by brute-force:</p>
|
||
<pre><code> (c % 32 + 5) * 9 / 5 % 13 + n / 32 * 12 - 22</code></pre>
|
||
<p>Interestingly, it converts an ASCII number of ABC notes
|
||
to the corresponding tone number.</p>
|
||
<pre><code> 'C' (ASCII 67) => 3
|
||
'D' (ASCII 68) => 5
|
||
'E' (ASCII 69) => 7
|
||
'F' (ASCII 70) => 9
|
||
'G' (ASCII 71) => 10
|
||
'A' (ASCII 65) => 12
|
||
'B' (ASCII 66) => 14
|
||
'c' (ASCII 99) => 15
|
||
'd' (ASCII 100) => 17
|
||
'e' (ASCII 101) => 19
|
||
'f' (ASCII 102) => 20
|
||
'g' (ASCII 103) => 22
|
||
'a' (ASCII 97) => 24
|
||
'b' (ASCII 98) => 26</code></pre>
|
||
<p>By the way, you can write a half-tone by the following characters.</p>
|
||
<pre><code> 'K' => 4 (= C#)
|
||
'L' => 6 (= D#)
|
||
'U' => 8 (= F#)
|
||
'V' => 11 (= G#)
|
||
'P' => 13 (= A#)</code></pre>
|
||
<p>Note that the tone numbers simply enumerate the semi-tone steps. So we can
|
||
calculate the frequency easily: <code>pow(2, n / 12.0)</code>. Then, how can we calculate
|
||
<code>pow</code> without <code>math.h</code>? <code>pow(2, 1.0 / 12.0)</code> is approximated by <code>89/84.</code>. (I
|
||
found this approximation by using the <a href="http://en.wikipedia.org/wiki/Stern%E2%80%93Brocot_tree">Stern-Brocot
|
||
tree</a>.) We can gain the
|
||
frequency by multiplying the value by <code>n</code> times.</p>
|
||
<p>Finally, the following code generates a saw wave:</p>
|
||
<pre><code> for(c = 0; c < len; c++) putchar(a = n * D);</code></pre>
|
||
<p>where <code>D</code> is a frequency and <code>a</code> is a variable whose type is <code>char</code>. By
|
||
assigning <code>float</code> to <code>char</code> variable, the implicit type conversion is performed
|
||
from <code>float</code> to <code>char</code> (modulo 256).</p>
|
||
<p>(Strictly speaking, this behavior is undefined according to 6.3.1.4 in C99; you
|
||
can replace it with <code>(long)(n*D)</code> if you are pedantic.)</p>
|
||
<p>All that was left was to combine and condense the components. The key is
|
||
squashing them into just one <code>for</code>-loop.</p>
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
<!-- AFTER: last line of markdown file: 2013/endoh3/README.md -->
|
||
|
||
<!-- END: this line ends content for HTML phase 21 by: bin/pandoc-wrapper.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
|
||
<!-- START: this line starts content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<div id="inventory">
|
||
<h1 id="inventory-for-2013endoh3">Inventory for 2013/endoh3</h1>
|
||
</div>
|
||
<h2 id="primary-files">Primary files</h2>
|
||
<ul>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/endoh3.c">endoh3.c</a> - entry source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/Makefile">Makefile</a> - entry Makefile</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/endoh3.orig.c">endoh3.orig.c</a> - original source code</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/flea-waltz.abc">flea-waltz.abc</a> - sample input</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/menuet.abc">menuet.abc</a> - sample input</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/test.abc">test.abc</a> - sample input</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/try.sh">try.sh</a> - script to try entry</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/twinkle.abc">twinkle.abc</a> - sample input</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/wavify.rb">wavify.rb</a> - post process output to form a WAV sound file</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/yankee.abc">yankee.abc</a> - sample input</li>
|
||
</ul>
|
||
<h2 id="secondary-files">Secondary files</h2>
|
||
<ul>
|
||
<li><a href="2013_endoh3.tar.bz2">2013_endoh3.tar.bz2</a> - download entry tarball</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/README.md">README.md</a> - markdown source for this web page</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/.entry.json">.entry.json</a> - entry summary and manifest in JSON</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/.gitignore">.gitignore</a> - list of files that should not be committed under git</li>
|
||
<li><a href="https://github.com/ioccc-src/temp-test-ioccc/blob/master/2013/endoh3/.path">.path</a> - directory path from top level directory</li>
|
||
<li><a href="index.html">index.html</a> - this web page</li>
|
||
</ul>
|
||
<hr style="width:10%;text-align:left;margin-left:0">
|
||
<h4>
|
||
Jump to: <a href="#">top</a>
|
||
</h4>
|
||
|
||
<!-- END: next line ends content generated by: bin/output-index-inventory.sh -->
|
||
|
||
<!-- END: this line ends content for HTML phase 22 by: bin/output-index-inventory.sh via bin/md2html.sh -->
|
||
<!-- START: this line starts content from: inc/after-content.default.html -->
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/after-content.default.html -->
|
||
<!-- START: this line starts content from: inc/footer.inventory.html -->
|
||
|
||
<!--
|
||
|
||
Copyright © 1984-2024 by Landon Curt Noll. All Rights Reserved.
|
||
|
||
You are free to share and adapt this file under the terms of this license:
|
||
|
||
Creative Commons Attribution-ShareAlike 4.0 International (CC BY-SA 4.0)
|
||
|
||
For more information, see:
|
||
|
||
https://creativecommons.org/licenses/by-sa/4.0/
|
||
|
||
-->
|
||
|
||
<div class="footer">
|
||
|
||
<div id="copyright"><h3>Copyright © 1984-2024 by Landon Curt Noll:
|
||
<a href="https://creativecommons.org/faq/#what-does-some-rights-reserved-mean"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">Some Rights Reserved</a></h3>
|
||
<p>
|
||
This work is <b>licensed by Landon Curt Noll</b> under
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/?ref=chooser-v1"
|
||
target="_blank"
|
||
rel="license noopener noreferrer"
|
||
style="display:inline-block;">CC BY-SA 4.0</a></b>.
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/cc.png"
|
||
alt="cc inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/by.png"
|
||
alt="person inside circle symbol">
|
||
<img style="height:22px!important;margin-left:3px;vertical-align:text-bottom;"
|
||
src="../../png/sa.png"
|
||
alt="arrow looping back on itself inside circle symbol"><br>
|
||
You should <b>carefully review</b> the
|
||
<b><a href="https://creativecommons.org/licenses/by-sa/4.0/legalcode.en"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">CC BY-SA 4.0 LEGAL CODE</a></b>
|
||
before using the licensed material.<br>
|
||
You may wish to review the
|
||
<b><a href="../../license.html"
|
||
target="_blank"
|
||
rel="license noopener noreferrer">highlights of some of the key features and terms</a></b>
|
||
of <b>CC BY-SA 4.0</b>.<br>
|
||
</p>
|
||
</div>
|
||
|
||
<div id="coda"><h3>Coda</h3>
|
||
<p>
|
||
<a href="https://validator.w3.org/nu/?doc=https%3A%2F%2Fioccc-src.github.io%2Ftemp-test-ioccc%2F2013%2Fendoh3%2Findex.html" rel="nofollow">Nu HTML check this web page</a><br>
|
||
<a href="#top">Jump to top</a> <a href="#content">Jump to Content</a> <a href="#inventory">Jump to Inventory</a><br>
|
||
</p>
|
||
</div>
|
||
|
||
</div>
|
||
|
||
<!-- END: this line ends content from: inc/footer.inventory.html -->
|
||
<!-- START: this line starts content from: inc/bottom.default.html -->
|
||
|
||
</body>
|
||
</html>
|
||
|
||
<!-- END: this line ends content from: inc/bottom.default.html -->
|