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
15
votes
3 answers

How to convert sample rate from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16?

I am decoding aac to pcm with ffmpeg with avcodec_decode_audio3. However it decodes into AV_SAMPLE_FMT_FLTP sample format (PCM 32bit Float Planar) and i need AV_SAMPLE_FMT_S16 (PCM 16 bit signed - S16LE). I know that ffmpeg can do this easily with…
frankish
  • 6,738
  • 9
  • 49
  • 100
13
votes
2 answers

Why are an integers bytes stored backwards? Does this apply to headers only?

I'm currently trying to decipher WAV files. From headers to the PCM data. I've found a PDF (http://www.tdt.com/T2Support/technical_notes/tn0132.pdf) detailing the anatomy of a WAV file, and I've been able to extract and make sense of the appropriate…
Z3t
  • 133
  • 1
  • 4
13
votes
10 answers

Downsampling and applying a lowpass filter to digital audio

I've got a 44Khz audio stream from a CD, represented as an array of 16 bit PCM samples. I'd like to cut it down to an 11KHz stream. How do I do that? From my days of engineering class many years ago, I know that the stream won't be able to…
twk
  • 16,760
  • 23
  • 73
  • 97
13
votes
2 answers

Issue encoding and decoding an audio recording to G711 ( PCMU - uLaw) format

There isn't too much info about apply this codec when we need to streaming audio. Without apply the codec, my code work like a charm establishing a communication between 2 devices but I need encode/decode in that format because I will need streaming…
Juan Pedro Martinez
  • 1,924
  • 1
  • 15
  • 24
12
votes
1 answer

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

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…
Gilead
  • 1,516
  • 2
  • 18
  • 26
12
votes
1 answer

Convert PCM wave data to numpy arrays and vice versa

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…
tiefenauer
  • 669
  • 7
  • 19
12
votes
1 answer

How do you attach a reverb effect to AudioRecord/PCM data and save it to a file?

I want to record input from the microphone, attach a reverb effect, and persist the result to a file. My use-case is an app that lets you sing a song and select different preset reverb options after recording, and then save your performance and…
Jason Robinson
  • 31,005
  • 19
  • 77
  • 131
11
votes
1 answer

How can the PulseAudio asynchronous library be used to play raw PCM data?

A clear explanation seems to be missing in the PulseAudio documentation, and I cannot find any simple examples.
Gavin Haynes
  • 1,721
  • 11
  • 21
10
votes
1 answer

convert MP4 to WAV file (containing signed 16-bit PCM samples) in ffmpeg

I have an MP4 file which I am looking to convert to WAV file, containing signed 16-bit PCM samples. I have ffmpeg at my disposal, and looking at previous SOF posts, I have tried: ffmpeg -y -i input.mp4 -acodec pcm_s16le -f s16le -ac 1 -ar 16000…
JohnJ
  • 6,736
  • 13
  • 49
  • 82
10
votes
2 answers

How is audio data stored in raw pcm format?

I am writing an app to manipulate audio where i need to convert a file (wav, MP3, etc) to raw data (samples are presented as float) at the first place. I use ffmpeg in cmd: ffmpeg -i test.wav -f s16le -acodec pcm_s16le output.dat How are samples…
Tian Ye
  • 101
  • 1
  • 1
  • 3
9
votes
3 answers

PCM Wave file - stereo to mono

I have an audio file which is stereo. Is converting it to mono just a case of skipping every other byte (after the header)? It's encoded in 16bit signed PCM format. I've got javax.sound.sampled available. Here's code I tried that didn't…
fredley
  • 32,953
  • 42
  • 145
  • 236
9
votes
1 answer

Android How To record audio using MediaRecorder and output as raw PCM?

I currently record audio using MediaRecorder to produce .m4a, .mp4, .acc and .3gp, and also visualize the output data of each recording with VisualizerView. Now I would like to do the same thing with PCM. I have tried using MediaRecorder with…
user2308699
  • 239
  • 1
  • 5
  • 14
9
votes
1 answer

Convert two bytes into signed 16 bit integer in JavaScript

In JavaScript, I need to convert two bytes into a 16 bit integer, so that I can convert a stream of audio data into an array of signed PCM values. Most answers online for converting bytes to 16 bit integers use the following, but it does not work…
Rick Giuly
  • 983
  • 1
  • 14
  • 19
9
votes
3 answers

FFmpeg - resampling from AV_SAMPLE_FMT_FLTP to AV_SAMPLE_FMT_S16 got very bad sound quality (slow, out of tune, noise)

I was confused with resampling result in new ffmpeg. I decode an AAC audio into PCM, the ffmpeg show audio information as: Stream #0:0: Audio: aac, 44100 Hz, stereo, fltp, 122 kb/s In new ffmpeg, the output samples are fltp format, so I have to…
kaienfr
  • 315
  • 1
  • 3
  • 8
9
votes
2 answers

Converting MIDI file to raw audio using a software synth

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…
RjK
  • 91
  • 1
  • 3
1
2
3
51 52