Skip to content

Commit

Permalink
Add Hall type audio upmixing.
Browse files Browse the repository at this point in the history
For stereo content: left is sent to left channels, right to right channels and a slight bias to center channel. Power levels are kept the same from original content.

Re-enable passive audio upmixing, old code was incorrect

Fixes #10751
  • Loading branch information
jyavenard committed Jun 2, 2012
1 parent 4963b9d commit 01048d8
Show file tree
Hide file tree
Showing 3 changed files with 30 additions and 4 deletions.
29 changes: 26 additions & 3 deletions mythtv/libs/libmythfreesurround/freesurround.cpp
Expand Up @@ -42,6 +42,8 @@ static const unsigned default_block_size = SURROUND_BUFSIZE;
// Gain of center and lfe channels in passive mode (sqrt 0.5) // Gain of center and lfe channels in passive mode (sqrt 0.5)
static const float center_level = 0.707107; static const float center_level = 0.707107;
static const float m3db = 0.7071067811865476f; // 3dB = SQRT(2) static const float m3db = 0.7071067811865476f; // 3dB = SQRT(2)
static const float m6db = 0.5; // 6dB = SQRT(4)
static const float m7db = 0.44721359549996; // 7dB = SQRT(5)


unsigned int block_size = default_block_size; unsigned int block_size = default_block_size;


Expand Down Expand Up @@ -245,8 +247,14 @@ uint FreeSurround::putFrames(void* buffer, uint numFrames, uint numChannels)
switch (surround_mode) switch (surround_mode)
{ {
case SurroundModePassive: case SurroundModePassive:
case SurroundModePassiveHall:
for (i = 0; i < numFrames && ic < bs; i++,ic++) for (i = 0; i < numFrames && ic < bs; i++,ic++)
bufs->l[ic] = bufs->c[ic] = bufs->r[ic] = samples[i]; {
// should be -7dB to keep power level the same
// but we bump the level a tad.
bufs->c[ic] = bufs->l[ic] = bufs->r[ic] = samples[i] * m6db;
bufs->ls[ic] = bufs->rs[ic] = bufs->c[ic];
}
process = false; process = false;
break; break;
default: default:
Expand All @@ -267,9 +275,24 @@ uint FreeSurround::putFrames(void* buffer, uint numFrames, uint numChannels)
float lt = *samples++; float lt = *samples++;
float rt = *samples++; float rt = *samples++;
bufs->l[ic] = lt; bufs->l[ic] = lt;
bufs->lfe[ic] = bufs->c[ic] = (lt+rt) * center_level; bufs->lfe[ic] = bufs->c[ic] = (lt+rt) * m3db;
bufs->r[ic] = rt; bufs->r[ic] = rt;
bufs->ls[ic] = bufs->rs[ic] = (lt-rt) * center_level; // surround channels receive out-of-phase
bufs->ls[ic] = (rt-lt) * 0.5;
bufs->rs[ic] = (lt-rt) * 0.5;
}
process = false;
break;
case SurroundModePassiveHall:
for (i = 0; i < numFrames && ic < bs; i++,ic++)
{
float lt = *samples++;
float rt = *samples++;
bufs->l[ic] = lt * m3db;
bufs->lfe[ic] = bufs->c[ic] = (lt+rt) * m3db;
bufs->r[ic] = rt * m3db;
bufs->ls[ic] = bufs->l[ic];
bufs->rs[ic] = bufs->r[ic];
} }
process = false; process = false;
break; break;
Expand Down
3 changes: 2 additions & 1 deletion mythtv/libs/libmythfreesurround/freesurround.h
Expand Up @@ -30,7 +30,8 @@ class FreeSurround
{ {
SurroundModePassive, SurroundModePassive,
SurroundModeActiveSimple, SurroundModeActiveSimple,
SurroundModeActiveLinear SurroundModeActiveLinear,
SurroundModePassiveHall
} SurroundMode; } SurroundMode;
public: public:
FreeSurround(uint srate, bool moviemode, SurroundMode mode); FreeSurround(uint srate, bool moviemode, SurroundMode mode);
Expand Down
2 changes: 2 additions & 0 deletions mythtv/programs/mythfrontend/audiogeneralsettings.cpp
Expand Up @@ -453,6 +453,8 @@ HostComboBox *AudioConfigSettings::AudioUpmixType()
{ {
HostComboBox *gc = new HostComboBox("AudioUpmixType",false); HostComboBox *gc = new HostComboBox("AudioUpmixType",false);
gc->setLabel(QObject::tr("Upmix Quality")); gc->setLabel(QObject::tr("Upmix Quality"));
gc->addSelection(QObject::tr("Passive"), "0");
gc->addSelection(QObject::tr("Hall"), "3");
gc->addSelection(QObject::tr("Good"), "1"); gc->addSelection(QObject::tr("Good"), "1");
gc->addSelection(QObject::tr("Best"), "2", true); // default gc->addSelection(QObject::tr("Best"), "2", true); // default
gc->setHelpText(QObject::tr("Set the audio surround-upconversion quality.")); gc->setHelpText(QObject::tr("Set the audio surround-upconversion quality."));
Expand Down

0 comments on commit 01048d8

Please sign in to comment.