DEV Community

Cover image for MannDaan (मन दान): an offering from the heart.
vimla
vimla

Posted on

MannDaan (मन दान): an offering from the heart.

This is a submission for the Presage SmartSpectra SDK Challenge

MannDaan (मन दान): an offering from the heart. A digital deepdaan for 2 AM
worries, because you can't float a diya from a hostel room.

What I Built

Last year, I stood on the steps of a ghat in Varanasi as the evening aarti began.
The bells rang, the fire rose, and all around me people knelt at the edge of the
Ganga to set small leaf-boat diyas on the water. It's called deepdaan, the
offering of a lamp. I floated one too, with a wish I've never said out loud to
anyone. I watched it drift until I couldn't tell which flame was mine. Nobody
around me tried to pull theirs back.

They say the Ganga takes whatever you're ready to release, and nothing you're
still holding.

But the ghat is far. Some nights you're awake at 2 AM with something heavy: a
goodbye you never got to say, someone you miss, words you can't tell anyone.
There's no river. There's just a laptop and a webcam.

MannDaan (मन दान, "an offering from the heart") brings the river to your desk. It
isn't a replacement for deepdaan or the Ganga. It's a small personal ritual,
inspired by what I felt on those steps, for the nights you can't get there. It:

  • Asks for consent before anything. The camera stays off until you say yes.
  • Writes your worry onto a diya sitting at the edge of a ghat at night.
  • Listens to your breath through the camera. Breathing live from the Presage SmartSpectra SDK drives the flame: rush it and the flame flickers and nearly dies, slow down and it stands tall and still. Your pulse sets the shimmer of the water and the tempo of the distant bells.
  • Refuses if you're still holding on. Breathe too fast and the current pushes your diya back to the ghat: "Ganga doesn't take what you're still holding."
  • Lets go after seven calm breaths. The diya drifts downstream and your words dissolve into the water like ink.
  • Keeps nothing. Your words are never written to disk, and no video is recorded. Nothing was saved. That was the point.

The ritual is the product. Without calm breathing, the diya does not float.
The SDK isn't decoration on top of an animation; it's the thing the animation
obeys.

Demo

What to watch for: the live breath/min and bpm readout in the corner carries the
SDK's own stable flag, a filled dot when the SDK considers the reading
reliable, a hollow one while it's still settling. The flame answers the chest
trace immediately; the seven flames light only on breaths the gate counts as
calm.

Code

GitHub logo vimla01 / manndaan

Write a worry on a diya. Breathe slowly for seven breaths, and the river takes it. Live breathing from your webcam.

MannDaan (मन दान)

An offering from the heart. Offer what weighs on your mann. Seven breaths. One diya.

Every evening at the ghats of Varanasi, people float a lit diya on the Ganga with a wish or a worry, deepdaan. You cannot do that from a hostel room at 2 AM before an exam.

MannDaan brings the ritual to your desk. You write down the one thing weighing on your mann, it appears on a diya at the edge of a night ghat, and then your breathing decides whether the river accepts it. Your breath is read from your webcam, live, by the Presage SmartSpectra SDK Rush, and the current pushes the diya back: "Ganga doesn't take what you're still holding." Breathe slowly for seven breaths, and it floats away downstream while your words dissolve into the water like ink.

Then it tells you the truth…

Setup is in the README: npm install, drop a Presage API key into .env, then
npm start. Without a key, npm run dev runs the entire ritual on a simulated
breath, so the piece can be explored with no camera and no credits.

Three files carry the integration:

  • main.js, binds the SDK to the window and refuses every camera request until consent is given.
  • src/renderer/js/signals/live.js, starts the camera, decodes metrics, turns validation codes into human guidance, restores the camera afterwards.
  • src/renderer/js/breathgate.js, the mechanic: detects breath cycles from the chest trace and decides calm, rushed, or in between.

How It Responds to Human Signals

Two live signals, both from the SmartSpectra SDK.

metrics.breathing.upperTrace, the raw chest trace, is the controller. It moves
with every breath, so the flame answers immediately: it stands tall and still
when you slow down, and gutters when you rush. Each exhale sends a ring of light
out across the water. The same trace feeds the gate that counts seven calm
breaths.

metrics.breathing.rate and metrics.cardio.pulseRate are the readout, shown
live in the corner with the SDK's own stable flag, a filled dot once the SDK
considers the reading reliable. Pulse also sets the shimmer on the water and the
tempo of the distant temple bells, one strike every eight heartbeats.

What you do What the river does
breathe in and out the flame rises and falls with the chest trace
exhale a ring spreads from the diya
a full breath of 5 s or longer one of seven flames lights
three rushed breaths in a row the diya drifts out, then the current pushes it back
your heart beats faster the water shimmers more, the bells quicken
the SDK cannot see you properly the ritual says why, in its own voice

The integration. bindSmartSpectraIpc in the main process, the SDK's preload
on the window, and the renderer SDK constructed with enableTelemetry: false.
MannDaan opens the camera itself at 640x480 and hands the stream to the SDK with
useMediaStream(), then decodes each metrics packet with decodeMetrics.
Camera permission is refused by the main process until the consent screen says
otherwise.

Electron, Canvas 2D, no frameworks, no art assets, the ghat, the water, the
moon and the diya are all drawn in code. The interesting part isn't the drawing
though. It's everything that went wrong between "the SDK is installed" and "the
diya moved because I breathed."

The numbers

Measured on a Dell laptop webcam, Ubuntu, @smartspectra/node-sdk 3.5.0, indoors
in daylight:

sdk.start() resolves 2.6 s
Metrics event cadence 27-29 events/s
First reading once framing is right ~10 s
First stable breathing rate 53 s
First stable pulse 82 s
Real calm breath cycles 5.6-6.9 s
CPU, vitals pipeline ~47% of a core
Renderer FPS during measurement 24 median

The cadence figure is worth writing down because the SDK docs don't state it
anywhere: breathing and pulse metrics arrive at roughly 28 Hz.

Why the flame follows the trace, not the rate

The first design drove the flame from breathing.rate. It felt broken: you'd
breathe, and nothing happened for half a minute. That's because the rate is a
long rolling average: it took 53 seconds before the SDK marked it stable.

The fix was to drive the flame from breathing.upperTrace, the raw chest trace,
which moves with every breath. The rate and the stable flag stayed on screen as
the honest readout, and the mechanic became immediate. If I'd kept the rate as
the input, the piece would not work at all.

One catch: the trace has no documented units. Mine ranged from -58 to +94,
and would differ per person and per camera. So it is normalised adaptively, with
a running mean and amplitude envelope, before it drives anything.

Four failures that all looked like "the camera is broken"

1. A metric I never used killed every session. Eleven seconds in, the SDK
went terminal and dropped every frame. I reproduced it without a camera, feeding
synthetic grey frames, and it ran clean: no error, but no metrics either,
because grey frames contain no face. That mismatch was the clue. The failure
needs a face, so it only happens once physiology inference runs, and the SDK's
source explains why: ARTERIAL_PRESSURE_TRACE needs an encrypted model that was
never delivered. I was asking for it without knowing, because cardioMetrics is
not just pulse. Requesting the two metrics I did not need was breaking the one
I did.

// before: convenient, and fatal
requestedMetrics: [...breathingMetrics, ...cardioMetrics],
// after
requestedMetrics: [...breathingMetrics, MetricType.PULSE_RATE],
Enter fullscreen mode Exit fullscreen mode

2. My own artwork was starving the measurement. frame rate stayed too low
to measure reliably
, while the camera was confirmed at 640x480 and 30 fps. The
camera was fine. My scene was rendering at 100+ fps and winning the fight for
CPU. It now caps at 30, sheds its expensive water effects under load, and drops
to 15 whenever the SDK reports it is short of frames.

3. Nobody's chest is in frame. 25 rejections in one session and 40 seconds
before a single reading. Breathing is measured from chest movement, and at
laptop distance a webcam sees a face and shoulders. There is now a framing step
that waits until the SDK is satisfied.

4. The one I am least proud of: I left the webcam broken. The SDK locks
auto-exposure while measuring, and on Linux that is a device-level setting which
outlives the process. I released the camera without restoring it, so every other
app on the machine, video calls included, inherited a dark fixed exposure. My
first fix only ran when the ritual completed, so quitting or crashing still left
it locked; the app now holds its own shutdown open until the camera is restored,
and handles SIGTERM so even pkill routes through it.

If an SDK changes hardware state, you own putting it back. That is the lesson
I would hand to anyone else building on a vitals SDK.

What the SDK gets right

validationStatus tells you precisely why it isn't measuring, and it is specific
enough to turn straight into guidance. I mapped every code to a line in the
ritual's voice:

SDK says MannDaan says
kChestNotVisible Sit back, the river reads your breath from your chest.
kTooDark Too dark for the lamp. Turn on a light, or face a window.
kExcessiveMotion Be still, like the water.
kFrameRateTooLow More light would help, the lamp is seeing you in slow motion.

That last translation matters. The SDK's own text is "Use a camera mode that
provides at least 25 frames per second", which is meaningless to someone sitting
in the dark trying to breathe. A slow camera almost always means a dim room.

So when the SDK reports the frame is too dark, the diya's glow swells and
lights your face
. The screen becomes the lamp. It is the oldest trick in the
selfie-camera book, except here it is thematically honest: the lamp you are
holding lights you.

The pulse drives the sound as well. There are no audio files in this project;
the river is filtered noise and the temple bells are inharmonic partials through
a generated reverb, struck once every eight heartbeats:

const beat = 60 / this.pulse;          // from metrics.cardio.pulseRate
const next = Math.min(14, Math.max(5, beat * 8));
Enter fullscreen mode Exit fullscreen mode

Prize Categories

Best Thoughtful Real-World Use. The real-world use isn't a dashboard of
vitals: it's a ritual that millions of people already perform, made available to
someone who can't reach a river at 2 AM. Breathing is the one physiological
signal you can consciously change, which makes it the only honest choice for a
mechanic that asks you to do something rather than be measured. And the
thoughtfulness is in the restraint: the app refuses to keep anything, says so,
and proves it by showing you the live numbers and then throwing them away.

Most Creative or Delightful Use. The delight is that the river argues with
you. The diya drifts out, and if you were rushing, the current brings it back
with a line that lands harder than any error message: "Ganga doesn't take what
you're still holding."
Your breath is the controller, the flame is the feedback,
and seven small lights fill up while you slow down. The closing line,
"Nothing was saved. That was the point.", is the only ending a piece about
letting go could have.

Consent and Data Handling

  • The camera is off until you consent. The main process denies every camera request until the consent screen reports that you pressed "Light the diya", and locks it again when the ritual ends.
  • What you write is never stored. The worry lives in one string in memory. It is never written to disk, logs, localStorage or any server, and is overwritten and cleared when the diya is released.
  • No video is recorded. Frames go to the SDK and are discarded. No images, no uploads, no session history, not even the breathing numbers.
  • No accounts, no analytics, no AI services. There is no backend.
  • SDK telemetry is disabled (enableTelemetry: false). Presage's docs state that with it off the SDK "starts no telemetry session and transmits nothing". Enabled, it would send session summaries and device diagnostics.
  • Measurement happens on your device. Presage's documentation states "On-device processing for iOS, Android, C++ and Node.js". The SDK contacts Presage only to validate the API key and report usage against your credits.
  • The camera is handed back with automatic exposure restored, before the app finishes quitting.

No diagnosis, no treatment, no health claims. The thresholds are game mechanics,
"calm enough for the river", not judgements about anyone.

Agent Session

Top comments (0)