linked-rolls 0.19.0 → 0.19.1
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/lib/readers/stanfordAton.js +28 -3
- package/package.json +1 -1
|
@@ -41,6 +41,33 @@ const rewindTrackIn = (holes) => {
|
|
|
41
41
|
const trailing = holes.slice(lastMusical + 1).map(hole => +hole.TRACKER_HOLE);
|
|
42
42
|
return mostFrequent(trailing);
|
|
43
43
|
};
|
|
44
|
+
/**
|
|
45
|
+
* The columns themselves, for a roll that punches its outermost
|
|
46
|
+
* positions. A hole can only sit on a position the bar reads, so
|
|
47
|
+
* columns spanning exactly as many positions as the bar has must run
|
|
48
|
+
* from its first to its last, and the lowest column is position one.
|
|
49
|
+
* Fewer columns leave the phase open and more mean something outside
|
|
50
|
+
* the bar was measured, and neither settles anything.
|
|
51
|
+
*/
|
|
52
|
+
const spannedShiftIn = (holes, bar) => {
|
|
53
|
+
const columns = holes.map(hole => +hole.TRACKER_HOLE).filter(Number.isFinite);
|
|
54
|
+
if (columns.length === 0)
|
|
55
|
+
return undefined;
|
|
56
|
+
const lowest = Math.min(...columns);
|
|
57
|
+
return Math.max(...columns) - lowest + 1 === bar.trackCount ? track(1 - lowest) : undefined;
|
|
58
|
+
};
|
|
59
|
+
/**
|
|
60
|
+
* How far the scanner's own hole numbering has to move to reach the
|
|
61
|
+
* bar. The rewind perforation is the usual landmark; where the roll
|
|
62
|
+
* carries punches past it, as Dyer's T-98 scans do, the span of the
|
|
63
|
+
* columns settles it instead.
|
|
64
|
+
*/
|
|
65
|
+
const calibrationShiftIn = (holes, bar) => {
|
|
66
|
+
const rewind = rewindTrackIn(holes);
|
|
67
|
+
if (rewind !== undefined)
|
|
68
|
+
return track(bar.rewindTrack - rewind);
|
|
69
|
+
return spannedShiftIn(holes, bar) ?? track(0);
|
|
70
|
+
};
|
|
44
71
|
/**
|
|
45
72
|
* The phase of the tracker grid within the image. The analysis file
|
|
46
73
|
* usually states it; where it does not, the holes themselves give it away,
|
|
@@ -92,9 +119,7 @@ export function readFromStanfordAton(atonString, { trackShift, bar = welteT100,
|
|
|
92
119
|
const separation = readPx(json.ROLLINFO.HOLE_SEPARATION);
|
|
93
120
|
const dpi = parseFloat(json.ROLLINFO.LENGTH_DPI);
|
|
94
121
|
const measuredBy = measuredByOf(json.ROLLINFO);
|
|
95
|
-
const
|
|
96
|
-
const shift = trackShift
|
|
97
|
-
?? (rewindTrack === undefined ? track(0) : track(system.rewindTrack - rewindTrack));
|
|
122
|
+
const shift = trackShift ?? calibrationShiftIn(holes, system);
|
|
98
123
|
const calibration = {
|
|
99
124
|
unit: 'px',
|
|
100
125
|
offset: gridOffsetOf(holes, separation, json.ROLLINFO.HOLE_OFFSET),
|
package/package.json
CHANGED