pcm

alsa声卡驱动分析总结(一)

落花浮王杯 提交于 2019-12-04 03:40:13
alsa声卡驱动分析总结 分析只列出部分重要代码,具体请参考 linux3.0 内核代码。 Alsa 架构整体来说十分复杂,但对于驱动移植来说我们仅仅只需要关心 ASOC 就足够了。 在学习 asoc 之前我们先了解一些专业术语: ASoC currently supportsthe three main Digital Audio Interfaces (DAI) found on SoC controllers and portable audio CODECs today, namelyAC97, I2S and PCM. ASoC 现在支持如今的SoC 控制器和便携 音频 解码器上的三个主要数字音频接口,即AC97 ,I2S,PCM(与pcm音频格式注意区分,前者是一种音频接口,后者是一种输入声卡的音频格式)。 AC97 AC97 ==== AC97 is a five wire interface commonly found on many PC soundcards. It is now also popular in many portable devices. This DAI has a reset line and time multiplexes its data on its SDATA_OUT (playback) and SDATA_IN

linux下ALSA音频驱动软件开发

血红的双手。 提交于 2019-12-04 03:39:32
最近一直忙于Linux下ALSA音频驱动的开,作了一次专题讨论,现将部分内容贴出来大家分享一下。 内容提要 一、音频相关的基础知识 •二、Linux下音频驱动开发模型 •三、socxx+ WM8993驱动实例分析 •四、总结 • 五、 Question& Discussion 音频相关的基础知识 ---- 采样、量化 •1、采样频率 • 常用 32kHz、 44.1kHz、 48kHz。 •2、量化精度 • 指对采样数据分析的精度,精度越高,声音就越逼真。常用8位、16位、24位。 音频相关的基础知识 ---- 音频设备硬件接口 •PCM接口:由时钟脉冲BCLK,帧同步信号FS及接收数据DR和发送数据DX组成。(先发MSB,后LSB)。 •IIS接口:在一个称为LRCLK的信号机制中经过多路转换,将两路音频信号变成单一的数据队列。LRCLK为高时,左声道数据被传输。 • AC97接口:AC97不只是一种数据格式,还具有控制功能。数据帧以SYNC脉冲开始,包括12个20位时间段及16位tag段,共256个数据序列。 音频相关的基础知识 ---- 音频放大器 • A类放大器 拓扑结构使用一只晶体管作为直流(DC)电流源,能够提供扬声器需要的最大音频电流。 • B类放大器 拓扑结构没有DC偏置电流,所以功耗大大减少。 • AB类放大器 是A类放大器和B类放大器的组合折衷

ALSA arm下录音

天涯浪子 提交于 2019-12-04 03:39:13
碰到一个开发 板录音的项目,结合网上的资料,自己总结 了一篇 头文件 #ifndef __RECORD_H #define __RECORD_H #include <alsa/asoundlib.h> #include <stdio.h> #include <stdlib.h> #include <string.h> #include <unistd.h> #include <sys/socket.h> #include <netinet/in.h> #include <arpa/inet.h> #include <signal.h> #include "threadsafe_queue.h" typedef long long off64_t; typedef struct SNDPCMContainer { snd_pcm_t *handle; snd_output_t *log; snd_pcm_uframes_t chunk_size; snd_pcm_uframes_t buffer_size; snd_pcm_format_t format; uint16_t channels;//声道 size_t chunk_bytes; uint32_t sample_rate;//采样率 size_t bits_per_sample;//比特率 size_t bits_per

IOS Swift read PCM Buffer

女生的网名这么多〃 提交于 2019-12-03 22:15:37
I have a project for Android reading a short[] array with PCM data from microphone Buffer for live analysis. I need to convert this functionality to iOS Swift. In Android it is very simple and looks like this.. import android.media.AudioFormat; import android.media.AudioRecord; ... AudioRecord recorder = new AudioRecord(MediaRecorder.AudioSource.DEFAULT, someSampleRate, AudioFormat.CHANNEL_IN_MONO, AudioFormat.ENCODING_PCM_16BIT, AudioRecord.getMinBufferSize(...)); recorder.startRecording(); later I read the buffer with recorder.read(data, offset, length); //data is short[] (That's what i'm

Converting a 8 bit PCM to 16 bit PCM

有些话、适合烂在心里 提交于 2019-12-03 21:54:49
Starting from this question I was made to understand how to deinterleave the left and right channel of a 16 bit PCM data. My question now is, how will a 8 bit PCM be deinterleaved and "stretched" into a 16 bit value 16-bit PCM has basically the same data bits and additional bits on the least significant bit side to specify the value and add accuracy and detail. Then 8-bit PCM is typically unsigned value with a centerpoint of 0x80 , and 16-bit (also applicable to higher bitnesses) PCM is signed integer, so the conversion formula is: UINT8 sample8 = ...; INT16 sample16 = (INT16) (sample8 - 0x80)

JTransforms FFT in Android from PCM data

折月煮酒 提交于 2019-12-03 19:38:43
问题 I've been playing with this now for sometime, I cant work out what I am meant to be doing here. I am reading in PCM audio data into an audioData array: recorder.read(audioData,0,bufferSize); //read the PCM audio data into the audioData array I want to use Piotr Wendykier's JTransform library in order to preform an FFT on my PCM data in order to obtain the frequency. import edu.emory.mathcs.jtransforms.fft.DoubleFFT_1D; At the moment I have this: DoubleFFT_1D fft = new DoubleFFT_1D(1024); //

PCM Raw Bytes [] To Audio on Android

社会主义新天地 提交于 2019-12-03 18:44:10
问题 I currently have a PCM audio in the form of a byte array. The format is signed 16 bit little endian. I would like to convert this to some playable format on the Android, preferably version 3.2 or higher. Does anyone have suggestions on how this can be done? I have done some research and tried the following below, but none were successful. It would be much appreciated if anyone can suggest a better way or indicate where I have gone wrong. I have tried creating an AudioFormat with the correct

Converting MIDI file to raw audio using a software synth

那年仲夏 提交于 2019-12-03 12:46:25
I'm trying to dynamically generate a small MP4 audio+video file directly from my Android app. My original plan of attack: The user enters some basic song data (a chord progression, etc) and the app builds a MIDI file. The system builds chord diagrams for each chord, and using a MIDI reader it generates the animations frames array that is timed to the MIDI Convert the MIDI into a raw PCM audio data <-- this S.O. question is specific to this point Apply the raw audio to the animation frames - and encode the audio and video frames into an MP4 Provide the resulting MP4 video to the user with

Getting PCM data of HLS from AVPlayer

£可爱£侵袭症+ 提交于 2019-12-03 10:32:45
问题 This question seems to be asked few times over last few years but none has answer for that. I am trying to process PCM data from HLS and I have to use AVPlayer. this post taps the local files https://chritto.wordpress.com/2013/01/07/processing-avplayers-audio-with-mtaudioprocessingtap/ and this tap work with remote files but not with .m3u8 hls files. http://venodesigns.net/2014/01/08/recording-live-audio-streams-on-ios/ I can play first two tracks in the playlist but it doesn't start the

Getting IOError: [Errno Invalid number of channels] -9998 when using mic with PyAudio on Raspberry Pi

匿名 (未验证) 提交于 2019-12-03 10:24:21
可以将文章内容翻译成中文,广告屏蔽插件可能会导致该功能失效(如失效,请关闭广告屏蔽插件后再试): 问题: Bad news, everyone! I try to use a microphone on my Raspberry Pi through PyAudio but without success. The microphone is connected to a USB sound card. The microphone works when I go through 'arecord' : pi@raspberrypi ~ $ arecord -D plughw:0,0 -f cd test2.wav Recording WAVE 'test2.wav' : Signed 16 bit Little Endian, Rate 44100 Hz, Stereo However, when I do the test record.py in PyAudio, I got an error. The error is the same for all programs in Python that uses PyAudio : pi@raspberrypi /usr/src/pyaudio/test $ python record.py ALSA lib pcm.c