Commit graph

62 commits

Author SHA1 Message Date
Wim Taymans
66e4334c92 channelmix: reuse more functions
Make some copy/vol functions and reuse them.
Reuse the 2->3p1 upmix code, tweak it a little to that the widen
param is always used.
2022-04-12 11:54:27 +02:00
Wim Taymans
e12e4295cf channelmix: only filter FC and LFE when upmixed
When we have an original source with LFE and FC, don't try to mix
it but pass it unmodified.

Fixes #2280
2022-04-12 11:51:01 +02:00
Wim Taymans
54f6f9293e channelmix: upmix disabled also disables FC and LFE generation
Don't generate FC and LFE when upmix is disabled.

Fixes #2266
2022-04-04 09:08:54 +02:00
Wim Taymans
bc5b486cb9 channelmix: add simple upmix method
Add a property to select the upmix method. PSD is enabled by default
but a new simple upmixing algorithm is available that duplicates
channels and avoids lowpass filter on the FC and disables widening.

Fixes #861
2022-03-14 15:33:07 +01:00
Wim Taymans
23db50630d channelmix: add option to filter FC
Add an option to do a lowpass filter on the FC channel to isolate
the voices better and move the higher frequencies to the stereo
channels.

See #861
2022-03-01 11:30:12 +01:00
Wim Taymans
5b3388e4ac audioconvert: add optional hilbert transform to rear channels
Add an option to do a hilbert transform on the generated rear channels
to do a 90 degree pahse shift on them. This can improve spacialization
of the rear channels.

See #861
2022-03-01 11:09:43 +01:00
Wim Taymans
5a307c11e1 audioconvert: add delay to rear channels when upmixing
See #861
2022-03-01 09:56:12 +01:00
Wim Taymans
d62d2764e8 channelmix: improve corssover processing
Apply volume after crossover, optimize when disabled or silent.
2022-03-01 09:08:17 +01:00
Wim Taymans
7241bf3c54 channelmix: remove LFE when cutoff is <= 0.0 2022-02-25 11:13:04 +01:00
Wim Taymans
2e8e8938bc channelmix: add stereo to 7.1 upmix 2022-02-24 16:09:14 +01:00
Wim Taymans
b1ca470d99 channelmix: don't pass channels around
We have this info in the channelmix structure.
2022-02-24 13:09:25 +01:00
Wim Taymans
b7279a1728 channelmix: dont make FC from synthesized FC
When we have stereo and need to make FC, don't try to upmix the
stereo into FC again.
Fix unit test now that we create FC channels.
2022-01-11 17:25:38 +01:00
Wim Taymans
59042251ee channelmix: also keep FC channel
When the target has FC, make it from FL and FR in all cases.
2022-01-11 14:47:17 +01:00
Wim Taymans
c9efae4334 channelmix: do LFE upmix when lfe_cutoff is set
Require only the lfe_cutoff be set when generating LFE.
This way you can only generate LFE without having to enable upmix
for all other channels.
2022-01-11 12:44:36 +01:00
Wim Taymans
22a210e798 channelmix: 1 channel MONO or FC should be handled the same.
They were handled the same, remove the wrong line to attempt to
make them different.
2021-12-09 17:19:22 +01:00
Wim Taymans
6b34b8c44e audioconvert: fix mono channel mix test
When we have a single MONO channel, distribute and average. Otherwise,
use the logic to do proper mixing.

Adjust the unit test accordingly.
2021-12-09 16:51:40 +01:00
Wim Taymans
ce02c7d435 channelmix: always handle 1 channel as mono
Handle 1 channel as a mono channel, which gets copied to all outputs
or gets the average of all inputs.

Fixes the case where a mono channel is handled like a FRONT channel
and then gets attenuated when mixed into left and right.
2021-12-09 16:03:32 +01:00
Wim Taymans
70722c0741 channelmix: provide some more upmix options
If nothing else is possible, also try to upmix from FC

See #1237
2021-05-27 18:08:07 +02:00
Wim Taymans
15239ff74d channelmix: only run the LFE filter when upmixing
Only run the lowpass filter on the LFE channel when we are upmixing
and there is a valid cutoff frequency defined.

Otherwise we might filter away a valid LFE channel.

Fixes: rhbz#1941366
2021-05-03 11:50:47 +02:00
Andrea Gelmini
47ef2b6b09 Fix typos 2021-04-30 07:40:20 +00:00
Wim Taymans
5724093343 audioconvert: run lr4 on tagged channels in generic case
Mark the LFE channels and run the lowpass filter on them in
the generic case. Generates LFE correctly in 2.1 upmix case.

See #1095
2021-04-26 17:34:14 +02:00
Wim Taymans
71824d0b03 audioconvert: debug selected function name in channelmix 2021-04-26 17:33:45 +02:00
Wim Taymans
fa3bd6b0e1 channelmix: support more than 19 channels
The channelmatrix was limited to the 19 known channels, leaving
only the first 19 channels usable.

Use the full 64x64 matrix instead and make sure to fill all 64
channels with the identity matrix in the case we need to copy or
distribute the matrix to unknown positions.

See #57
2021-04-16 10:56:24 +02:00
Wim Taymans
14e8073d18 audioconvert: add LFE filter
Use a lowpass filter to generate LFE from the stereo channels.
2021-03-17 11:28:40 +01:00
Wim Taymans
e51cc5b537 channelmix: Prepare for generating LFE channel
Add channelmix.lfe-cutoff property, 0 is disabled
Disable upmix by default
2021-03-17 11:09:19 +01:00
Wim Taymans
6324298bc5 channelmix: add more generic upmixing
Add options to enable lfe filtering and upmix.
Enable upmix by default, lfe is disabled because we don't actually
do a lowpass filter yet.
2021-03-06 21:31:18 +01:00
Wim Taymans
c7309f0248 channelmix: small cleanups
Fix indent
Rename DUAL/QUAD to REAR and SIDE and use it for checking availability
of stereo pairs.
2021-03-06 21:29:36 +01:00
fdev31
4d21b5f8bd Simple upmix of stereo inputs up to 7.1 output 2021-03-06 20:22:09 +00:00
Wim Taymans
6b0abd2057 channelmix: Improve unknown channel layout handling
Clamp position to valid range. so that AUX becomes UNKNOWN.
If we have one mono source channel and unknown destination, copy it
to all destination channels.
If we have one mono destination channel and unknown source layout,
average all channels.
Otherwise, pair source and dest channels.

See #538
2021-01-15 17:51:07 +01:00
Wim Taymans
f70d0b19af channelmix: add option to NORMALIZE volumes
Normalize the complete matrix with the same coefficient
2020-09-29 12:02:34 +02:00
Wim Taymans
700a0aa35c Fix FLC+FRC to FL+FR 2020-09-29 12:02:30 +02:00
Wim Taymans
df3394a694 add some more debug 2020-09-29 12:02:25 +02:00
Wim Taymans
9a7cbeea83 channelmix: improve undefined channel layout
When we have no channel layout, just copy input to output
channel.
Optimize this case in the mixer implementation.
2020-09-04 13:41:24 +02:00
Wim Taymans
f7d8fef070 channelmix: normalize volumes
Normalize the volumes.
Don't mix in LFE by default but add an option
Move some booleans to flags
Improve some checks for fastpaths.
2020-09-03 13:20:36 +02:00
Wim Taymans
b62fa9faf2 channelmix: disable normalize for now
Volume is too low and we don't choose the right functions all the
time. Needs more work.
2020-09-02 18:50:01 +02:00
Wim Taymans
5dea431372 channelmix: normalize matrix to avoid clipping 2020-09-02 18:36:42 +02:00
Wim Taymans
0d35f44fd9 tests: add channelmix test 2019-08-29 14:05:02 +02:00
Wim Taymans
954c96632c channelmix: try to handle 1 channel as MONO/FC 2019-08-16 15:03:16 +02:00
Wim Taymans
87ae7a8011 channelmix: apply channel volumes correctly 2019-08-14 14:56:16 +02:00
Wim Taymans
c6a7b3eedb channelmix: implement per channel volume
Implement per channel volume on channelmix. Extend control on stream to
take an array of values when possible.

Remove name argument from pw_node_new and pw_device_new. We can pass
this as a property instead.

Improve properties on nodes to more closely match what pulseaudio does.
Don't let the monitor do too much with the udev properties but let the
session manager set the description and icon-names.

Remove some change_mask flags for things that don't change in
introspect. Use the flags to mark changes in -cli and -monitor.
2019-08-12 15:14:39 +02:00
Wim Taymans
d46c239ab0 some printf fixes 2019-06-07 16:37:08 +02:00
Wim Taymans
d8e399dee9 audioconvert: pass state to functions
Pass some state to convert and channelmix functions. This makes it
possible to select per channel optimized convert functions but
also makes it possible to implement noise shaping later.
Pass the channelmix matrix and volume in the state.
Handle specialized 2 channel s16 -> f32 conversion
2019-03-29 17:39:59 +01:00
Wim Taymans
d260cb19be audioconvert: compile c version separately
Also compile the c versions in a separate module with their own
flags.
2019-03-28 21:07:53 +01:00
Wim Taymans
0505f2dc98 audioconvert: implement passthrough
Add some const and SPA_RESTRICT to methods
When the input and output is the same, work in passthrough mode
where we simply copy place the input pointer onto the output buffer
without doing a memcpy.
Do memcpy when the resampler is not active.
2019-03-20 19:29:14 +01:00
Wim Taymans
74cf412f47 utils: add debugable spa_memcpy 2019-03-20 19:27:46 +01:00
Wim Taymans
ac5ec9bbe2 device: improve callbacks
Pass info structures to device callbacks to make it more extensible.
Also notify about the supported params on the device because we
can.
2019-02-13 11:13:46 +01:00
Wim Taymans
13bf70a8dd mem: align memory to requested alignment
Improve the allocators to always align the buffer memory to the
requested alignment
Use aligned read and writes for sse functions and check alignment,
optionally falling back to unaligned path.
Add more tests and benchmark cases
Check and warn for misaligned memory in plugins.
2019-01-24 18:28:52 +01:00
Wim Taymans
e918f9f77c fix sign confusion 2019-01-07 15:52:42 +01:00
Wim Taymans
b6db6e2130 channelmix: add quad and 3.1 to mono optimisation 2018-12-19 16:49:29 +01:00
Wim Taymans
4dfe1011a6 audioconvert: use cpu detection interface 2018-12-17 13:26:54 +01:00