-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.xml
91 lines (91 loc) · 24.7 KB
/
index.xml
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
<?xml version="1.0" encoding="UTF-8" ?>
<rss version="2.0">
<channel>
<title>it's jessie</title>
<link>https://jessie.grosen.systems</link>
<description>Last 10 notes on it's jessie</description>
<generator>Quartz -- quartz.jzhao.xyz</generator>
<item>
<title>i think i'm beginning to recover</title>
<link>https://jessie.grosen.systems/posts/i-think-i'm-beginning-to-recover</link>
<guid>https://jessie.grosen.systems/posts/i-think-i'm-beginning-to-recover</guid>
<description><p>by the end of the third year of my phd program, i was beginning to show external signs of hitting my stride: nearly finishing my course requirements, having a first-author paper accepted at a major conference, generating my own promising (if meager) research ideas. but internally, i was a trainwreck. i spent most days in the office doing nothing but doomscrolling. the very thought of opening up my in-progress proofs or writing some inference rules on the whiteboard spiked my anxiety to such an extent that the ensuing headache made work all but impossible anyway.</p>
<p>maybe it was my grandiose expectations of myself conflicting with my lack of field-redefining work. maybe it was covid’s isolation that prevented me from picking up good grad student habits by osmosis. maybe it was the weight of my increasing disillusion that tech could ever do any good in the world. maybe it was just burnout.</p>
<p>my varied attempts to fix the situation while continuing to come to school each day had failed, so i knew i needed something else. i took leave.</p>
<hr>
<p>half a year later, i’m don’t think i’ve <em>solved</em> anything. but i have begun clawing something back: joy.</p>
<p>i started my batch at the <a href="https://www.recurse.com" class="external">Recurse Center<svg aria-hidden="true" class="external-icon" viewBox="0 0 512 512"><path d="M320 0H288V64h32 82.7L201.4 265.4 178.7 288 224 333.3l22.6-22.6L448 109.3V192v32h64V192 32 0H480 320zM32 32H0V64 480v32H32 456h32V480 352 320H424v32 96H64V96h96 32V32H160 32z"></path></svg></a> this week. <em>everyone</em> is excited about what they’re building and learning, and <em>everyone</em> is excited by everyone else. no one interrupts a presentation to ask, “didn’t Robin Milner solve this in the 80s?”</p>
<p>i’m building things that have been built before. i’m learning things for my sake. i’m believing that tech can be neat. i’m regaining control over my mind.</p>
<p>i don’t expect RC to be a cure-all. a loving community is a pretty good start, though.</p></description>
<pubDate>Sat, 30 Mar 2024 00:00:00 GMT</pubDate>
</item><item>
<title>distance audio modulator</title>
<link>https://jessie.grosen.systems/posts/distance-audio-modulator</link>
<guid>https://jessie.grosen.systems/posts/distance-audio-modulator</guid>
<description><p>recently, my friend zero told me an idea it had to add some crowd-mediated interactivity to a live show: measure how close together a particular few people are by looking at bluetooth signal strengths, then report that back to the synth to modulate some parameters.</p>
<p>we whittled that down to a simpler starting place: estimate distances to a few devices directly from the central laptop, then emit some midi CC values based on that. with some trial and error, we got that to work! here’s a little demo video:
<video src="../public-media/midi_rssi_example.mov" controls></video>
it’s pretty inconsistent and high latency, as you can tell. i bet if we wrote a little app that sent out bluetooth pings every 25ms we could probably address those, though of course with some tradeoff between the two.</p>
<p>here’s the python script we wrote:</p>
<figure data-rehype-pretty-code-figure=""><pre tabindex="0" data-language="python" data-theme="github-light github-dark"><code data-language="python" data-theme="github-light github-dark" style="display: grid;"><span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> asyncio</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> hashlib</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ipdb</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">from</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> bleak </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> BleakScanner</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">import</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> mido</span></span>
<span data-line=""> </span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">NUM_CCS</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 8</span></span>
<span data-line=""><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">BASE_CC</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 70</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">MIN_RSSI</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> 0x</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">30</span></span>
<span data-line=""><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">MAX_RSSI</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> =</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> 0x</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">60</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> clamp</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(lo, hi, x):</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> x </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> lo:</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> lo</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> elif</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> x </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">></span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> hi:</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> hi</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> x</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> scale</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(from_lo, from_hi, to_lo, to_hi, x):</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (clamp(from_lo, from_hi, x) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> from_lo) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">/</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (from_hi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> from_lo) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">*</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (to_hi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to_lo) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">+</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> to_lo</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> rssi_to_midi</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(rssi):</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> return</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> round</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(scale(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">MIN_RSSI</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">MAX_RSSI</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">0</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">127</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">abs</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(rssi)))</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> valid_ad</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(dev, ad):</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> return</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> dev.name </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> \</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> dev.name.startswith(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">'Jessie'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> \</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ad.rssi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">is</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> not</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> and</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> \</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (ad.tx_power </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">is</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> None</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> or</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> ad.tx_power </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 50</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> update_cc</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(port, cc, val):</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> port.send(mido.Message(</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">'control_change'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">control</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">cc, </span><span style="--shiki-light:#E36209;--shiki-dark:#FFAB70">value</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">val))</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> def</span><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0"> main</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">():</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> port </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> mido.open_output()</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> cc_nums </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> {}</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> with</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> BleakScanner() </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">as</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> scanner:</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> async</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> for</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> bd, ad </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> scanner.advertisement_data():</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> not</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> valid_ad(bd, ad):</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> continue</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> bd.address </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">not</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> in</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> cc_nums:</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> len</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(cc_nums) </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">&#x3C;</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> NUM_CCS</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> cc_nums[bd.address] </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> BASE_CC</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> +</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> len</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(cc_nums)</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> else</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> continue</span></span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> val </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">=</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> rssi_to_midi(ad.rssi </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">-</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> (ad.tx_power </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">or</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> 8</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">))</span></span>
<span data-line=""><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> print</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">(</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">f</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">bd.name</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> -> </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">{</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">val</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF">}</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF">"</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">)</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> update_cc(port, cc_nums[bd.address], val)</span></span>
<span data-line=""> </span>
<span data-line=""> </span>
<span data-line=""><span style="--shiki-light:#D73A49;--shiki-dark:#F97583">if</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF"> __name__</span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583"> ==</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF"> '__main__'</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8">:</span></span>
<span data-line=""><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8"> asyncio.run(main())</span></span></code></pre></figure>
<p>if i/we work on it any more, i’ll put it in a repo somewhere</p></description>
<pubDate>Fri, 01 Dec 2023 21:39:00 GMT</pubDate>
</item>
</channel>
</rss>