dechatter 0.2.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -6,6 +6,89 @@ What changed for people who use the dechatter widget and command line. The forma
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.4.0] - 2026-11-23
10
+
11
+ ### Added
12
+
13
+ - **Lanes**: a long block is split into lanes along X. When a lane's face runs out of
14
+ width, the next round moves on to the next lane, a fresh face at Y0 at the same height
15
+ above the vise jaws, without remounting or re-zeroing. Each pass cuts one lane and stops
16
+ just short of the next; a lane is never cut back further than the one before it. By
17
+ default the number of lanes is worked out from the stock length: as many as leave every
18
+ cut at least 6 s long at the fastest test speed (`min_cut_s` in `[planner]`, the
19
+ wizard's Shortest cut to listen to), and 1 on a short block, as before. The wizard shows
20
+ the number; `lanes` in `[stock]` (Lanes along X, under Advanced) sets it by hand. The
21
+ session's first round settles it. The widget, the program, `dechatter plan` and the
22
+ report say which lane a round cuts.
23
+
24
+ ### Changed
25
+
26
+ - Sessions planned by this version cannot be opened by dechatter 0.3.0, whose plans lack the
27
+ lane. Sessions from 0.2.0 and 0.3.0 load as they are and keep cutting the whole length.
28
+
29
+ ## [0.3.0] - 2026-11-12
30
+
31
+ ### Changed
32
+
33
+ - The widget runs a round itself: press Start in the widget instead of loading the program
34
+ into cncjs and pressing play. It sends one move at a time through cncjs and waits for the
35
+ controller to report Idle at its end, so it knows exactly when each cut starts and ends
36
+ and records those windows with the sound. Hold, Resume and Stop are in the widget; Stop
37
+ always holds first and resets the controller only once it has reported the hold complete
38
+ (or Idle) and nothing has changed for a second; if the connection drops meanwhile, nothing
39
+ is reset, then or on reconnect. An alarm (its state or an `ALARM:` line) ends the round with
40
+ nothing more sent and is left for you to clear (the widget never unlocks). With a
41
+ manual spindle no `M0` is sent: the widget asks for each speed and waits for Continue, so
42
+ the "set the spindle" prompt shows only once the machine has stopped. Start is refused
43
+ while cncjs runs a job of its own, in alarm or hold, or before the machine's units are
44
+ known, and a job cncjs starts during the round stops it. If the machine refuses, or the
45
+ microphone closes, while the round is being prepared, it does not start and no recording
46
+ is kept. While a round runs,
47
+ or starts, its session stays open: the session list, New, Import and Setup wait for it to
48
+ end.
49
+ `program.nc` is still written, unchanged, for the command line.
50
+
51
+ - On a machine in G20 the whole widget shows inches, not only the wizard and the programs:
52
+ the session summary, round headings and pass table, the front face position, the best
53
+ cuts, the chip-load sweep result and the stability map's axes. Inches have 4 decimals
54
+ (chip loads 5), with millimetres alongside where there is room. Files stay in mm.
55
+
56
+ ### Added
57
+
58
+ - **Reset** next to the widget's session list, and `dechatter reset <session>` (with
59
+ `--yes` to skip the question), discard every round of a session and keep its setup. The
60
+ session starts again from round 1 and its setup can be changed freely, for instance after
61
+ a run in the air to check the toolpath, or one with Z zero set wrong. It asks first,
62
+ naming the rounds and recordings lost, offers Export first, and is refused while the
63
+ session records or a cncjs job of its program runs, and for a session whose setup does
64
+ not load (delete that one instead); rounds that do not load are no obstacle. A stale `report.html` in the session goes too.
65
+ - **Delete** next to the widget's session list removes a session from the browser for good,
66
+ after a confirmation that names its rounds and recordings and offers Export first. It
67
+ works for sessions that no longer load, such as ones from dechatter 0.1.x. One whose setup
68
+ does not load cannot be exported, and the confirmation says so instead. It is refused while the session
69
+ records or a cncjs job of its program runs.
70
+
71
+ ### Fixed
72
+
73
+ - Cuts were matched to the wrong passes, seen on a real manual-spindle session: light cuts at
74
+ a low speed fell under one level threshold for the whole recording, and the rest slid onto
75
+ the wrong passes; passes never run had cuts forced onto them. A round the widget runs is
76
+ now analysed from the cut and dwell windows it recorded. A recording without them is
77
+ searched against the spindle's own noise around each cut, keeps the pass order with the
78
+ narrowest cuts taken as the unheard ones, and marks passes after the last cut as "likely
79
+ not run". A widget run that ended before its first cut leaves the round to run again,
80
+ and a cut stopped before the cutter reached the stock counts as not run. A hold before
81
+ the cutter reaches the stock no longer puts air into the cut analysed. Silence in a
82
+ recording, even most of it (a recorder left running after the round), short pauses with
83
+ the spindle off, or silence broken up by knocks, is told from a quiet spindle under loud
84
+ cuts, and no longer hides the spindle's level.
85
+ A pass whose spindle speed was found at the edge of its search is flagged.
86
+ - A recording could get stuck with no way to stop it, and Export was disabled meanwhile. The
87
+ recording now follows the widget's own run, which always ends (Stop, the last pass, an
88
+ error or a lost connection) and keeps the cuts made. A run held for a minute, or a machine
89
+ idle but not where its move ends, points to Stop. Export works during a run, without the
90
+ round in progress, and says so.
91
+
9
92
  ## [0.2.0] - 2026-11-12
10
93
 
11
94
  ### Changed
@@ -97,7 +180,9 @@ What changed for people who use the dechatter widget and command line. The forma
97
180
  Sessions export to a zip the command line reads, and import in another browser.
98
181
  - Published on npm as `dechatter`, with third-party notices for the bundled Pyodide.
99
182
 
100
- [Unreleased]: https://github.com/pedropaulovc/dechatter/compare/v0.2.0...HEAD
183
+ [Unreleased]: https://github.com/pedropaulovc/dechatter/compare/v0.4.0...HEAD
184
+ [0.4.0]: https://github.com/pedropaulovc/dechatter/compare/v0.3.0...v0.4.0
185
+ [0.3.0]: https://github.com/pedropaulovc/dechatter/compare/v0.2.0...v0.3.0
101
186
  [0.2.0]: https://github.com/pedropaulovc/dechatter/compare/v0.1.1...v0.2.0
102
187
  [0.1.1]: https://github.com/pedropaulovc/dechatter/compare/v0.1.0...v0.1.1
103
188
  [0.1.0]: https://github.com/pedropaulovc/dechatter/releases/tag/v0.1.0
package/README.md CHANGED
@@ -59,7 +59,7 @@ a page the microphone on those. Then, in the widget:
59
59
 
60
60
  1. Create a session. A short wizard asks for the machine, the tool, the cut and the stock. It
61
61
  shows lengths in inches when the machine is in G20 and in millimetres when it is in G21,
62
- or with no machine connected. Its last step holds the planner's settings, which rarely
62
+ or with no machine connected; so does the rest of the widget. Its last step holds the planner's settings, which rarely
63
63
  need changing. Settings with a sensible default or a computed value (the machine's name,
64
64
  the holder, the cut's limits and chip load, the program's dwell, clearance, plunge feed,
65
65
  truing width and coolant, and the planner) sit in a collapsed Advanced section of their
@@ -74,7 +74,7 @@ a page the microphone on those. Then, in the widget:
74
74
  setup. Each round keeps a copy of the setup it was planned from. Once a round has been
75
75
  cut, the setup can no longer change in anything that shapes the cut or its sound (the
76
76
  machine's weight and spindle control, the tool, the work material, depth, direction and
77
- chip load, the stock length, the dwell and the coolant), since the stability map belongs
77
+ chip load, the stock length and lanes, the dwell and the coolant), since the stability map belongs
78
78
  to the setup it was measured with: start a new session instead. What only bounds the
79
79
  search may still change (the machine's speed range and power, the cut's speed and width
80
80
  limits and shallower depths), as may the machine's name, the safe height, clearance,
@@ -87,9 +87,22 @@ a page the microphone on those. Then, in the widget:
87
87
  plan uses the new setup. `dechatter plan` refuses the same changes made by hand.
88
88
  2. Plan a round. Round 1 is a coarse grid of speeds and widths.
89
89
  3. Set the work zero at the left end of the stock, on its front face, at the top.
90
- 4. Load the program into cncjs and press play in cncjs. The widget never starts the machine.
91
- 5. Recording starts when the job starts and stops when it ends. The widget then shows each
92
- pass as stable or chatter, the stability map and the best cuts so far.
90
+ 4. Press Start. The widget runs the round itself through cncjs, one move at a time: it
91
+ sends a move, waits until the controller reports Idle at its end, then sends the next.
92
+ So it knows when every cut starts and ends, and records those times with the sound; at
93
+ most one move is ever queued, so if the tab closes or the connection drops the machine
94
+ finishes that move and stands. Hold, Resume and Stop are in the widget (cncjs's own feed
95
+ hold works too). Stop holds, waits until the controller reports the hold complete (or
96
+ Idle) and nothing changes for a second, then resets it; if the hold never completes, or
97
+ the connection drops meanwhile, it does not reset, and says so. An alarm stops the round with nothing more sent and is left for you
98
+ to clear in cncjs (home, or unlock): the widget never unlocks. While a round runs, its
99
+ session stays open: the session list, New, Import and Setup wait for it to end. Start is refused while cncjs runs a job of its own, while the machine is in
100
+ alarm or held, or before its G20/G21 mode is known, and a job cncjs starts during the
101
+ round stops the round. To check the toolpath first, raise Z zero and run the round in the
102
+ air, then Reset the session (next to the session list) and set Z zero back on the top of
103
+ the stock.
104
+ 5. Recording starts with Start and stops when the last pass ends, or on Stop. The widget
105
+ then shows each pass as stable or chatter, the stability map and the best cuts so far.
93
106
  6. If your ears disagree with a verdict, change it in the table. Plan the next round and
94
107
  repeat until the widget reports convergence.
95
108
  7. Optionally, plan the chip-load sweep it then offers: the best cut once more at five
@@ -111,17 +124,26 @@ browser kept any of that processing on.
111
124
 
112
125
  Sessions are stored in that browser (IndexedDB), per cncjs address. Export saves one as a zip
113
126
  holding `setup.toml` and each round's plan, program, `recording.wav`, results and the job
114
- timeline cncjs reported, plus `report.html`. Import loads it in another browser, and unzipped it is a session
127
+ timeline of the run (each pass's cut and dwell windows), plus `report.html`. Import loads it in another browser, and unzipped it is a session
115
128
  folder the command line reads. Keep the tab open while a round runs: the recording lives in
116
- the page until the job ends.
129
+ the page until the round ends. Export works during a run too, without that round. If a run
130
+ seems stuck (held for a minute, or the machine idle but not where its move ends), the widget
131
+ says so and points to Stop, which keeps and analyses the cuts made so far. Reset, next to the session list, discards every round and
132
+ keeps the setup, so the session starts again from round 1 and its setup can be changed
133
+ freely (`dechatter reset <session>` on the command line); it needs a setup that loads,
134
+ though its rounds need not. Delete removes a session for good after asking, and offers
135
+ Export first. It also removes sessions that no longer load, such as ones from dechatter
136
+ 0.1.x; one whose setup does not load cannot be exported.
137
+ Both are refused while that session records or its job runs.
117
138
 
118
139
  ### Manual spindle
119
140
 
120
141
  If the spindle is started and set by hand, choose "me, by hand" on the wizard's first step
121
142
  (`spindle = "manual"` under `[machine]` in a setup file). The program then never commands the
122
- spindle. It stops with `M0` before each speed, with
123
- the cutter clear of the work, and the widget (and cncjs) shows the speed to set. Set it and
124
- press resume in cncjs. Cuts are grouped by speed, lightest first, so a round has one stop per
143
+ spindle. In the widget, the round stops before each speed with the cutter clear of the work
144
+ and shows the speed to set: set it and press Continue. The program file (`program.nc`, for
145
+ the command line) stops with `M0` at the same places instead: set the speed and press resume
146
+ in cncjs. Cuts are grouped by speed, lightest first, so a round has one stop per
125
147
  speed: five in round 1. The first stop is where you start the spindle, and you stop it yourself
126
148
  after the program ends.
127
149
 
@@ -145,6 +167,7 @@ dechatter analyze al-10mm recording.wav # classifies each pass
145
167
  dechatter plan al-10mm # next round, or "converged"
146
168
  dechatter plan al-10mm --sweep # once converged: chip-load sweep of the best cut
147
169
  dechatter report al-10mm # stability map and best cuts so far
170
+ dechatter reset al-10mm # discard every round, keep the setup (asks first)
148
171
  dechatter report al-10mm --html al-10mm.html --units in # printable report
149
172
  ```
150
173
 
@@ -176,9 +199,19 @@ remaining spectrum and at least 10 dB above the same frequency in the dwell just
176
199
  pass, when the spindle was turning in air. The second test rejects tones the machine makes
177
200
  without cutting, such as drive whine.
178
201
 
179
- Passes are found in the recording by level, then matched in order to the planned passes by
180
- how long each cut should last. A quiet pass that goes undetected is reported as missing and
181
- does not shift the others. If matching fails, mark the cuts yourself and pass
202
+ When the widget ran the round, it recorded where every cut and every dwell is, and those
203
+ windows are used as they are: the cut from where the cutter meets the stock to where it
204
+ leaves it, without any time the machine was held, and the dwell before it as the air
205
+ reference. A pass the run never reached is "not run". A run that ended before its first cut
206
+ is not analysed, and the round stays planned to run again.
207
+
208
+ A recording made otherwise (the command line, a phone) is searched for its cuts by their
209
+ level over the spindle's own noise around them, since the spindle gets louder as it speeds
210
+ up and a light cut is only a few dB over it. The cuts found are matched in order to the
211
+ planned passes by how long each should last; at one speed the narrowest cuts are the ones
212
+ that can go unheard, so those are the ones taken as missing. Passes after the last cut heard
213
+ are "likely not run" (a verdict can still be set by hand, should one have run unheard), and a pass whose spindle speed was found at the edge of its ±5% search is
214
+ flagged ("speed?" in the widget). If matching fails, mark the cuts yourself and pass
182
215
  `--segments labels.txt` (start and end seconds per pass; an Audacity label export works).
183
216
 
184
217
  `results.json` in each round holds the verdicts and the numbers behind them. If your ears
@@ -241,7 +274,28 @@ Three things differ from the paper, which tests one cut at a time under closed-l
241
274
  width that was stable where the chatter was heard, so the planner tries them.
242
275
 
243
276
  The stock runs out before the search does on small blocks. `plan` then asks for fresh stock;
244
- mount it, reset the face to `Y0` and run `dechatter plan --new-stock`.
277
+ mount it, reset the face to `Y0` and run `dechatter plan --new-stock` (in the widget: plan on
278
+ the "fresh block, face at Y0").
279
+
280
+ ### Lanes: fresh faces without remounting
281
+
282
+ A long block is split into lanes along X. By default there are as many as leave every cut
283
+ at least 6 s long at the fastest test speed, where cuts are shortest (`min_cut_s` in
284
+ `[planner]`, the wizard's Shortest cut to listen to), so a short block keeps a single lane;
285
+ the wizard shows the number it works out. `lanes` in `[stock]` (Lanes along X, under
286
+ Advanced in the wizard's Stock step) sets it by hand. The session's first round settles it:
287
+ it stays fixed even if a later change to the speed limits would allow more. The lanes are
288
+ used one after another, starting at the end the cutter meets first (the left end in
289
+ conventional milling, the right in climb). When a lane's face
290
+ has room for fewer of a round's cuts than a fresh lane would, the round moves to the next
291
+ lane: a new face at `Y0`, at the same height above the vise jaws as the first, with the same
292
+ work zero. Each pass then cuts one lane: it starts a cutter diameter clear of the lane
293
+ before, which is already cut back, and stops just short of the next lane, still untouched,
294
+ then backs off the face (the last lane runs out past the end of the stock as usual). A
295
+ lane is never cut further back than the one before it, since the cutter crosses that one
296
+ on its way in, and each lane must be at least twice the cutter diameter long. A deeper
297
+ depth still needs fresh stock, since the cutter would cross the earlier lanes below where
298
+ they were cut. The number of lanes cannot change once a round was cut.
245
299
 
246
300
  ## Development
247
301
 
@@ -249,6 +303,7 @@ mount it, reset the face to `Y0` and run `dechatter plan --new-stock`.
249
303
  uv sync
250
304
  uv run pytest
251
305
  uv run ruff check .
306
+ node --test tests/js/stepper.test.mjs # the widget's stepper against a scripted controller
252
307
  uv run validation/purdue.py ~/purdue-cache # downloads about 370 MB once
253
308
  ```
254
309
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dechatter",
3
- "version": "0.2.0",
3
+ "version": "0.4.0",
4
4
  "description": "CNCjs custom widget that finds chatter-free milling speeds, widths and depths from test cuts heard through the microphone.",
5
5
  "keywords": [
6
6
  "cncjs",
@@ -35,6 +35,7 @@
35
35
  },
36
36
  "scripts": {
37
37
  "build": "node .github/build_widget.mjs",
38
+ "test": "node --test tests/js/stepper.test.mjs",
38
39
  "prepack": "npm run build"
39
40
  }
40
41
  }
package/web/dechatter.zip CHANGED
Binary file
package/web/engine.js CHANGED
@@ -5,7 +5,7 @@ import { loadPyodide } from './pyodide/pyodide.js';
5
5
 
6
6
  const ROOT = '/sessions';
7
7
  // Calls that change files; the filesystem is flushed to IndexedDB after each of them.
8
- const WRITES = new Set(['create', 'save_setup', 'plan', 'plan_sweep', 'record_stop', 'analyze', 'set_verdict', 'import_zip']);
8
+ const WRITES = new Set(['create', 'delete', 'reset', 'save_setup', 'plan', 'plan_sweep', 'record_stop', 'analyze', 'set_verdict', 'import_zip']);
9
9
 
10
10
  let pyodide;
11
11
  let call;
@@ -68,7 +68,8 @@ async function handle({ method, args }) {
68
68
  return { ok: bytes };
69
69
  }
70
70
  const reply = JSON.parse(result);
71
- if ('ok' in reply && WRITES.has(method)) {
71
+ // Also after a refused or failed write: memory may have changed before it failed.
72
+ if (WRITES.has(method)) {
72
73
  await sync(false);
73
74
  }
74
75
  return reply;
package/web/index.html CHANGED
@@ -13,6 +13,8 @@
13
13
  <div id="main" hidden>
14
14
  <header>
15
15
  <select id="sessions" aria-label="Session"></select>
16
+ <button id="reset-session" disabled>Reset</button>
17
+ <button id="delete-session" disabled>Delete</button>
16
18
  <button id="new-session">New</button>
17
19
  <button id="edit-setup" disabled>Setup</button>
18
20
  <button id="export" disabled>Export</button>
@@ -46,6 +48,16 @@
46
48
  </p>
47
49
  </section>
48
50
 
51
+ <dialog id="confirm-dialog" aria-labelledby="confirm-question">
52
+ <p id="confirm-question"></p>
53
+ <p id="confirm-note" class="muted"></p>
54
+ <p class="wizard-buttons">
55
+ <button id="confirm-export" type="button">Export first</button>
56
+ <button id="confirm-go" type="button" class="danger">Delete</button>
57
+ <button id="confirm-cancel" type="button">Cancel</button>
58
+ </p>
59
+ </dialog>
60
+
49
61
  <section id="step" hidden></section>
50
62
 
51
63
  <section id="round" hidden>
@@ -69,7 +81,7 @@
69
81
  <section id="best-section" hidden>
70
82
  <h2>Best stable cuts <button id="download-report" type="button">Download report</button></h2>
71
83
  <table>
72
- <thead><tr><th>rpm</th><th>width</th><th>depth</th><th>feed</th><th>cm³/min</th></tr></thead>
84
+ <thead><tr><th>rpm</th><th>width</th><th>depth</th><th>feed</th><th>removal</th></tr></thead>
73
85
  <tbody id="best"></tbody>
74
86
  </table>
75
87
  <p id="sweep-result" class="muted legend" hidden></p>