<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[Browser Signal Notes]]></title><description><![CDATA[Practical notes on browser audio, timing, and small web tools.]]></description><link>https://browsersignalnotes.hashnode.dev</link><generator>RSS for Node</generator><lastBuildDate>Fri, 04 Dec 2026 22:36:57 GMT</lastBuildDate><atom:link href="https://browsersignalnotes.hashnode.dev/rss.xml" rel="self" type="application/rss+xml"/><language><![CDATA[en]]></language><ttl>60</ttl><item><title><![CDATA[A Puzzle Solver Needs Four Answers, Not Just True or False]]></title><description><![CDATA[A solver returns one valid board. Can a puzzle generator now label the puzzle “unique”? No: it has established existence, not uniqueness. A second…]]></description><link>https://browsersignalnotes.hashnode.dev/a-puzzle-solver-needs-four-answers-not-just-true-or-false</link><guid isPermaLink="true">https://browsersignalnotes.hashnode.dev/a-puzzle-solver-needs-four-answers-not-just-true-or-false</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[algorithms]]></category><category><![CDATA[Software Testing]]></category><dc:creator><![CDATA[Leo Wong]]></dc:creator><pubDate>Thu, 19 Nov 2026 17:04:39 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aff143cd4293966e07b3d6b/a3d02c7c-fc18-4161-a92b-a137a3826a5c.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A solver returns one valid board. Can a puzzle generator now label the puzzle “unique”? No: it has established existence, not uniqueness. A second arrangement might remain in an unexplored branch. Returning <code>true</code> hides that distinction—and returning <code>false</code> after a search limit can be worse.</p>
<p>I maintain <a href="https://meowdokugame.app/">an unofficial fan browser-puzzle site</a>. I am not the original Meow Sudoku developer. The deliberately artificial model below is not a production board, a live-bug demonstration, or an audit of any game's code.</p>
<p><strong>AI disclosure:</strong> All sections, example code, and the explanatory diagram were prepared with AI assistance. Local scripts checked the examples and code; those tool checks are not a claim of human review, gameplay testing, or production validation.</p>
<p><img src="https://cdn.hashnode.com/uploads/covers/6aff143cd4293966e07b3d6b/a3d02c7c-fc18-4161-a92b-a137a3826a5c.png" alt="Four solver outcomes and two distinct valid arrangements on an illustrative 4×4 board." /></p>
<p><em>Original code-drawn illustration, not a game screenshot. Board coordinates are one-based.</em></p>
<h2>Build a counterexample small enough to enumerate</h2>
<p>Take a 4×4 board. Place exactly one token in each row, each column, and each region. Tokens cannot touch, even diagonally. Define the four regions as the four vertical columns: they are connected, but deliberately redundant with the column rule. This is a teaching model, not a realistic puzzle-generation benchmark.</p>
<p>Represent an arrangement by its column in each successive row. <code>[2,4,1,3]</code> means tokens at <strong>(row, column) = (1,2), (2,4), (3,1), (4,3)</strong>. All coordinates here start at one.</p>
<p>Using permutations of columns 1–4 automatically satisfies the row, column, and region rules. Only adjacent rows need a touching check: their column difference must exceed one. Rows farther apart cannot touch.</p>
<p>There are <code>4! = 24</code> permutations. Exhaustively checking them leaves exactly two:</p>
<ul>
<li><code>[2,4,1,3]</code>, with adjacent column differences 2, 3, 2.</li>
<li><code>[3,1,4,2]</code>, at <strong>(1,3), (2,1), (3,4), (4,2)</strong>, also with differences 2, 3, 2.</li>
</ul>
<p>Either arrangement is valid. Together they disprove uniqueness. Finding two distinct witnesses is conclusive even without inspecting the remaining candidates.</p>
<h2>Return evidence, not just a boolean</h2>
<p>Use four outcomes for this classification task:</p>
<ul>
<li><strong>NONE:</strong> a complete search found zero solutions.</li>
<li><strong>UNIQUE:</strong> a complete search found exactly one solution.</li>
<li><strong>MULTIPLE:</strong> at least two distinct solutions were found; completion is unnecessary.</li>
<li><strong>UNKNOWN:</strong> the search stopped early with zero or one solution found so far.</li>
</ul>
<p>UNKNOWN does not erase evidence. One witness still proves the puzzle is solvable; it simply leaves uniqueness unresolved. Zero witnesses before a limit proves neither impossibility nor existence.</p>
<p>This is an application-level contract, not a universal solver API. For comparison, <a href="https://developers.google.com/optimization/cp/cp_solver">Google's CP-SAT documentation</a> distinguishes feasible, infeasible, and unknown outcomes and separately describes enumerating solutions. Its statuses are not this tutorial's four-value uniqueness classification.</p>
<h2>An executable, bounded classifier</h2>
<p>The JavaScript below was checked locally with Node.js. It needs no libraries. <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/function*">MDN’s generator-function reference</a> explains <code>yield</code>, used here to produce each permutation once.</p>
<p><code>row1</code> optionally fixes the first row's column. <code>budget</code> is a nonnegative safe integer counting candidate checks—not milliseconds or recursion nodes. Generating the tiny candidate list is outside that budget; this is not a runtime limiter.</p>
<pre><code class="language-javascript">function* permutations(xs) {
  if (!xs.length) { yield []; return; }
  for (const x of xs)
    for (const rest of permutations(xs.filter(v =&gt; v !== x)))
      yield [x, ...rest];
}

function classify(row1 = null, budget = 24) {
  if (!Number.isSafeInteger(budget) || budget &lt; 0)
    throw new RangeError("Invalid candidate budget");
  if (row1 !== null &amp;&amp; (!Number.isInteger(row1) || row1 &lt; 1 || row1 &gt; 4))
    throw new RangeError("First-row column must be 1..4 or null");
  const candidates = [...permutations([1, 2, 3, 4])];
  const witnesses = [];
  let checked = 0;
  const result = status =&gt; ({ status, checked, witnesses });
  for (const p of candidates) {
    if (checked === budget) return result("UNKNOWN");
    checked++;
    const separated = p.slice(1).every((c, i) =&gt; Math.abs(c - p[i]) &gt; 1);
    if (separated &amp;&amp; (row1 === null || p[0] === row1)) {
      witnesses.push(p);
      if (witnesses.length === 2) return result("MULTIPLE");
    }
  }
  return result(witnesses.length === 1 ? "UNIQUE" : "NONE");
}

console.log(classify(null, 11));
</code></pre>
<p>In this enumeration order, the first witness is candidate 11; the second is candidate 14. The example call returns UNKNOWN, 11 checked, and <code>[2,4,1,3]</code> as its sole witness.</p>
<p>The budget check happens before checking another candidate. Consequently, budget zero inspects nothing; budget 24 permits full enumeration. A second witness on the last permitted check returns MULTIPLE immediately. Reaching a limit is not itself evidence against a solution.</p>
<h2>Tests that expose the dangerous shortcut</h2>
<p>These results were reproduced from the code above:</p>
<table>
<thead>
<tr>
<th>Call</th>
<th align="right">Checked</th>
<th align="right">Witnesses</th>
<th>Outcome</th>
</tr>
</thead>
<tbody><tr>
<td><code>classify(null, 0)</code></td>
<td align="right">0</td>
<td align="right">0</td>
<td>UNKNOWN</td>
</tr>
<tr>
<td><code>classify(null, 11)</code></td>
<td align="right">11</td>
<td align="right">1</td>
<td>UNKNOWN</td>
</tr>
<tr>
<td><code>classify(null, 14)</code></td>
<td align="right">14</td>
<td align="right">2</td>
<td>MULTIPLE</td>
</tr>
<tr>
<td><code>classify(2, 24)</code></td>
<td align="right">24</td>
<td align="right">1</td>
<td>UNIQUE</td>
</tr>
<tr>
<td><code>classify(1, 24)</code></td>
<td align="right">24</td>
<td align="right">0</td>
<td>NONE</td>
</tr>
<tr>
<td><code>classify(2, 23)</code></td>
<td align="right">23</td>
<td align="right">1</td>
<td>UNKNOWN</td>
</tr>
</tbody></table>
<p>Fixing row one's column to two removes the other witness. Fixing it to one removes both. The classifier still must finish its search before reporting UNIQUE or NONE.</p>
<h2>Keep model errors separate from search results</h2>
<p>An invalid budget is not an unsatisfiable puzzle. The example throws for fractional, negative, or unsafe-integer budgets and for out-of-range clues, rather than returning NONE. A contradictory but well-formed clue is different: fixing row one to column one is legal input, yet this model has no satisfying arrangement. That distinction keeps configuration mistakes from masquerading as mathematical conclusions.</p>
<p>Complete search also need not mean blindly visiting every assignment in a larger implementation. Sound pruning can exclude whole branches. What matters is that no possible second logical solution remains unaccounted for. This toy deliberately uses enumeration so that completion is visible and independently checkable.</p>
<p>Keep the validator independent of the generator's stored answer. Comparing a submitted board only against that answer would reject a different valid arrangement without establishing that it violates any rule. Validate constraints first; classify the solution space separately.</p>
<p>For larger models, different internal assignments can encode the same visible board. Count distinct logical arrangements, not auxiliary-variable assignments or repeated visits. Here the permutation representation is one-to-one with token placements, so two different arrays really are different solutions.</p>
<p>Keep that evidence in the UI: “one solution found; uniqueness unverified” is more honest than “unique” after interruption. A stored answer establishes existence only after it passes the actual constraints. When search stops, the interface should report what was proved—not what the generator hoped was true.</p>
]]></content:encoded></item><item><title><![CDATA[Why Browser Morse Audio Clicks—and How to Check Its Timing]]></title><description><![CDATA[A Morse player can spell every character correctly and still sound wrong. A click at a tone boundary, a misplaced pause, and an exported file that slowly…]]></description><link>https://browsersignalnotes.hashnode.dev/why-browser-morse-audio-clicks-and-how-to-check-its-timing</link><guid isPermaLink="true">https://browsersignalnotes.hashnode.dev/why-browser-morse-audio-clicks-and-how-to-check-its-timing</guid><category><![CDATA[JavaScript]]></category><category><![CDATA[Web Development]]></category><category><![CDATA[Web Audio API]]></category><dc:creator><![CDATA[Leo Wong]]></dc:creator><pubDate>Thu, 19 Nov 2026 15:42:04 GMT</pubDate><enclosure url="https://cdn.hashnode.com/uploads/covers/6aff143cd4293966e07b3d6b/f757375a-7484-40cd-9bd0-71c78412c8f6.png" length="0" type="image/jpeg"/><content:encoded><![CDATA[<p>A Morse player can spell every character correctly and still sound wrong. A click at a tone boundary, a misplaced pause, and an exported file that slowly drifts are different defects. Debugging them together makes each harder to isolate.</p>
<p>Work on <a href="https://morse-code-translator.org/">the browser Morse translator I maintain</a> motivates this tutorial; the design below is not a claim about that site’s implementation.</p>
<p><strong>AI disclosure:</strong> AI assisted with drafting all sections and preparing the explanatory diagram. The cited documentation was consulted and timing arithmetic was checked with a local script. These checks are not browser listening tests or an audit of the linked site.</p>
<img src="https://cdn.hashnode.com/uploads/covers/6aff143cd4293966e07b3d6b/9c65c838-8d33-4cef-95d6-5700750bfd5e.png" alt="Illustrative timeline of the letters S O S at 20 WPM, totaling 27 timing units." style="display:block;margin:0 auto" />

<p><em>Original explanatory illustration, prepared with AI assistance—not a captured production waveform. It shows three separate letters, without trailing silence.</em></p>
<h2>Start with a timeline, not a sound</h2>
<p><a href="https://www.itu.int/dms_pubrec/itu-r/rec/m/R-REC-M.1677-1-200910-I!!PDF-E.pdf">ITU-R M.1677-1, Annex 1, section 2</a> specifies the relative durations: a dot is one unit, a dash three, the gap within a letter one, between letters three, and between words seven.</p>
<p>Those gaps replace one another; they do not stack. After the last element of a letter, insert either the letter gap or the word gap—not an element gap followed by both. Decide separately whether the file needs trailing silence.</p>
<p>For ordinary, unstretched spacing, the PARIS convention defines a word as 50 units, including its following word gap. Therefore:</p>
<p><strong>seconds per unit = 60 / (50 × WPM) = 1.2 / WPM</strong></p>
<p><a href="https://morsecode.world/international/timing.html">Morse Code World's timing explanation</a> details that convention. It is a speed calibration, not a promise that every five-letter word has equal duration. Separately stretched training gaps require a different calculation.</p>
<p>At 20 WPM, one unit is 60 milliseconds. For the three letters <code>S O S</code>, with letter gaps but no spaces in the input:</p>
<ul>
<li>First S: three dots plus two internal gaps = 5 units.</li>
<li>O: three dashes plus two internal gaps = 11 units.</li>
<li>Final S: another 5 units.</li>
<li>Two letter gaps: 6 units.</li>
</ul>
<p>Total: <strong>27 units, or 1.62 seconds</strong>, with no trailing gap. This example treats SOS as three letters, not a continuous distress prosign; that distinction changes the gaps.</p>
<p>Represent this first as tone and silence intervals in integer units. Both playback and export should consume that same timeline. A wrong interval is easier to diagnose than a vaguely wrong sound.</p>
<h2>Smooth the edge without moving the beat</h2>
<p>A sine wave is smooth while it runs. Abruptly switching it to silence at a nonzero amplitude introduces a discontinuity, which can sound like a click. Choosing a sine oscillator alone does not solve keying edges.</p>
<p>For an introduction to waveform generation, HackerNoon's <a href="https://hackernoon.com/web-audio-api-series-2-oscillator-d0fb38d0ca7c">Web Audio API Series 2—Oscillator</a> explains the building block. It is a 2016 tutorial, not a current compatibility guarantee.</p>
<p>Put a gain stage between oscillator and output. Start each mark at zero gain, ramp up, hold, then ramp back to zero before its scheduled end. Keep attack and release inside the allocated mark: appending release afterward steals time from the gap. Ensure the two ramps fit even the shortest dot. Envelope length is a design choice, not an ITU timing constant.</p>
<p><a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioParam">MDN's AudioParam reference</a> documents timed value changes and linear ramps. Its <a href="https://developer.mozilla.org/en-US/docs/Web/API/Web_Audio_API/Advanced_techniques">sequencing tutorial</a> demonstrates gain envelopes. Smoothing reduces abrupt transitions; it does not guarantee inaudibility on every device.</p>
<p>Use one <a href="https://developer.mozilla.org/en-US/docs/Web/API/AudioContext">AudioContext</a> and one scheduling origin on its audio timeline. Derive every boundary from that origin plus elapsed units, rather than using successive JavaScript timeouts as the tone clock. For longer input, a timer can refill a look-ahead schedule; it should not directly determine audible edges.</p>
<p>Create or resume audio in response to user interaction, and handle suspension rather than assuming playback started. Stop deserves its own check: cancel future marks and bring active gain down smoothly before disconnecting. Otherwise, a polished start can still end with a click.</p>
<h2>Export boundaries, not rounded fragments</h2>
<p>Live scheduling uses seconds; a PCM export uses discrete sample frames. A frame contains one sample per channel. Specify the sample rate, channel count, and encoding before calculating storage.</p>
<p>At 48,000 frames per second, the example's 1.62 seconds contains <strong>77,760 frames</strong>. Mono 16-bit PCM needs <strong>155,520 data bytes</strong>. That is the audio payload, not the entire WAV file.</p>
<p>For arbitrary speeds, one timing unit need not contain an integer number of frames. Round each cumulative boundary instead of rounding each interval independently:</p>
<pre><code class="language-javascript">const unitSeconds = 1.2 / wpm;
const frameAt = units =&gt; Math.round(units * unitSeconds * sampleRate);
const startFrame = frameAt(startUnits);
const endFrame = frameAt(endUnits);
</code></pre>
<p>Treat each interval as half-open: include <code>startFrame</code>, exclude <code>endFrame</code>. Adjacent intervals then share a boundary without double-writing a frame. The final length comes from the final cumulative boundary, limiting endpoint rounding error to half a frame; individual interval lengths may differ slightly.</p>
<p>WAV is a container, not a synonym for 16-bit PCM. <a href="https://www.mmsp.ece.mcgill.ca/Documents/AudioFormats/WAVE/WAVE.html">McGill University's WAVE format documentation</a> describes RIFF chunks, encoding variants, and padding. A minimal PCM file can have a 44-byte preamble, but metadata or format extensions change it. Read chunk identifiers and lengths; do not assume audio always begins at byte 44.</p>
<h2>Check contracts before trusting your ears</h2>
<p>Test the interval model separately: empty input, one dot, repeated letters, a word boundary, and unknown characters. Choose an explicit unknown-character policy so silently removed input cannot accidentally join words. Reject invalid speeds before calculating durations.</p>
<p>Then inspect rendered samples around mark boundaries, verify frame counts, and listen at a comfortable volume. Compare playback and export, including stop and restart. Arithmetic assertions can establish timing expectations; they cannot establish perceived sound quality.</p>
<p>The useful debugging order is simple: validate the symbolic timeline, inspect the envelope, then verify sample boundaries. Each layer has a measurable contract—and none requires trusting a product's claims.</p>
]]></content:encoded></item></channel></rss>