Bill Farmer

Random thoughts on random subjects

Musical Temperaments

by Bill Farmer. Categories: Hacking .

My Tuner app uses equal temperament because that is the current standard and it is relatively easy to calculate using double precision arithmetic and maths library functions. First, declare some constants. private static final int OCTAVE = 12; private static final int EQUAL = 8; private static final int A_OFFSET = 9; private static final int C5_OFFSET = 57; The calculation first produces the cents relative to the reference, usually 440Hz.

Read more →

Draw Musical Staff

by Bill Farmer. Categories: Hacking .

A musical staff is not a trivial thing to draw because of the complex curves needed for the treble and bass clef. What is needed is a source of vector drawing coordinates. The data used was originally intended for use in postscript, so the vertical axis is reversed. // Treble clef private static final float tc[][]= { {-6, 16}, {-8, 13}, {-14, 19}, {-10, 35}, {2, 35}, {8, 37}, {21, 30}, {21, 17}, {21, 5}, {10, -1}, {0, -1}, {-12, -1}, {-23, 5}, {-23, 22}, {-23, 29}, {-22, 37}, {-7, 49}, {10, 61}, {10, 68}, {10, 73}, {10, 78}, {9, 82}, {7, 82}, {2, 78}, {-2, 68}, {-2, 62}, {-2, 25}, {10, 18}, {11, -8}, {11, -18}, {5, -23}, {-4, -23}, {-10, -23}, {-15, -18}, {-15, -13}, {-15, -8}, {-12, -4}, {-7, -4}, {3, -4}, {3, -20}, {-6, -17}, {-5, -23}, {9, -20}, {9, -9}, {7, 24}, {-5, 30}, {-5, 67}, {-5, 78}, {-2, 87}, {7, 91}, {13, 87}, {18, 80}, {17, 73}, {17, 62}, {10, 54}, {1, 45}, {-5, 38}, {-15, 33}, {-15, 19}, {-15, 7}, {-8, 1}, {0, 1}, {8, 1}, {15, 6}, {15, 14}, {15, 23}, {7, 26}, {2, 26}, {-5, 26}, {-9, 21}, {-6, 16} }; // Bass clef private static final float bc[][] = { {-2.

Read more →

Expand Android Selection

by Bill Farmer. Categories: Hacking .

When editing data or source files it would be useful to have selections triggered by a double tap or long press expand to enclosing delimiters or brackets. There is a section in the Android docs which explains how to set up your own context menu or contextual action mode, but not how to change the selection. This method is fine if you have only one text editor view in your app, but would be difficult with more than one as there is no way to identify the originating view.

Read more →

Create PDF Report

by Bill Farmer. Categories: Hacking .

Introduction As part of the Questionnaire Maker plugin it is necessary to create a pdf report. The best tool to do this appears to be TCPDF, which appears to be part of at least some Linux distributions as php-tcpdf. It is not included in WordPress. Implementation As both the plugin and TCPDF are hosted on GitHub, the best way to implement the plugin, and TCPDF if it is not available on the web server, is to clone the repositories and use symbolic links to provide the plugin and the library in the right places.

Read more →

Questionnaire Maker

by Bill Farmer. Categories: Hacking .

Introduction Questionnaire Maker is a WordPress and Hugo plugin that asks a series of questions and produces a PDF report. The project is on Github. Documentation The plugin uses the shortcodes [questionnaire-questions] and [questionnaire-report], or {{< questionnaire-questions >}} and {{< questionnaire-report >}}. The shortcode will be replaced on the page with a series of panels containing the questions and options for the answers, or a panel with a preview of the report.

Read more →
Previous page Next page