Skip to content

Instantly share code, notes, and snippets.

export function calculateCompression(audioData){
// Convert the linear values to dB
let audioDataInDb = audioData.map(x => -20 * Math.log10(x || 1e-9)); // Avoid log(0) by replacing 0 with a very small number
// Compute the peak value
let peak = Math.max(...audioDataInDb);
// Compute the RMS value
let sumOfSquares = 0;
@sunpazed
sunpazed / cv2win32.py
Last active August 12, 2023 10:49
MacOS fix for Fooocus to work correctly within a cv2 worker with AppKit
import threading
import cv2
buffer = []
cv2.namedWindow('Foooocus', cv2.WINDOW_NORMAL)
def worker():
global buffer
@sunpazed
sunpazed / release.sh
Created March 28, 2017 21:40
ConnectIQ release
#!/bin/bash
APP_NAME="<appname>"
KEYS="<path_to_keys>/key/"
P_INFO="<path_to_sdk>/connectiq-sdk-mac-2.2.4/bin/projectInfo.xml"
pkill simulator
monkeyc -y $KEYS/developer_key.der -o $APP_NAME.iq -m manifest.xml -z resources/resources.xml -z resources/settings/* -z resources/strings/strings.xml source/* -w -p $P_INFO -g -e -r
@sunpazed
sunpazed / build.sh
Created March 28, 2017 21:39
ConnectIQ build
#!/bin/bash
APP_NAME="<appname>"
KEYS="<path_to_keys>/key/"
P_INFO="<path_to_sdk>/connectiq-sdk-mac-2.2.4/bin/projectInfo.xml"
# kill the simulator if it's running
pkill simulator
# build via monkeyc
@sunpazed
sunpazed / pebble_handler_health_hr.c
Created November 6, 2016 03:09
Pebble HR handler
// -- init and handle health data ------------------------------------------
static void handler_health_hr(HealthEventType type, void *context) {
// if the update was from the Heart Rate Monitor, query it
if (type == HealthEventHeartRateUpdate) {
field_hr_value = health_service_peek_current_value(HealthMetricHeartRateBPM);
//field_hr_value = (uint32_t) 0x0000008F; // debug HR
}
if (state_is == STATE_RUN || state_is == STATE_PAUSE) {