pcm

Writing PCM recorded data into a .wav file (java android)

别来无恙 提交于 2019-11-27 06:34:01
I'm using AudioRecord to record 16 bit PCM data in android. After recording the data and saving it to a file, I read it back to save it as .wav file. The problem is that the WAV files are recognized by media players but play nothing but pure noise. My best guess at the moment is that my wav file headers are incorrect but I have been unable to see what exactly the problem is. (I think this because I can play the raw PCM data that I recorded in Audacity) Here's my code for reading the raw PCM file and saving it as a .wav: private void properWAV(File fileToConvert, float newRecordingID){ try {

Convert 16 bit pcm to 8 bit

扶醉桌前 提交于 2019-11-27 06:16:59
问题 I have pcm audio stored in a byte array. It is 16 bits per sample. I want to make it 8 bit per sample audio. Can anyone suggest a good algorithm to do that? I haven't mentioned the bitrate because I think it isn't important for the algorithm - right? 回答1: I can't see right now why it's not enough to just take the upper byte, i.e. discard the lower 8 bits of each sample. That of course assumes that the samples are linear; if they're not then maybe you need to do something to linearize them

PCM -> AAC (Encoder) -> PCM(Decoder) in real-time with correct optimization

谁说我不能喝 提交于 2019-11-27 06:14:35
I'm trying to implement AudioRecord (MIC) -> PCM -> AAC Encoder AAC -> PCM Decode -> AudioTrack?? (SPEAKER) with MediaCodec on Android 4.1+ (API16). Firstly, I successfully (but not sure correctly optimized) implemented PCM -> AAC Encoder by MediaCodec as intended as below private boolean setEncoder(int rate) { encoder = MediaCodec.createEncoderByType("audio/mp4a-latm"); MediaFormat format = new MediaFormat(); format.setString(MediaFormat.KEY_MIME, "audio/mp4a-latm"); format.setInteger(MediaFormat.KEY_CHANNEL_COUNT, 1); format.setInteger(MediaFormat.KEY_SAMPLE_RATE, 44100); format.setInteger

Android AudioTrack playing .wav file, getting only white noise

断了今生、忘了曾经 提交于 2019-11-27 04:34:09
When I play a file with the following code: private void PlayAudioFileViaAudioTrack(int ResId) throws IOException { int intSize = android.media.AudioTrack.getMinBufferSize(11025, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT); AudioTrack at = new AudioTrack(AudioManager.STREAM_MUSIC, 11025, AudioFormat.CHANNEL_CONFIGURATION_MONO, AudioFormat.ENCODING_PCM_16BIT, intSize, AudioTrack.MODE_STREAM); int count = 256 * 1024; // 256 kb byte[] byteData = null; byteData = new byte[(int) count]; InputStream in = null; AssetFileDescriptor fd = null; fd = mResources

How to convert .pcm file to .wav or .mp3?

北战南征 提交于 2019-11-27 01:40:57
问题 I am currently developing an Android Application that has audio recording and playing. I am new to dealing with audio and I'm having some trouble with encoding and formats. I am able to record and play the audio in my application, but when exporting I am not able to reproduce the audio. The only way I found was exporting my .pcm file and converting using Audacity. This is my code to record the audio is: private Thread recordingThread private AudioRecord mRecorder; private boolean isRecording

PCM audio amplitude values?

让人想犯罪 __ 提交于 2019-11-27 00:10:53
问题 I am starting out with audio recording using my Android smartphone. I successfully saved voice recordings to a PCM file. When I parse the data and print out the signed, 16-bit values, I can create a graph like the one below. However, I do not understand the amplitude values along the y-axis. What exactly are the units for the amplitude values? The values are signed 16-bit, so they must range from -32K to +32K. But what do these values represent? Decibels? If I use 8-bit values, then the

Extract iPod Library raw PCM samples and play with sound effects

梦想的初衷 提交于 2019-11-26 19:16:13
问题 I am trying to extract raw PCM samples from an MP3 in the iPod Library so that I can play the song and manipulate the pitch, tempo, and apply sound effects (such as filters). I have already gone down the route of AVPlayer and AVAudioPlayer which both do not allow very much control over the playback at all. The code below is as far as I have gotten with this. I am at a point now where I do not know what to do with the CMSampleBufferRef's in my while loop because I do not know which framework

Qt 采集麦克风PCM数据并实时翻译

对着背影说爱祢 提交于 2019-11-26 16:39:57
一,需求 采集麦克风PCM数据,并利用有道 实时语音翻译 API进行显示 (1),麦克风数据采集 (2),调用有道API进行实时翻译 二,数据采集 根据有道 接口要求,数据采样率8k、16bit、wav(PCM编码)( https://irma.youdao.com/html/%E5%AE%9E%E6%97%B6%E8%AF%AD%E9%9F%B3%E7%BF%BB%E8%AF%91/API%E6%96%87%E6%A1%A3/%E5%AE%9E%E6%97%B6%E8%AF%AD%E9%9F%B3%E7%BF%BB%E8%AF%91%E6%9C%8D%E5%8A%A1/%E5%AE%9E%E6%97%B6%E8%AF%AD%E9%9F%B3%E7%BF%BB%E8%AF%91%E6%9C%8D%E5%8A%A1-API%E6%96%87%E6%A1%A3.html ) 传输方式 WSS 字符编码 统一使用UTF-8编码 响应格式 统一采用JSON格式 语音格式 wav(不压缩、pcm编码) 语音采样率 8k或者16k。推荐16k 语音编码 16bit位深的单声道 什么是PCM? PCM(Pulse Code Modulation,脉冲编码调制)音频数据是未经压缩的音频采样数据裸流,它是由模拟信号经过采样、量化、编码转换成的标准数字音频数据。 描述PCM数据的6个参数:

Creating a WAV file from raw PCM data using the Android SDK

狂风中的少年 提交于 2019-11-26 15:59:55
问题 I'm trying to use the AudioRecord class to record a WAV file. The problem is that it only supplies the raw PCM data, and if I write it to a file, there is no header information, so it will not play in any media player. How can I create a WAV file from this raw data? Or alternatively, is there any other way to record sound in Android to a WAV file (or, alternatively MP3)? Oh, and I know that MediaRecorder can'y be used because it doesn't support either WAV or MP3 formats. 回答1: OK, I've got

Writing PCM recorded data into a .wav file (java android)

此生再无相见时 提交于 2019-11-26 12:05:40
问题 I\'m using AudioRecord to record 16 bit PCM data in android. After recording the data and saving it to a file, I read it back to save it as .wav file. The problem is that the WAV files are recognized by media players but play nothing but pure noise. My best guess at the moment is that my wav file headers are incorrect but I have been unable to see what exactly the problem is. (I think this because I can play the raw PCM data that I recorded in Audacity) Here\'s my code for reading the raw PCM