q-p / SoundPusher

Virtual audio device, real-time encoder and SPDIF forwarder for macOS
MIT License
148 stars 14 forks source link

Upmix Stereo Question #3

Closed GrandfatherTrout closed 4 years ago

GrandfatherTrout commented 6 years ago

When "Upmix Stereo" is enabled what happens when there is already a 5.1 sound source playing? I have noticed a difference in sound - will the additional surround channels be overridden by the upsampled stereo signal?

I am curious because so far your little program is so promising... My goal is to have different material in a playlist and I would like to have for example stereo material being upsampled, but 6 channel FLACs being passed through as 5.1.

q-p commented 6 years ago

The up-mix matrix is described in the commit message here https://github.com/q-p/SoundPusher/commit/42b2f23745614e4f212b355b4632bf95cc220bcc

As you can see the original 5.1 channels are passed through but the up-mix is performed and added additionally. SoundPusher doesn't look at the audio data at all, and preferably I'd keep it that way.

The main problem I see is that detecting >2 channels is easy (was there any signal on the non-L/R channels in the last N frames?), but the converse is not, because you could have a 5.1 signal that purposely has silence everywhere but the L/R channels.

GrandfatherTrout commented 6 years ago

I see, so the 5.1 is actually sounding, but an upmix from the stereo is also added to the back L+R channels... And so what you are saying, for SoundPusher there is no difference in a 5.1 stream with silence in the back L+R than a stereo stream? So it would have to find another way to see whether the file that is streaming through is 2ch or 6ch source. To me it would be really cool if I could randomly stream 6ch and 2ch files with only the stereo files being upmixed, but I understand if that is difficult to do.

q-p commented 6 years ago

And so what you are saying, for SoundPusher there is no difference in a 5.1 stream with silence in the back L+R than a stereo stream?

Yes, that's the essence. The audio device (in this case LoopbackAudio) is always 5.1 channels, but which channels the application "feeds" depends on the application, and I don't know of a good way to transport "intent".

As I said, technically, it's not hard to insert a silence detection heuristic and toggle upmixing based on that, but it will always be wrong occasionally.

What are you using to play your tracks? Maybe it's possible to add the upmix on the application side, where the knowledge of the source format is still there?

GrandfatherTrout commented 6 years ago

I use Swinsian. It is the most flexible music player I know and I tried everything else I could get my hands on - it works like iTunes used to work before Apple ruined it and can handle very large music libraries. It also has the ability to play lossless and multi-channel formats and switch between them on the fly (I am not affiliated - I am using it for several years now and it has stood the test of time) I wonder how often a silence detection would actually get it wrong in a real-world test, you would probably have to introduce a delay so SoundPusher can examine a certain portion ahead of time?

q-p commented 6 years ago

No, there wouldn't be any additional delay, you'd instead switch in one direction (when turning upmix back on) a fixed amount of time too late (for however long you decide you need to not hear anything on all surround channels for you to assume it really is only 2 channel content — but this really can't be too short because otherwise you'd get weird flips of upmix on/off just because some channels were silent for too long in a real 5.1 context).