Skip to content

DEV-1478: Shimmer Capture's microphone - audio recording, sound level, audio status - #354

Merged
JongChern merged 1 commit into
masterfrom
DEV-1478_capture_audio
Nov 16, 2026
Merged

JongChern merged 1 commit into
masterfrom
DEV-1478_capture_audio

Conversation

@JongChern

@JongChern JongChern commented Nov 16, 2026 •

Copy link
Copy Markdown
Contributor

The Java Shimmer Capture app (ShimmerPCBasicExamples, com.shimmerresearch.capture, DEV-1473 / #350) gets the microphone half of shimmer-host-core's bindings/CAPTURE.md section "Event markers and audio recording". It uses the driver calls DEV-1459 brought to master in #353 (setAudioMode, getAudioModeToWrite, readAudioStatus, isAudioSupported, the audio flags) and the sound level channel from DEV-1413 (#346).

Jira: DEV-1478.

What it adds

The window. The Stream tab's button is now Event markers and audio.... EventMarkersFrame gets an Audio section for configuration byte 233:

  • Audio recording: Off, Fingerprint only, Fingerprint and raw audio, or Raw audio only (the driver's names).
  • Sound level: the Sound_Level channel, offered from LogAndStream_Shimmer3R v1.01.026.
  • Write sets both on the driver, writes the whole configuration and reads it back, then sends an inquiry, since the sound level adds or removes a channel. The line below shows what the unit kept.
  • Read audio status (GET_AUDIO_STATUS), only while not streaming: the driver reads that reply between commands, not between data packets.
  • Ask again also sends GET_AUDIO_STATUS to a v1.01.025 unit, the one version that says whether it records audio only by answering it.

Raw audio records speech. Where the new mode keeps raw audio and the unit's own (as last read) does not, Write asks first and writes nothing on No, as CAPTURE.md has it. The driver's ShimmerObject.setRawAudioAllowed is process-wide, so it is set for that one write and put back. Without a yes, getAudioModeToWrite() writes the mode without the raw audio, as it does today. A unit that already keeps raw audio is not asked.

MicrophoneSettings (new, simpleexamples, no Swing) holds byte 233's rules, so they are tested without a window.

Device tab: the status's Recording audio and Audio fault flags beside the other nine where the unit records audio, and a line saying whether the firmware has the event markers (yes, no, not asked yet) and audio recording (yes, no).

EventMarkersFrame is shared with SensorMapsExample, which gets the Audio section too.

Sound_Level already reached the plot's Other panel and the CSV through the driver; a test now holds the CSV columns, with NaN / -32768 while the unit has no level yet.

Tests

Unit tests. ./gradlew :test --tests 'com.shimmerresearch.capture.*' in ShimmerPCBasicExamples: 26 pass, 11 of them new. The new ones check byte 233 as it would be written, on a ShimmerPC read with a given byte 233: a raw mode with and without a yes, a unit that already keeps raw audio, the driver's raw audio switch put back, the sound level bit on v1.01.026 and not on v1.01.025, and the flags as shown. CI does not build this module.

On the bench (2026-11-16): a Shimmer3R GSR+ (SR48.8.1) on LogAndStream v1.1.26, over Bluetooth Classic, driven through the code the window's buttons call. 34 of 35 checks passed:

  • Every mode with Sound Level on and off (8 writes): each read back exactly as written, 0x10 / 0x00 / 0x11 / 0x01 / 0x12 / 0x02 / 0x13 / 0x03, and the packet size went 23 ↔ 25 as the channel came and went. Configuration byte 6 (the wide-range accelerometer's setup) stayed as it was through every write.
  • The raw audio rule: Off → Raw only without a yes was written as Off; Fingerprint → Fingerprint and raw without a yes as Fingerprint only; on a unit keeping raw audio already, no question, and Raw only was kept.
  • Sound_Level streamed: 357 samples; the first 15 (about 0.3 s, while the level settles) NaN with raw −32768, then 50.9 to 52.5 dB(A) in a quiet room. In the CSV as Sound_Level_CAL, Sound_Level_RAW in dB(A). With Sound Level turned off, the next stream had no Sound_Level.
  • Read audio status at READY: not recording, no fault.
  • Not checked: Recording audio while logging. That unit would not start logging at all, with audio Off as well (it ACKs START_LOGGING_ONLY, and the next status shows it not logging; no session appeared on its card). So that is the unit, not this change, and the check is still owed on a unit that logs.

An earlier hand run in the window showed the raw audio question and its Yes writing 0x13.

To test

On a Shimmer3R with LogAndStream v1.01.026 or later that logs over Bluetooth. ./gradlew runCapture in ShimmerPCBasicExamples, pick the unit's COM port, Connect, then Event markers and audio... on the Stream tab.

  1. The top line says audio recording yes. On the Device tab, Firmware has: event markers yes, audio recording yes; Status ends with recording audio no, audio fault no.
  2. Set Audio recording to Fingerprint only, tick Sound level, Write. The line under the buttons reads Fingerprint only, sound level on.
  3. Start on the Stream tab: Sound_Level appears in the Other panel. Record to CSV for a few seconds: the file has Sound_Level_CAL and Sound_Level_RAW.
  4. Stop. Untick Sound level, Write, Start again: Sound_Level is gone.
  5. While streaming, Read audio status refuses with a message.
  6. Stopped: Read audio status shows recording audio no.
  7. Start logging (Device tab), wait a few seconds, Read audio status: recording audio yes. The Device tab's Status shows it too. Stop logging; it goes back to no.
  8. Pick Fingerprint and raw audio, Write: the speech question appears. Answer No: nothing is written. Write again and answer Yes: the line reads Fingerprint and raw audio.
  9. Put the unit back how you found it (Audio recording Off, or as it was), and Write.
  10. On a v1.01.025 unit: audio recording no, and Audio recording and Sound level are greyed.

Don't log with a raw mode unless everyone nearby has agreed: it records speech to the card.

Elsewhere

  • The driver: unchanged.
  • Sibling APIs: this is app code, not a protocol, parsing or calibration change, so nothing is owed to the C#, Python, web or Swift APIs.
  • shimmer-host-core: none owed. Its Capture apps already have this view (C ABI 22), and this app follows them.
  • Left out, as CAPTURE.md lists them as not yet in any app: a WAV header or fingerprint file opened from disk, and the audio/ files downloaded with their session (the driver has no SD card over Bluetooth).

🤖 Generated with Claude Code

…, audio status

The Java Shimmer Capture app gets the microphone half of shimmer-host-core's
CAPTURE.md "Event markers and audio recording", on the driver calls DEV-1459
brought to master (#353) and the sound level channel from DEV-1413 (#346).

- EventMarkersFrame, now "Event markers and audio": configuration byte 233's
  audio recording mode (Off, Fingerprint only, Fingerprint and raw audio, Raw
  audio only) and Sound Level, written with the whole configuration and read
  back, then an inquiry for the channel list; Read audio status from READY.
- Raw audio records speech: Write asks first where the new mode keeps raw
  audio and the unit's own does not, and writes nothing on No. The driver's
  raw audio switch is set for that one write and put back.
- MicrophoneSettings: byte 233's rules without Swing, so they are tested.
- Device tab: the status's Recording audio and Audio fault flags where the
  unit records audio, and whether the firmware has the event markers and
  audio recording.
- CaptureRulesTest: 11 tests, byte 233 as written checked on a ShimmerPC.
- README.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@JongChern
JongChern marked this pull request as ready for review November 16, 2026 04:22
@JongChern
JongChern merged commit 00c409d into master Nov 16, 2026
2 checks passed
@JongChern
JongChern deleted the DEV-1478_capture_audio branch November 16, 2026 05:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants