Skip to content

Instantly share code, notes, and snippets.

View jarkkojs's full-sized avatar

Jarkko Sakkinen jarkkojs

View GitHub Profile
import sys
from zipfile import ZipFile
with ZipFile(sys.argv[1], 'r') as zip_file:
filename_list = zip_file.namelist()
for filename in filename_list:
print(filename)
if filename.endswith('.mp4'):
zip_file.extract(filename, sys.argv[2])
//! Copyright (c) Jarkko Sakkinen 2021
//!
//! A simple synthesis and playback test.
use cpal::Device;
use cpal::Sample;
use cpal::SampleFormat;
use cpal::StreamConfig;
use cpal::StreamError;
use cpal::traits::DeviceTrait;
find -maxdepth 1 -name "*.wav" -print0 | xargs --null -n1 basename | xargs -I{} sox "{}" "mono_{}" remix 1,2 norm -1
import numpy as np
import wave
NOTE_FREQUENCY = 261.63 # C4
NOTE_LENGTH = 1.0 / NOTE_FREQUENCY
SAMPLE_LENGTH = 1000.0 * NOTE_LENGTH
SAMPLE_RATE = 44100.0
t = np.linspace(0, SAMPLE_LENGTH, int(SAMPLE_LENGTH * SAMPLE_RATE))
s = np.sin(2 * np.pi * NOTE_FREQUENCY * t)
@jarkkojs
jarkkojs / 89-pulseaudio.rules
Last active April 13, 2021 19:45
/etc/udev/rules.d/89-pulseaudio.rules
# Audient EVO4
ATTRS{idVendor}=="2708", ATTRS{idProduct}=="0006", ENV{PULSE_IGNORE}="1"
# Intel Corporation Comet Lake PCH cAVS
ATTRS{vendor}=="0x8086", ATTRS{device}=="0x06c8", ENV{PULSE_IGNORE}="1"
# NVIDIA Corporation TU106 High Definition Audio Controller
ATTRS{vendor}=="0x10de", ATTRS{device}=="0x10f9", ENV{PULSE_IGNORE}="1"
@jarkkojs
jarkkojs / fix-home-directory-permissions.sh
Last active April 8, 2021 07:17
Fix home directory permissions
#!/bin/bash
find $HOME -perm /o=rwx -type f -not -path "$HOME/pCloudDrive/*" -print0 | xargs -0 chmod o-rwx
find $HOME -perm /o=rwx -type d -not -path "$HOME/pCloudDrive/*" -print0 | xargs -0 chmod o-rwx
# 0x01 view
# Ox02 read
# 0x04 write
# 0x08 search
# 0x10 link
# 0x20 setattr
#
# A key default permissions: 0x3f010000
# A keyring default permissions: 0x3f3f0000
@jarkkojs
jarkkojs / jack_init
Created December 12, 2020 21:45
In JACK2, command-line is the sanest interface.
#!/bin/sh
SOUND_CARD=$1
SAMPLE_RATE=$2
FRAMES_PER_INT=$3
FRAME_SIZE=$4
# Use the ALSA backend.
jack_control ds alsa
from matplotlib import pyplot as plt
from matplotlib import style
from scipy import signal
import numpy as np
FREQUENCY = 440 # A3
RATE = 44100
DURATION = 2 # seconds
NR_SAMPLES = DURATION * RATE
import sys
from elftools.elf.elffile import ELFFile
PAGE_SIZE = 0x1000
if __name__ == '__main__':
flags2str = ['---', '--x', '-w-', '-wx', 'r--', 'r-x', 'rw-', 'rwx']
if len(sys.argv) != 2:
sys.exit(1)