Questions tagged [pcm]

Use this tag for questions about the Pulse-Code Modulation representation of sampled signals.

Pulse-Code Modulation (PCM) is a method used to digitally represent sampled analog signals. It is the standard form for digital audio in computers and various Blu-ray, DVD and Compact Disc formats, as well as other uses such as digital telephone systems. A PCM stream is a digital representation of an analog signal, in which the magnitude of the analog signal is sampled regularly at uniform intervals, with each sample being quantized to the nearest value within a range of digital steps. PCM streams have two basic properties that determine their fidelity to the original analog signal: the sampling rate, which is the number of times per second that samples are taken; and the bit depth, which determines the number of possible digital values that each sample can take.

Pulse-code modulation is an uncompressed audio encoding method. PCM is used in the .WAV, and .PCM file formats, and for encoding audio CDs, among many other uses. Digital signal processing algorithms like filters or FFT interact with the data when its in PCM format. When compressed audio format conversions are made, say from aac to flac, the data is converted from the source codec into PCM and then into the target codec. PCM can be considered the fundamental representation of digital time series data (EG. audio, financial ticker prices).

An alternative to PCM, with its sample rate and bit depth measurements, is the notion of storing the curve as a series of one bit samples. Instead of the ADC generating a sample of the absolute location of the height of the input analog curve when using the PCM approach, with this alternative one bit sample approach the ADC generates the relative position of the input analog curve. This one bit approach is memory efficient when performing very high sample rates.

780 questions
0
votes
1 answer

libsndfile cannot encode WAV with float array

I'm trying to write a file using libsndfile in C++, with an array of floats: void encode_file (const char *outfilename, int filetype) { static float buffer [BUFFER_LEN] ; for (int i = 0; i< BUFFER_LEN; i++) { buffer[i] =…
William Clark
  • 65
  • 1
  • 5
0
votes
1 answer

Need to upsample audio from 8k to 16k

I was using below code for downsampling my audio while recording let inputSampleRate; let inputBuffer = []; function init(x) { inputSampleRate = x; } function process(inputFrame) { for (let i = 0; i < inputFrame.length; i++) { …
0
votes
1 answer

How to play an array of [Int16] audio samples from memory in Swift

Trying to build a game music player (NSF, SPC etc) for Mac, using the GME library. I have spent hours upon hours testing so many solutions and tips here on SO, but it seems no solution works well. I have tried many variants of the…
Joneth
  • 91
  • 1
  • 9
0
votes
0 answers

Audio capture float format using ALSA - cannot set format

I'm trying to capture audio using Alsa and c/c++ library. I'm able to do it successfully using 16bit and 32bit Int but when I try to use floating point formats I'm not able to set the corresponding formats. example: //returns -22 and doesn't…
SM_PT
  • 1
  • 1
0
votes
2 answers

Android API for analyzing PCM data?

Is there an Android-native API which would help me analyzing raw PCM data? (Just basic things: frequency, volume of a data piece.) If not, are there good (non-Android-specific) references to reading PCM? Thank you!
java.is.for.desktop
  • 10,748
  • 12
  • 69
  • 103
0
votes
0 answers

Extraction of PCM from unknown file type

I have an old Korg KP3 that writes an obscure file type to SD card. I'm pretty sure there's a PCM in there, because the original support software for it can extract it to either aiff or wav files. That's what I want, but the original converter no…
4m1r
  • 12,234
  • 9
  • 46
  • 58
0
votes
1 answer

Go - int16 slice to byte slice

I'm writing a Go program that interfaces with libalsa. I have my PCM data stored in a []int16 slice, but to call libalsa I need that stored in a []byte slice. How do I convert a []int16 slice to []byte to accomplish this?
user96931
  • 103
  • 7
0
votes
1 answer

Convert Between 16 bit Scaled PCM Data to Floating Point PCM Data C++

I cannot convert between 16 bit Scaled PCM Data and Floating Point PCM Data in C++. I think I must be close because the output audio somewhat resembles what I expect, but it is distorted. The reason I am doing this is because I am running ScummVM…
0
votes
1 answer

How to convert PCM to MP3?

I am in the process of converting PCM to MP3 player. It does not work well to convert PCM files with 20KHz to MP3. What's the problem? And this is my code: using (var retMs = new MemoryStream()) using (var ms = new…
user10993563
0
votes
0 answers

How to get data from web assembly to JavaScript?

I have build the libopus library using emscripten compiler by writing wrapper over it and exposed some API to JavaScript which will get decoded audio PCM data. Now I am able to send data to web assembly from JavaScript to decode it but don't have…
0
votes
1 answer

Change Sample rate with AudioConverter

I am trying to re-sample the input audio 44.1 kHz to 48 kHz. using AudioToolbox's AUAudioUnit.inputHandler writing out the input 44.1 kHZ to a wav file (this is working perfectly) converting the 44.1 kHz to 48 kHz and writing out this converted…
szuniverse
  • 1,076
  • 4
  • 17
  • 32
0
votes
2 answers

Schedule buffer with AVAudioPCMBuffer int16 data

I'm trying to play music from byte array which is coming from the network in pcmInt16 data format. // formats let format1 = AVAudioFormat(commonFormat: AVAudioCommonFormat.pcmFormatFloat32, sampleRate: 48000, channels: 1, interleaved: false)! let…
szuniverse
  • 1,076
  • 4
  • 17
  • 32
0
votes
2 answers

How do I convert audio from one format to wav or raw in Java?

I am trying to figure out how to use the java.sound api to convert a WAV file to RAW/PCM format. I need to convert the WAV file from some given audio format to a RAW file encoded as follows: 16 kHz 16 bits Mono Signed Little endian Many of the…
Micha Pringle
  • 123
  • 2
  • 8
0
votes
0 answers

Play sounds synchronously using snd_pcm_writei

I need to play sounds upon certain events, and want to minimize processor load, because some image processing is being done too, and processor performance is limited. For the present, I play only one sound at a time, and I do it as follows: At…
hreba
  • 107
  • 1
  • 8
0
votes
1 answer

what is bits per sample Structure of .wav Audio Files

in the example of this post http://dracoater.blogspot.com/2008/11/comparing-2-audio-wav-files.html bits per sample is 0010 or 16 (in DEC) but why each sample contains 4 bytes ? 4 X 8 = 32 bits !?
user4254398
  • 373
  • 3
  • 12