Core Concept:
- Continuously monitor microphone input for high-energy acoustic signatures (e.g., gunfire, explosions, screams).
- If matched, trigger a local event, optionally queue for IPFS broadcast, and/or activate SafeSignal Defender alerts.
Detection Methods
- FFT-based acoustic fingerprinting
- Machine learning (lightweight CNN/RNN)
- Optional: spectrogram pattern matching
- All processing done locally, to preserve privacy and reduce latency
Endpoints (API Spec)
yamlPOST /acoustic/start
- Begins audio monitoring with specified detection sensitivity
- Payload: { sensitivity: 0.0–1.0, filters: [“gunshot”, “scream”], offlineMode: true }
POST /acoustic/event
- Accepts a manually tagged acoustic event (e.g., from hardware button or AI engine)
- Payload: { type: “gunshot”, location: "lat,long", timestamp: "...", cid: "..." }
GET /acoustic/logs
- Retrieves detected acoustic events from local or synced logs
POST /acoustic/report
- Broadcasts CID of event report to validators / OTA network
🛠️Device Support
- Raspberry Pi + external mic array
- Thetis SDR w/ audio input
- Windows-based validator nodes (more compute for AI filtering)
Relay & Response (Optional)
- Relay detection via:
- HF SDR (if no internet)
- IPFS broadcast
- Edge-pinned CID log
- Trigger:
- Silent alerts
- Push to Defender node
- Nearby validator notification
Privacy & Verification
- MAC-auth for source device
- CID-signed audio hash (optional)
- Local-only retention or timed broadcast delay (for safety)
Sample sdk
Core Hardware Nodes
Purpose | Part | Notes |
---|
SDR Receiver | Hermes Lite 2 | High-quality HF SDR for accurate capture + MAC registration |
Companion Pi | Raspberry Pi 4B (4GB or 8GB) | Runs Thetis or Pi Router w/ gunshot logic |
Outdoor Enclosure | IP67-rated case with antenna port | Weatherproof for pole or rooftop mount |
Power | 12V solar + battery pack | For uninterrupted operation in remote areas |
Acoustic Gunshot Detection System
Sensor | Model | Integration |
---|
Microphone Array | ReSpeaker 4-Mic Array for Pi | Supports basic triangulation |
Analog Mic (alt) | Adafruit Electret Mic + Preamp | Lower-cost sensor per node |
Processing | Built-in to Pi via gunshot_analyzer.py | Uses FFT + envelope detection |
Communications
Medium | Part | Notes |
---|
Primary Relay | OTR Mesh (MAC-router + SDR) | CID relay of gunshot + timestamp |
Backup | LoRa 915MHz Gateway | Range-based fallback; not ideal for high volume |
Long-Haul | Iridium GO! or LTE Stick (optional) | Fallback IPFS sync when internet present |
Logic + Storage
Task | Part/Software | Notes |
---|
CID logging | Pi + gunshot_logger.py | Logs + pushes gunfire CIDs to IPFS |
Event sync | SafeSignal or /eventsync.py | Broadcasts to other trusted nodes |
Mode switch | band_matrix_ui.py | Enables dedicated gunshot mode (e.g., listen-only) |
Security + Auth
Function | Part | Notes |
---|
MAC Auth | Built-in OTR node logic | Auto-verifies validator relay and logs |
Device Auth | /device/verify + alias_api_server.py | Prevent rogue node injection |
Tamper Sensor | Optional IMU or reed switch | Triggers alert if box opened or moved |
Operator Panel (Optional)
Interface | Tool | Description |
---|
Local Admin | gunshot_dashboard.html | Web dashboard from LAN or VPN |
Remote Sync | /gunshot/view API | Pulls CID log, shows map, waveform, time |
Core Node Hardware
Part | Description | Link (Example) | Approx Price |
---|
Raspberry Pi 4 (4GB or 8GB) | Main controller with USB support | Amazon | $60–$85 |
MicroSD Card (32–128GB) | Boot + storage | Amazon | $10–$25 |
USB Microphone (Omni-directional) | Acoustic capture | Amazon | $15–$40 |
GPS Module (e.g., u-blox NEO-6M) | Location for triangulation + sync | Amazon | $12–$18 |
Real-Time Clock (RTC) module (DS3231) | Timestamp accuracy offline | Amazon | $8–$15 |
LoRa Module (e.g., RFM95W SX1276) | OTR comms layer | Amazon | $10–$18 |
LoRa Hat or USB adapter | Interface to Pi | PiHat | $14–$22 |
Weatherproof Outdoor Case | Field deployment enclosure | Amazon | $25–$50 |
Power Bank or Solar + Battery Pack | Power for remote units | Amazon | $25–$70 |
Network + Software Stack
Feature | Tool / Package | Notes |
---|
Acoustic Classifier | TensorFlow Lite or PyTorch | Trained to detect gunshot vs. other impulse noise |
Triangulation Engine | Custom OTA Python module | Based on timestamp and GPS across 3+ nodes |
LoRa OTR Relay | lora_node_api + ipfshttpclient | Mesh+IPFS bridge |
IPFS Logging | Go-IPFS binary or embedded client | For CID-based event audit trail |
CLI/GUI Ops Tool | lora_gui.py (you approved this) | Manual ops or debug |
Optional Add-ons
- AI camera module (OpenCV compatible) — For visual correlation
- Acoustic MEMS mic array — For more precise detection (e.g., SPH0645LM4H)
- Remote OTAwallet uplink node — Automatically logs CIDs and payout on match (trigger alert → mint)
/gunshot/view
Endpoint (FastAPI Example)
pythonfrom fastapi import FastAPI
from pydantic import BaseModel
from typing import List
import json
from datetime import datetime
import os
app = FastAPI()
# Simulated local log file
LOG_FILE = "gunshot_events.json"
class GunshotEvent(BaseModel):
timestamp: str
latitude: float
longitude: float
confidence: float
cid: str
node_id: str
@app.get("/gunshot/view", response_model=List[GunshotEvent])
def view_gunshot_events(limit: int = 20):
if not os.path.exists(LOG_FILE):
return []
with open(LOG_FILE, "r") as f:
events = json.load(f)
return sorted(events, key=lambda e: e["timestamp"], reverse=True)[:limit]
Example Log File (gunshot_events.json
)
json[
{
"timestamp": "2025-06-04T21:14:55Z",
"latitude": 34.0522,
"longitude": -118.2437,
"confidence": 0.92,
"cid": "QmExampleCID123",
"node_id": "node-west01"
},
{
"timestamp": "2025-06-04T20:59:31Z",
"latitude": 34.0500,
"longitude": -118.2450,
"confidence": 0.87,
"cid": "QmExampleCID456",
"node_id": "node-west02"
}
]
Optional Add-ons
/gunshot/push
: Upload log to IPFS and return CID
/gunshot/geo
: Return all points as GeoJSON for map overlay
/gunshot/node-stats
: Count per-node detection and confidence level summary