News for hackers. Stuff that matters.
Re:Lyra V2 – a better, faster, and more versatile speech codec by dale_glass on Friday September 30, 2022 @07:41PM (#33042148)
Is there an open codec that concentrates on low CPU usage? I'm fine with it not being very bandwidth efficient.

Opus is a very good codec, but it's not amazing CPU-wise. I work on a VR world, and audio encoding is usually our most limiting factor when running on an VPS. We have the capability to negotiate codecs, so the high cpu/low bandwidth use case is already covered.

What I'm looking for specifically:

* Low CPU usage

* Support for high bitrate, suitable for music and sounds other than voice

* Low latency

Re:Lyra V2 – a better, faster, and more versatile speech codec by douglasheriot on Friday September 30, 2022 @08:47PM (#33042621)
It sounds like you’re asking for uncompressed audio? That meets all of your listed requirements. 48kHz * 16bit, single channel = 768kbit/s
Re:Lyra V2 – a better, faster, and more versatile speech codec by dale_glass on Saturday October 01, 2022 @06:37AM (#33045533)
We support that already, yup. But it never hurts to see if there's something better than that out there.
Re:Lyra V2 – a better, faster, and more versatile speech codec by orlp on Tuesday October 04, 2022 @12:12PM (#33082483)
You can bootleg your own fast lossless codec by doing delta-encoding on the raw PCM to get a lot of zeros and then feed it through an off-the-shelf fast compressor like snappy/lz4/zstandard/etc. It won't get remotely close to the dedicated audio algorithms, but I wouldn't be surprised if you cut your data size by a factor 2-4 and essentially no CPU cost compared to raw uncompressed audio.
Re:Lyra V2 – a better, faster, and more versatile speech codec by muziq on Wednesday October 05, 2022 @05:07PM (#33101255)
You’ve not done this before have you ?
Re:Lyra V2 – a better, faster, and more versatile speech codec by orlp on Thursday October 13, 2022 @10:15AM (#33191258)
I haven't, but now I have. I took https://opus-codec.org/static/examples/samples/music_orig.wa... from https://opus-codec.org/examples/. Then I wrote the following snippet of Python code:

    from scipy.io import wavfile
    import numpy as np
    import zstd

    sampling_rate, samples = wavfile.read(r'data/bootleg-compress/music_orig.wav')
    orig = samples.tobytes()

    naive_compressed = zstd.ZSTD_compress(orig)
    deltas = np.diff(samples, prepend=samples.dtype.type(0), axis=0) # Per-channel deltas.
    compressed_deltas = zstd.ZSTD_compress(deltas.ravel()) # Interleave channels and compress.

    decompressed_deltas = np.frombuffer(zstd.ZSTD_uncompress(compressed_deltas), dtype=samples.dtype)
    decompressed = np.cumsum(decompressed_deltas.reshape(deltas.shape), axis=0, dtype=samples.dtype)
    assert np.array_equal(samples, decompressed)

    print(len(orig))
    print(len(naive_compressed))
    print(len(compressed_deltas))
giving:

    17432876
    15518973
    12817602
Looks like my initial estimation of 2-4 was way off (when FLAC achieves ~2 this should've been a red flag), but you do get a ~1.36x reduction in space at basically memory read speed.
Re:Lyra V2 – a better, faster, and more versatile speech codec by zinekeller on Saturday October 01, 2022 @07:05AM (#33045653)
While I also want a low-computation codec that can save space, the historical use cases unfortunately assumes a lot more CPU power to be compensated for a lot less bandwidth, so there's little research in this area, and there's no real incentive to make something like ProRes and DNxHD as if you are editing audio the SSD speeds has been so fast that you'll run into CPU problems first.
Re:Lyra V2 – a better, faster, and more versatile speech codec by userbinator on Friday September 30, 2022 @10:28PM (#33043208)
Either that or G.711.
Re:Lyra V2 – a better, faster, and more versatile speech codec by viraptor on Saturday October 01, 2022 @10:35AM (#33046862)
G711 is neither high bitrate nor usable for music.
Re:Lyra V2 – a better, faster, and more versatile speech codec by simfree on Saturday October 01, 2022 @04:08PM (#33049596)
Then use G.722, it works fine for music.
Re:Lyra V2 – a better, faster, and more versatile speech codec by viraptor on Saturday October 01, 2022 @06:10PM (#33050601)
No, g722 is still a wideband speech codec. Its available frequency goes up to 7 kHz. The uncompressed audio this thread began with goes up to 22 kHz. With g722 you're losing most overtones, or even all overtones from the top of a piano. Please don't use g722 for music apart from on-hold muzak.
Re:Lyra V2 – a better, faster, and more versatile speech codec by rasz on Friday September 30, 2022 @11:49PM (#33043711)
How is Audio encoding the most limiting factor in a VR project? :o Afaik Opus encoder eats something like 30-50MHz of one cpu core.
Re:Lyra V2 – a better, faster, and more versatile speech codec by CodesInChaos on Saturday October 01, 2022 @01:52AM (#33044257)
It sounds plausible that it's the most expensive thing on the server side, if you have cheap simulation/behaviour and many concurrent users.

But unless it's a non commercial project, the cost shouldn't be a big deal, so it's still a bit strange.

Re:Lyra V2 – a better, faster, and more versatile speech codec by dale_glass on Saturday October 01, 2022 @05:59AM (#33045376)
We work on a community-led fork of the dead commercial High Fidelity project. The server requirements are indeed very light except for audio.

Physics are actually farmed out to the clients themselves, it's a bit of a quirky idea, but it actually works if one isn't concerned with accuracy.

Re:Lyra V2 – a better, faster, and more versatile speech codec by muziq on Saturday October 01, 2022 @12:04PM (#33047587)
I did a prototype of a 3D low-latency server side mixing system, based on a hypothetical 4k clients, @48k each being mixed with the 64 loudest clients.. Using Opus, forced to Celt mode only and running 256 stereo sample frames at 128kbps.. Worked well, using only 6 cores for that workload.. The mixing was trivial, but the decode and encode of 4k streams was entirely doable.. This issue at that rate was 1.5M network packets a second.. If I was to revisit it, I’d look at using a simple MDCT based codec, with a simple Psychacoustic model based on MPC (minus CVD) and modified for shorter frames + Mdct behaviour versus PQMF behaviour, without any Huffman coding or entropy coding.. And put that codec on the GPU.. Small tests I did using a 1080ti indicated ~1M clients could be decoded, mixed and encoded (same specs as above) problem is then how to handle ~370M network packets a second :)

Edit: Had high hopes for High Fidelity, and came very close to asking for a job there ;) Shame it’s kaput, didn’t know that :(

Re:Lyra V2 – a better, faster, and more versatile speech codec by dale_glass on Saturday October 01, 2022 @01:07PM (#33048113)
Those are interesting ideas, thanks! I'll have to try and play with that.

High Fidelity the company is still around, but they pivoted multiple times radically. Initially their plan was social VR of sorts. Then they tried to make a corporate product for meetings and such, and gave up on that right before COVID19 hit!

And after that they ripped out all the 3D and VR and scaled down to a 2D, overhead spatial audio web thing. Think something like Zoom, only you have an icon that you can move around to get closer or further to other people.

The original code still lives on, we picked it up and are working on improvements. Feel free to visit out Discord (see my profile).

Re:Lyra V2 – a better, faster, and more versatile speech codec by jimmySixDOF on Saturday October 01, 2022 @07:26AM (#33045753)
Apparently RP1 team handle bigger crowd loads through muxing on the server but not sure exactly how that works out for spatial audio there is a Kent Bye Voices of VR podcast discussing how they got 4k users in the same shard.
Re:Lyra V2 – a better, faster, and more versatile speech codec by rasz on Saturday October 01, 2022 @07:06AM (#33045655)
Ventrilo/teampspeak servers run great on shared hosting. https://www.myteamspeak.com/addons/9ddfa0b2-25c2-4302-8a43-0... gives you positional audio support on teamspeak server
Re:Lyra V2 – a better, faster, and more versatile speech codec by cma on Saturday October 01, 2022 @12:20AM (#33043840)
Why is your VPS server encoding rather than clients? Are you combining talkers together into one source for doing crowds and avoiding N^2 or something and need to reencode after combining?
Re:Lyra V2 – a better, faster, and more versatile speech codec by dale_glass on Saturday October 01, 2022 @05:57AM (#33045365)
Correct, server does spatial audio.

It's a community-led continuation of High Fidelity, a dead commercial project. They made their own proprietary codec with excellent performance we can't use and managed to have a couple thousand people in the same server.

Re:Lyra V2 – a better, faster, and more versatile speech codec by fanick on Saturday October 01, 2022 @01:51AM (#33044251)
I would like to know the answer to this question from dale_glass too.
Re:Lyra V2 – a better, faster, and more versatile speech codec by dale_glass on Saturday October 01, 2022 @05:57AM (#33045366)
Replied to the parent
Re:Lyra V2 – a better, faster, and more versatile speech codec by izacus on Friday September 30, 2022 @10:50PM (#33043360)
The Bluetooth codecs are all designed to be very cheap on CPU and low latency - e.g. LC3, AptX or SBC.
Re:Lyra V2 – a better, faster, and more versatile speech codec by themerone on Saturday October 01, 2022 @10:05AM (#33046657)
I'm skeptical, those are almost always going to be implemented in hardware, so the complexity of a software encoder isn't a design concern.

There is some correlation between the cost of a hardware implementation and complexity of a software implementation. SBC is a very simple codec, but AptX and LC3 might not be much better than Opus.

Re:Lyra V2 – a better, faster, and more versatile speech codec by CharlesW on Friday September 30, 2022 @08:03PM (#33042298)
I couldn't find data on CPU requirements for encode/decode versus, say, Opus, but Apple uses AAC-LD for similar scenarios.
Re:Lyra V2 – a better, faster, and more versatile speech codec by jchw on Friday September 30, 2022 @11:43PM (#33043679)
If you are OK with moderately high bitrates, you might prefer something simpler like an ADPCM scheme. It's pretty damn easy to implement ADPCM, certainly a lot less math heavy than MDCT-based schemes, and they achieve good quality at a somewhat higher bitrate (I have no data, but I'd guess 200-250%~ish.)
Re:Lyra V2 – a better, faster, and more versatile speech codec by bjt2n3904 on Friday September 30, 2022 @08:01PM (#33042284)
I believe codec2 is pretty easy computationally. The M17 project uses it IIRC, and implements it on an STM32.
Re:Lyra V2 – a better, faster, and more versatile speech codec by CharlesW on Friday September 30, 2022 @08:04PM (#33042303)
That'd be a good choice except for the requirement to support non-speech audio.
Re:Lyra V2 – a better, faster, and more versatile speech codec by ksec on Friday September 30, 2022 @09:35PM (#33042933)
LC3Plus or AAC-LD. Although they likely don’t fit the definition of Open Codec.
Re:Lyra V2 – a better, faster, and more versatile speech codec by aidenn0 on Friday September 30, 2022 @09:15PM (#33042808)
Vorbis might be a good choice there