News for hackers. Stuff that matters.
Re:Improved audio rendering with an optimised version of mem... by azernik on Saturday April 22, 2017 @10:41AM (#14172742)
To people making fun - this is not about creating audio files, but rather about techniques to reduce latency and jitter when playing audio files. Similar to the crazy techniques that the VR folks like Carmack have proposed. Yes, indeed, audio files these days have WAY more information content them the human ear can distinguish, but if your playback has skips and assorted corruption that doesn't matter.

For example, one of the responses proposed pre-loading a large fully-rendered audio segment onto a DMA buffer to remove the CPU from the latency-sensitive pipeline entirely.

Re:Improved audio rendering with an optimised version of mem... by mikeash on Saturday April 22, 2017 @10:47AM (#14172774)
Reducing jitter for file playback is easy. Just use a huge buffer. Done. Latency doesn't matter because the whole file is available ahead of time.

Even if this did matter, it's still bullshit. Memcpy isn't going to add latency and jitter over some "optimized" copy routine. And C++ new certainly isn't going to be better than malloc, when it's almost certainly calling through to malloc.

Re:Improved audio rendering with an optimised version of mem... by kazinator on Saturday April 22, 2017 @10:57AM (#14172837)
If the song was recorded in 1991 and you're playing it now, that's 26 years of latency, no matter what.
Re:Improved audio rendering with an optimised version of mem... by usrusr on Saturday April 22, 2017 @02:31PM (#14173940)
One year longer and it would not be latency anymore, it would be hammertime.

(Sorry)

Re:Improved audio rendering with an optimised version of mem... by dom0 on Saturday April 22, 2017 @10:56AM (#14172832)
Audio codecs use memory-mapped ring buffers; as long as the driver's write pointer stays ahead of the codecs' read pointer there is no way to add jitter. Note that the codec doesn't care about the write pointer, if the driver forgets to update the buffer, the card will just play it over and over again. Sometimes that happens when a computer wakes up from stand-by. The result is quite characteristic.
Re:Improved audio rendering with an optimised version of mem... by _iiu1 on Saturday April 22, 2017 @06:38PM (#14175252)
you are describing a buffer over/under run. jitter is when a stream of serial audio data (such as most external usb/firewire/etc audio interfaces end up receiving) is not time-aligning it's frames/samples correctly with the clock of the codec (which should be the master clock) or other situations where the clocking of playback/recording differs from the derived "clock" of the streams boundaries.
Re:Improved audio rendering with an optimised version of mem... by asveikau on Saturday April 22, 2017 @12:01PM (#14173117)
The concepts you are mentioning (DMA and ring buffers) are heavily used but I don't think you have the layering right. In all APIs I have used, the codec library itself works with contiguous buffers typically on the heap, which end may up being copied into ring buffers or DMA buffers I will give you, but that is one abstraction above or below.
Re:Improved audio rendering with an optimised version of mem... by dom0 on Saturday April 22, 2017 @01:21PM (#14173550)
I meant the hardware with audio codec, though technically it would be the audio controller which has the buffers and control registers (which may/may not be the same chip, depending on the exact make, e.g. in HD Audio the controller is in the chipset, and the codec is a separate chip). Sorry for the confusion.
Re:Improved audio rendering with an optimised version of mem... by CyberDildonics on Saturday April 22, 2017 @11:03AM (#14172859)
Why isn't it the audio codec's write pointer and the driver's read pointer?
Re:Improved audio rendering with an optimised version of mem... by dom0 on Saturday April 22, 2017 @11:08AM (#14172882)
Because this is about audio output?
Re:Improved audio rendering with an optimised version of mem... by CyberDildonics on Thursday April 27, 2017 @08:47PM (#14216080)
I had that part figured out for myself, thanks for being patronizing while adding nothing.
Re:Improved audio rendering with an optimised version of mem... by beojan on Saturday April 22, 2017 @05:06PM (#14174800)
Right, so the codec decodes the audio and writes it into the buffer, and the sound card (or driver) reads out of that buffer and plays the sound. Where am I going wrong?
Re:Improved audio rendering with an optimised version of mem... by Dylan16807 on Saturday April 22, 2017 @05:34PM (#14174949)
"codec" here is the sound card.
Re:Improved audio rendering with an optimised version of mem... by mschaef on Saturday April 22, 2017 @10:55AM (#14172826)
Back in 1997-8, I ran across custom hardware that used this strategy to directly transfer large volumes of ADC data from the sampling hardware to a disk array. It made absolute sense given the the data volumes involved. (100-200MB/sec to persistent storage, which was a lot for commodity hardware back then.)

Audio is full orders of magnitude less data and this is on hardware that's 20 years newer. With any reasonable buffer size this is a slam dunk, unless perhaps you're really concerned about latency.(In which case automatically streaming multiple megabytes of audio data across DMA isn't going to help you either.)

Re:Improved audio rendering with an optimised version of mem... by coldtea on Saturday April 22, 2017 @12:18PM (#14173193)
>To people making fun - this is not about creating audio files, but rather about techniques to reduce latency and jitter when playing audio files.

They are more like techniques for creating April Fools jokes...

>For example, one of the responses proposed pre-loading a large fully-rendered audio segment onto a DMA buffer to remove the CPU from the latency-sensitive pipeline entirely.

You missed the fact that that response was taking the piss of the initial post...

Re:Improved audio rendering with an optimised version of mem... by aminorex on Saturday April 22, 2017 @06:43PM (#14175275)
"Taking the piss of" is not comprehensible in my (middle american) dialect. Please elaborate.
Re:Improved audio rendering with an optimised version of mem... by coldtea on Sunday April 23, 2017 @07:27AM (#14177695)
It may be also be used to refer to a ruse whereby a person is led to believe a plainly unbelievable fact for the purpose of ridicule of the subject, e.g. "Are you being serious?" "No, I'm just taking the piss."
Re:Improved audio rendering with an optimised version of mem... by Mz on Saturday April 22, 2017 @06:44PM (#14175286)