pcm

Converting 16BitPCM to .wav, after switching endianness, the .wav file plays backwards

心已入冬 提交于 2021-01-07 01:36:33
问题 I am trying to build an Android app that records PCM audio and exports it as a wav file. It worked fine for 8BitPCM, but when I switched to 16BitPCM I got white noise. I finally figured out it was the endianness of the byte array, but now, after converting from Little Endian to Big Endian, I get my audio crystal clear, but reversed! Here is how I call the method: byte[] inputByteArray = convertLittleEndianToBig(readToByte(input)); and then that byte[] is appended to my .wav header here:

Converting 16BitPCM to .wav, after switching endianness, the .wav file plays backwards

北慕城南 提交于 2021-01-07 01:36:32
问题 I am trying to build an Android app that records PCM audio and exports it as a wav file. It worked fine for 8BitPCM, but when I switched to 16BitPCM I got white noise. I finally figured out it was the endianness of the byte array, but now, after converting from Little Endian to Big Endian, I get my audio crystal clear, but reversed! Here is how I call the method: byte[] inputByteArray = convertLittleEndianToBig(readToByte(input)); and then that byte[] is appended to my .wav header here:

Getting PCM data from wavesurfer.js backend/web audio api

寵の児 提交于 2020-06-27 16:25:08
问题 I am using wavesurfer.js to create a multitrack player online and want to export a remixed version of the combined tracks with levels panning etc. First I have an array of audioFiles and use this to create an array of wavesurfer elements. for(var i=0; i<audiofiles.length; i++){ spectrum[i] = WaveSurfer.create({ }); } I then create a buffer for each of these from wavesurfer backend for(var i=0; i<audiofiles.length; i++){ var ctx = spectrum[i].backend.ac; var length = spectrum[i].getDuration()

Play raw PCM audio received in UDP packets

风流意气都作罢 提交于 2020-06-25 18:30:04
问题 The remote device is sending live raw PCM audio(no header included) in UDP packets and I need to implement a program in java to receive these packets and play them on the PC live. As I know that raw PCM's attributes are 16bit, mono, sampling rate 24KHz, so I tried to add a wav header to this raw PCM audio and play but the problem is I don't have File size of the audio. I also implemented a program based on this link but it only gives noise in output. I am bound to use UDP and I can get only

Convert PCM wave data to numpy arrays and vice versa

浪尽此生 提交于 2020-06-09 18:32:12
问题 The situation I am using VAD (Voice Activity Detection) from WebRTC by using WebRTC-VAD, a Python adapter. The example implementation from the GitHub repo uses Python's wave module to read PCM data from files. Note that according to the comments the module only works with mono audio and a sampling rate of either 8000, 16000 or 32000 Hz. What I want to do Read audio data from arbitrary audio files (MP3 and WAV files) with different sampling rates, convert them into the PCM-representation that

How to change the volume of a PCM data stream (failed experiment)

前提是你 提交于 2020-05-25 04:31:24
问题 Solved My code was never before used for processing signed values and as such bytes -> short conversion was incorrectly handling the sign bit. Doing that properly solved the issue. The question was... I'm trying to change the volume of a PCM data stream. I can extract single channel data from a stereo file, do various silly experimental effects with the samples by skipping/duplicating them/inserting zeros/etc but I can't seem to find a way to modify actual sample values in any way and get a

Qt 播放音频文件

佐手、 提交于 2020-03-29 12:58:46
Qt播放音频文件的方法有好多中,简单介绍几种 不过一下几种方式都需要在Qt工程文件中添加 QT += multimedia 第一 QMediaPlayer类 可以播放MP3文件,同时使用也是最简单的了,具体代码 { player = new QMediaPlayer; connect(player, SIGNAL(positionChanged(qint64)), this, SLOT(positionChanged(qint64))); player->setMedia(QUrl::fromLocalFile("E:\\CloudMusic\\林沁简介 - 太阳的后裔 MIX.mp3")); player->setVolume(30); player->play(); } 该中实现方式适合单个文件的,如果有多个文件需要播放,那么需要使用下面的方式 { playlist = new QMediaPlaylist; playlist->addMedia(QUrl::fromLocalFile("E:\\CloudMusic\\林沁简介 - 太阳的后裔 MIX.mp3")); playlist->addMedia(QUrl::fromLocalFile("E:\\CloudMusic\\芭比 - 触电 (完整版).mp3")); playlist->addMedia(QUrl: