I'm using a DSP for audio processing, I get an audio input via Bluetooth (a2dp) and I output the processed audio through an analog connector to a headset.
The audio I receive from the Bluetooth device has a frequency of 44100 Hz, and one of the purposes of the DSP is to resample (upsample, downsample) the bluetooth audio to a frequency of my choosing, for example 48000 Hz.
I have already implemented the resampling (the manufacturer of the DSP has the code to do this) but I get random glitches in the output audio, and I have no idea why. The following images show a 400 Hz sine wave being played from the Bluetooth device to the analog output, being resampled from 44100 Hz to 48000 Hz, I connected a jack to this output and measured the resulting wave with an oscilloscope.
I can't find any patterns or something that tells me where to look. I've been trying to find the cause of this for over a week now and so far no success. Anyone have any ideas? I'm a bit desperate.
Please let me know if you need more details.
Related
As per Apple, in AAC encoding 2112 priming samples are added at the beginning of audio. When creating HLS stream with AAC audio, will these priming samples be added to the beginning of each HLS segment or only to the first HLS segment? And, how does this AAC encoder delay affect HLS DISCONTINUITY tags later in the HLS stream?
https://developer.apple.com/library/archive/documentation/QuickTime/QTFF/QTFFAppenG/QTFFAppenG.html
I depends on the AAC you use.
For 'old-style' AAC-LC you only have priming samples at the beginning of the stream and not at the beginning of each segment.
But the delay is carried through the entire stream.
Typically a new piece of media is displayed after a DISCONTINUITY tag - for example an advertisement - so you will receive another set of priming samples.
Your AAC audio decoder needs to discard the priming samples (first 2112) PCM output samples after startup and after DISCONTINUITY.
If you use the more modern xHE-AAC - you don't have to worry about priming samples anymore.
Another wrinkle - in the early days it was just assumed that AAC-LC has 2112 priming samples.
Now the number can be different and it can be signaled in the MP4 container as Edit-List.
The two streams I am decoding are an audio stream (adts AAC, 1 channel, 44100, 8-bit, 128bps) and a video stream (H264) which are received in an Mpeg-Ts stream, but I noticed something that doesn't make sense to me when I decode the AAC audio frames and try to line up the audio/video stream timestamps. I'm decoding the PTS for each video and audio frame, however I only get a PTS in the audio stream every 7 frames.
When I decode a single audio frame I get back 1024 samples, always. The frame rate is 30fps, so I see 30 frames each with 1024 samples which comes equals 30,720 samples and not the expected 44,100 samples. This is a problem when computing the timeline as the timestamps on the frames are slightly different between the audio and video streams. It's very close, but since I compute the timestamps via (1024 samples * 1,000 / 44,100 * 10,000 ticks) it's never going to line up exactly with the 30fps video.
Am I doing something wrong here with decoding the ffmpeg audio frames, or misunderstanding audio samples?
And in my particular application, these timestamps are critical as I am trying to line up LTC timestamps which are decoded at the audio frame level, and lining those up with video frames.
FFProbe.exe:
Video:
r_frame_rate=30/1
avg_frame_rate=30/1
codec_time_base=1/60
time_base=1/90000
start_pts=7560698279
start_time=84007.758656
Audio:
r_frame_rate=0/0
avg_frame_rate=0/0
codec_time_base=1/44100
time_base=1/90000
start_pts=7560686278
start_time=84007.625311
I have two microphones Blue microphone - snow ball ice and Stage line microphone (EMG-500P, DMS-1 microphone base, MPR-1 pre-amp, soundcard as shown in the image below).
I am using a python sound device library example from git and i working fine. Audio recording from Blue microphone is working fine for many different sampling rate like 16000, 44100, 48000 etc (-r = 16000/44100/48000) but Stage line microphone is recording audio only when sampling rate are 44100 or 48000 Hz. Any sampling rate other than 44100/48000 Hz its throwing an error.
PortAudioError: Error opening InputStream: Invalid sample rate
[PaErrorCode -9997]
How can i record at 16KHz from Stage line microphone ?
Why am I not able to sample at 16kHz ? Is it because of sound card ?
I am using sound device python example exact code to record both from Blue microphone and Stage line microphone.
Thanks.
I've made a movie for RPG Maker XV ace with just music in the background.
The program only allows .ogv movies (OGG, THEORA) to be played. I have no problem with the video quality, however, the sound is distorted and "jumps"
(like when we were playing records in the '90s..) when there are high pitched or reverberating instruments.
The following are my settings for the movie output:
Container: OGG
Video Codec: Theora
Audio Codec: Vorbis
Bit rate: 160 (16 bit)
Sample rate: 44100 (44.1 kHz)
System: Windows 10
Video Editor: Blender 2.79
The .ogg audio files are perfect when played in RPG Maker Ace by themselves just as audio files. The problem only exists with the audio in .ogv movies.
I have already tried increasing the bit rate and the frame rate but to no avail.
Does anyone know the standard audio requirements for audio in movies for RPG Maker Ace?
Thanks for your help!
I actually disobeyed what RPG Maker suggests in their help menu and made some changes as follow:
CONTAINER: OGG
VIDEO CODEC: H.264
OUTPUT QUALITY: CONSTANT BIT RATE (This is very important)
ENCODING SPEED: Medium
AUDIO CODEC: VORBIS
BIT RATE: 200
FRAME RATE: 48000
Now it works like a charm!
When I was studying Cocoa Audio Queue document, I met several terms in audio codec. There are defined in a structure named AudioStreamBasicDescription.
Here are the terms:
1. Sample rate
2. Packet
3. Frame
4. Channel
I known about sample rate and channel. How I was confused by the other two. What do the other two terms mean?
Also you can answer this question by example. For example, I have an dual-channel PCM-16 source with a sample rate 44.1kHz, which means there are 2*44100 = 88200 Bytes PCM data per second. But how about packet and frame?
Thank you at advance!
You are already familiar with the sample rate defintion.
The sampling frequency or sampling rate, fs, is defined as the number of samples obtained in one second (samples per second), thus fs = 1/T.
So for a sampling rate of 44100 Hz, you have 44100 samples per second (per audio channel).
The number of frames per second in video is a similar concept to the number of samples per second in audio. Frames for our eyes, samples for our ears. Additional infos here.
If you have 16 bits depth stereo PCM it means you have 16*44100*2 = 1411200 bits per second => ~ 172 kB per second => around 10 MB per minute.
To the definition in reworded terms from Apple:
Sample: a single number representing the value of one audio channel at one point in time.
Frame: a group of one or more samples, with one sample for each channel, representing the audio on all channels at a single point on time.
Packet: a group of one or more frames, representing the audio format's smallest encoding unit, and the audio for all channels across a short amount of time.
As you can see there is a subtle difference between audio and video frame notions. In one second you have for stereo audio at 44.1 kHz: 88200 samples and thus 44100 frames.
Compressed format like MP3 and AAC pack multiple frames in packets (these packets can then be written in MP4 file for example where they could be efficiently interleaved with video content). You understand that dealing with large packets helps to identify bits patterns for better coding efficiency.
MP3, for example, uses packets of 1152 frames, which are the basic atomic unit of an MP3 stream. PCM audio is just a series of samples, so it can be divided down to the individual frame, and it really has no packet size at all.
For AAC you can have 1024 (or 960) frames per packet. This is described in the Apple document you pointed at:
The number of frames in a packet of audio data. For uncompressed audio, the value is 1. For variable bit-rate formats, the value is a larger fixed number, such as 1024 for AAC. For formats with a variable number of frames per packet, such as Ogg Vorbis, set this field to 0.
In MPEG-based file format a packet is referred to as a data frame (not to be
mingled with the previous audio frame notion). See Brad comment for more information on the subject.