--min-amplitude flag to control how sensitive the accelerometer detection is. This determines the minimum g-force required to trigger an audio response.
The min-amplitude Flag
main.go:200
Default value:
0.3Valid range: 0.0 to 1.0Lower values = more sensitive (detects lighter taps)Higher values = less sensitive (requires harder impacts)How It Works
When the accelerometer detects motion, Spank calculates the amplitude (g-force magnitude) of the impact. The audio only plays if:- The amplitude exceeds the
--min-amplitudethreshold - At least 750ms has passed since the last sound (cooldown)
main.go:336-338
Validation
Spank validates the min-amplitude value at startup. Values outside the 0.0-1.0 range will cause an error. Code Reference:main.go:226-228
Recommended Values
Choose a sensitivity level based on your use case:- High Sensitivity
- Medium Sensitivity (Default)
- Low Sensitivity
Values: Best for:
0.05 - 0.15- Detecting light taps and gentle touches
- Testing the accelerometer response
- Very reactive setups
- May trigger on keyboard typing or normal movement
- Could produce false positives from vibrations
- More frequent audio playback
Combining with Modes
The--min-amplitude flag works with all modes:
Real-Time Output
When a slap is detected, Spank logs the amplitude to help you tune your sensitivity:amp=X.XXXXXg shows the detected g-force. Use this to:
- Increase threshold: If you see unwanted triggers with low amplitudes
- Decrease threshold: If your slaps show high amplitudes but don’t trigger
main.go:343
Troubleshooting
Not triggering when I slap
Not triggering when I slap
Problem: Your slaps aren’t registeringSolution: Lower the min-amplitude valueObserve the console output to see detected amplitudes and adjust accordingly.
Too many false triggers
Too many false triggers
Problem: Normal typing or movement triggers soundsSolution: Raise the min-amplitude valueMonitor the console to see what amplitudes are causing false positives.
Inconsistent detection
Inconsistent detection
Problem: Some slaps trigger, others don’tPossible causes:
- Slapping with inconsistent force
- Laptop on soft surface (absorbs impact)
- 750ms cooldown preventing rapid slaps
- Use consistent force when testing
- Place laptop on hard surface
- Wait at least 750ms between slaps
Testing Your Settings
To find your ideal sensitivity:- Start with default:
sudo spank - Slap your laptop a few times with varying force
- Observe the amplitude values in the console output
- Adjust the threshold:
- If values are mostly above 0.4: try
--min-amplitude 0.35 - If values are around 0.2-0.3: keep default
0.3 - If values are below 0.2: try
--min-amplitude 0.15
- If values are mostly above 0.4: try