Skip to content

Instantly share code, notes, and snippets.

@G10DRAS
Last active September 29, 2016 00:28
Show Gist options
  • Save G10DRAS/d6799ded9c4821ed49dffd60b1e96268 to your computer and use it in GitHub Desktop.
Save G10DRAS/d6799ded9c4821ed49dffd60b1e96268 to your computer and use it in GitHub Desktop.
ALSA Problem Solving on Jessie
lsusb
lsusb -v -d 1b3f:2007 | grep tSamFreq
cat /proc/asound/cards
cat /proc/asound/modules
cat ~/.asoundrc
cat /etc/asound.conf
alsamixer -c 0
alsamixer -c 1
amixer -c 0
amixer -c 1
arecord -L
arecord -l
aplay -L
aplay -l
##Use below python code to find index of Device
>> python
po = pyaudio.PyAudio()
for index in range(po.get_device_count()):
desc = po.get_device_info_by_index(index)
print "device_name index rate", desc["name"], index, int(desc["defaultSampleRate"])
##Sample Rate Convertion in ~/.asoundrc
pcm.record {
type plug;
slave {
pcm "hw:0,0"
}
}
##changes in /usr/share/alsa/alsa.conf
defaults.ctl.card 0
defaults.pcm.card 0
# load card-specific configuration files (on request)
##Change To
defaults.ctl.card 1
defaults.pcm.card 1
load card-specific configuration files (on request)
##Better do experiments with Record script available on PyAudio Website
https://people.csail.mit.edu/hubert/pyaudio/
##From Documentation & Examples section, take the code of Record example,
##modified it little bit as follows and then see if it works for you.
"""PyAudio example: Record a few seconds of audio and save to a WAVE file."""
CHUNK = 1024
FORMAT = pyaudio.paInt16
CHANNELS = 1
RATE = 16000
RECORD_SECONDS = 5
WAVE_OUTPUT_FILENAME = "output.wav"
p = pyaudio.PyAudio()
stream = p.open(format=FORMAT,
channels=CHANNELS,
rate=RATE,
input_device_index = 1, # change 1 with pcm.record plugin index
input=True,
frames_per_buffer=CHUNK)
##Find out the index of pcm.record plugin and set that in
input_device_index
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment