Skip to content

Instantly share code, notes, and snippets.

View aynik's full-sized avatar

Pablo Vazquez aynik

View GitHub Profile
@aynik
aynik / mix-bytes.c
Created June 13, 2022 11:25
mix-bytes
#!/usr/bin/env C -m
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
void mix_bytes(const char *in_even_fname, const char *in_odd_fname, int bytes)
{
int c;
FILE *fin_odd, *fin_even;
fin_even = fopen(in_even_fname, "rb");
@aynik
aynik / mdout-stream.sh
Created June 13, 2022 11:24
mdout-stream
#!/usr/bin/env bash
# usage: mdout-stream | mplayer -
mix-bytes \
<(sox -t coreaudio <LEFT_CHANNEL_AUDIO_IFACE> -t raw -r 16000 -c 1 -b 16 -e signed -L - | modem-rx) \
<(sox -t coreaudio <RIGHT_CHANNEL_AUDIO_IFACE> -t raw -r 16000 -c 1 -b 16 -e signed -L - | modem-rx)
@aynik
aynik / mdin.sh
Created June 13, 2022 11:22
mdin
#!/usr/bin/env bash
# usage: ./mdin.sh <input-file> <output-file.wav>
sox -G -M \
-t raw -r 16000 -c 1 -b 16 -e signed -L <(even-bytes < $1 | modem-tx) \
-t raw -r 16000 -c 1 -b 16 -e signed -L <(odd-bytes < $1 | modem-tx) \
-t wav -r 44100 $2
@aynik
aynik / odd-bytes.c
Created June 13, 2022 11:21
odd-bytes
#!/usr/bin/env C -m
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
void odd_bytes(const int bytes)
{
int c;
do
{
@aynik
aynik / even-bytes.c
Created June 13, 2022 11:21
even-bytes
#!/usr/bin/env C -m
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
void even_bytes(const int bytes)
{
int c;
do
{
@aynik
aynik / deinterleave.c
Last active June 8, 2022 09:13
interleave / deinterleave
#!/usr/bin/env C -m
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
void deinterleave(const char *out_even_fname, const char *out_odd_fname, int bytes)
{
int c;
FILE *fout_odd, *fout_even;
fout_odd = fopen(out_odd_fname, "wb");
@aynik
aynik / .bashrc
Created April 6, 2022 02:51
Bashrc lite
# Path
export PATH="/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/sbin:/bin"
# Return if non-interactive
case $- in
*i*) ;;
*) return;;
esac
shopt -s histappend
@aynik
aynik / modem-qam.py
Last active February 12, 2024 13:45
QAM/OFDM Audio Modem
#!/usr/bin/env python3
import os
import sys
import types
import struct
import itertools
import functools
import collections
@aynik
aynik / sox-coreaudio-full-device-names.patch
Created February 13, 2022 17:22
Sox coreaudio full device names
--- src/coreaudio.c
+++ src/coreaudio.c
@@ -152,6 +152,7 @@ static int setup(sox_format_t *ft, int is_input)
for (i = 0; i < device_count; i++)
{
char name[256];
+ property_size = sizeof(name);
status = AudioDeviceGetProperty(devices[i],0,false,kAudioDevicePropertyDeviceName,&property_size,&name);
lsx_report("Found Audio Device \"%s\"\n",name);
#!/usr/bin/env bash
set -eu
SKIP_TRACKS=$((${SKIP_TRACKS:=0} + 1))
while ALBUM="$1" && [ ! -z "$ALBUM" ]; do
find "$ALBUM" -iname "*.flac" \
| sed -e 's:\(.*/\)\([^/]*\):\2 \1\2:' \
| sort -n \
| sed -e 's:[^/]* ::' \