Skip to content

Instantly share code, notes, and snippets.

@alpereira7
alpereira7 / sound_playback.c
Last active September 24, 2020 09:17 — forked from ghedo/sound_playback.c
Simple sound playback using ALSA API and libasound
/*
* Simple sound playback using ALSA API and libasound.
*
* Compile:
* $ cc -o play sound_playback.c -lasound
*
* Usage:
* $ ./play <sample_rate> <channels> <seconds> < <file>
*
* Examples:
/*
A Minimal Capture Program
This program opens an audio interface for capture, configures it for
stereo, 16 bit, 44.1kHz, interleaved conventional read/write
access. Then its reads a chunk of random data from it, and exits. It
isn't meant to be a real program.
From on Paul David's tutorial : http://equalarea.com/paul/alsa-audio.html
@alpereira7
alpereira7 / capture_nb_chan.c
Last active March 14, 2021 20:05
Simple alsa API example. Get the min and max number of channels supported by capture audio device and other values.
/*
* file: capture_nb_chan.c
* description: Simple alsa API example. Get the min and max number of channels supported by capture audio device and other values.
* doc: https://www.alsa-project.org/alsa-doc/alsa-lib/index.html
* install asound: apt-get install libasound2
* apt-get install libasound2-dev
* compile: gcc -o capture_nb_chan capture_nb_chan.c -lasound
* execute: ./capture_nb_chan
* expected output (something similar to) :
* Min channels: 2. (0)
@alpereira7
alpereira7 / asus-bt400-linux-install.md
Created December 14, 2020 15:47 — forked from ssledz/asus-bt400-linux-install.md
Linux Installation guide for Asus USB-BT400

Download driver

curl 'https://dlcdnets.asus.com/pub/ASUS/wireless/USB-BT400/DR_USB_BT400_1201710_Windows.zip' \
  -o bt400-driver.zip

Driver & tools for bt400 can be found here

Find out what is a filename for your driver

Plug device and do

@alpereira7
alpereira7 / simplescan.c
Last active January 8, 2021 10:46
Simple program that detects nearby Bluetooth devices.
// Simple program that detects nearby Bluetooth devices.
// Based on https://people.csail.mit.edu/albert/bluez-intro/c404.html#simplescan.c
// Enhanced with comments and personal notes.
// To compile:
// `gcc -o simplescan simplescan.c -lbluetooth`
// Install libbluetooth-dev:
// `sudo apt-get install libbluetooth-dev`
#include <stdio.h>
// Simple program to read and write Class of Device.
// To compile: `gcc -o rw_cod rw_cod.c -lbluetooth`
// To install lbluetooth: `apt-get install libbluetooth-dev`
// Execute with 'sudo'
// Note the original CoD first because it has strict rules, you might need to write it back later.
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h> // for close()
#include <bluetooth/bluetooth.h>
@alpereira7
alpereira7 / gist:3b50b9261a03de7ce58e16e6cdee4660
Created March 14, 2021 20:07
Simple alsa API example. Get the min and max number of channels supported by playback audio device and other values.
/*
* file: playback_nb_chan.c
* description: Simple alsa API example. Get the min and max number of channels supported by playback audio device and other values.
* doc: https://www.alsa-project.org/alsa-doc/alsa-lib/index.html
* install asound: apt-get install libasound2
* apt-get install libasound2-dev
* compile: gcc -o playback_nb_chan playback_nb_chan.c -lasound
* execute: ./playback_nb_chan
* expected output (something similar to) :
* Min channels: 2. (0)