Ticket #8568: vuvuzela-fixes.2.patch

File vuvuzela-fixes.2.patch, 24.0 KB (added by jyavenard, 2 years ago)

Updated version for 0.23-fixes

  • mythtv/libs/libmythtv/NuppelVideoPlayer.cpp

     
    51415141    return false; 
    51425142} 
    51435143 
     5144bool NuppelVideoPlayer::ToggleVuvuzela() 
     5145{ 
     5146    bool ret = false; 
     5147    if (audioOutput) 
     5148        ret = audioOutput->ToggleVuvuzela(); 
     5149    if (decoder) 
     5150        decoder->SetDisablePassThrough(ret); 
     5151    return ret; 
     5152} 
     5153 
    51445154void NuppelVideoPlayer::Zoom(ZoomDirection direction) 
    51455155{ 
    51465156    if (videoOutput) 
  • mythtv/libs/libmythtv/tv_play.h

     
    436436                                 const QStringList &actions); 
    437437 
    438438    void ToggleUpmix(PlayerContext*); 
     439    void ToggleVuvuzela(PlayerContext*); 
    439440    void ChangeAudioSync(PlayerContext*, int dir, bool allowEdit = true); 
    440441    bool AudioSyncHandleAction(PlayerContext*, const QStringList &actions); 
    441442 
  • mythtv/libs/libmythtv/NuppelVideoPlayer.h

     
    166166    void ToggleAdjustFill(AdjustFillMode adjustfillMode = kAdjustFill_Toggle); 
    167167    bool ToggleUpmix(void); 
    168168    bool CanPassthrough(void); 
     169    bool ToggleVuvuzela(void); 
    169170 
    170171    // Gets 
    171172    QSize   GetVideoBufferSize(void) const    { return video_dim; } 
  • mythtv/libs/libmythtv/tv_play.cpp

     
    45164516        ToggleTimeStretch(ctx); 
    45174517    else if (has_action("TOGGLEUPMIX", actions)) 
    45184518        ToggleUpmix(ctx); 
     4519    else if (has_action("TOGGLEVUVUZELA", actions)) 
     4520        ToggleVuvuzela(ctx); 
    45194521    else if (has_action("TOGGLESLEEP", actions)) 
    45204522        ToggleSleepTimer(ctx); 
    45214523    else if (has_action("TOGGLERECORD", actions) && islivetv) 
     
    82868288        ctx->nvp->GetOSD()->SetSettingsText(text, 5); 
    82878289} 
    82888290 
     8291void TV::ToggleVuvuzela(PlayerContext *ctx) 
     8292{ 
     8293    if (!ctx->nvp || !ctx->nvp->HasAudioOut()) 
     8294        return; 
     8295    QString text; 
     8296    if (ctx->nvp->ToggleVuvuzela()) 
     8297        text = tr("Vuvuzela Filter On"); 
     8298    else 
     8299        text = tr("Vuvuzela Filter Off"); 
     8300 
     8301    if (ctx->nvp->GetOSD() && !browsemode) 
     8302        ctx->nvp->GetOSD()->SetSettingsText(text, 5); 
     8303} 
     8304 
    82898305// dir in 10ms jumps 
    82908306void TV::ChangeAudioSync(PlayerContext *ctx, int dir, bool allowEdit) 
    82918307{ 
     
    99499965        ToggleTimeStretch(actx); 
    99509966    else if (action == "TOGGLEUPMIX") 
    99519967        ToggleUpmix(actx); 
     9968    else if (action == "TOGGLEVUVUZELA") 
     9969        ToggleVuvuzela(actx); 
    99529970    else if (action.left(13) == "ADJUSTSTRETCH") 
    99539971    { 
    99549972        bool floatRead; 
     
    1032310341        new OSDGenericTree(treeMenu, tr("Adjust Audio Sync"), "TOGGLEAUDIOSYNC"); 
    1032410342    else if (category == "TOGGLEUPMIX") 
    1032510343        new OSDGenericTree(treeMenu, tr("Toggle Audio Upmixer"), "TOGGLEUPMIX"); 
     10344    else if (category == "TOGGLEVUVUZELA") 
     10345        new OSDGenericTree(treeMenu, tr("Toggle Vuvuzela Filter"), "TOGGLEVUVUZELA"); 
    1032610346    else if (category == "TIMESTRETCH") 
    1032710347        FillMenuTimeStretch(ctx, treeMenu); 
    1032810348    else if (category == "VIDEOSCAN") 
  • mythtv/libs/libmythtv/tvosdmenuentry.cpp

     
    236236        "AUDIOSYNC",          1,  1,  1,  1, "Audio Sync")); 
    237237    curMenuEntries.append(new TVOSDMenuEntry( 
    238238        "TOGGLEUPMIX",        1,  1,  1,  1, "Toggle Upmixer")); 
     239    if (gContext->GetNumSetting("AdvancedAudioSettings", false) && 
     240        gContext->GetNumSetting("VuvuzelaFilter", false)) 
     241    { 
     242        curMenuEntries.append(new TVOSDMenuEntry( 
     243            "TOGGLEVUVUZELA", 1,  1,  1,  1, "Toggle Vuvuzela Filter")); 
     244    } 
    239245    curMenuEntries.append(new TVOSDMenuEntry( 
    240246        "TIMESTRETCH",        1,  1,  1,  1, "Time Stretch")); 
    241247    curMenuEntries.append(new TVOSDMenuEntry( 
  • mythtv/libs/libmyth/audiooutputbase.h

     
    1616 
    1717// MythTV headers 
    1818#include "audiooutput.h" 
     19#include "audiooutpututil.h" 
    1920#include "samplerate.h" 
    2021#include "mythverbose.h" 
    2122 
     
    4445    virtual void SetStretchFactor(float factor); 
    4546    virtual float GetStretchFactor(void) const; 
    4647    virtual bool ToggleUpmix(void); 
     48    virtual bool ToggleVuvuzela(void); 
    4749 
    4850    virtual void Reset(void); 
    4951 
     
    5759    virtual void SetTimecode(long long timecode); 
    5860    virtual bool IsPaused(void) const { return audio_actually_paused; } 
    5961    virtual void Pause(bool paused); 
    60     virtual bool CanPassthrough(void) const { return !need_resampler; } 
     62    virtual bool CanPassthrough(void) const { return !(need_resampler || vuvuzela); } 
    6163 
    6264    // Wait for all data to finish playing 
    6365    virtual void Drain(void); 
     
    231233    /** main audio buffer */ 
    232234    unsigned char audiobuffer[kAudioRingBufferSize]; 
    233235    uint memory_corruption_test4; 
     236 
     237    //Vuvuzela filter 
     238    bool vuvuzela, last_vuvuzela; 
     239    AudioOutputUtil::Notch *notch_instance; 
    234240}; 
    235241 
    236242#endif 
  • mythtv/libs/libmyth/audiooutpututil.h

     
     1#ifndef AUDIOOUTPUTUTIL 
     2#define AUDIOOUTPUTUTIL 
     3 
     4using namespace std; 
     5 
     6#define IIR_NUM_COEFFICIENTS    (3)     // Assumed biquads 
     7 
     8class AudioOutputUtil 
     9{ 
     10 public: 
     11     
     12    //Notch Filter / IRR transformation 
     13    // Parameters 
     14    typedef struct 
     15    { 
     16        uint N; 
     17        uint num_biquads; 
     18        float b[IIR_NUM_COEFFICIENTS]; 
     19        float a[IIR_NUM_COEFFICIENTS]; 
     20    } IIR_Parameters; 
     21     
     22    // State information 
     23    typedef struct 
     24    { 
     25        float a[IIR_NUM_COEFFICIENTS]; 
     26        float b[IIR_NUM_COEFFICIENTS]; 
     27        float x_mem[IIR_NUM_COEFFICIENTS]; 
     28        float y_mem[IIR_NUM_COEFFICIENTS]; 
     29    } IIR_State; 
     30 
     31    // Instance 
     32    typedef struct 
     33    { 
     34        IIR_Parameters parameters; 
     35        IIR_State state; 
     36    } IIR; 
     37 
     38    // Parameters 
     39    typedef struct 
     40    { 
     41        uint N; 
     42        float frequency;        // Notch frequency 
     43    } Notch_Parameters; 
     44 
     45    // State information 
     46 
     47    typedef struct 
     48    { 
     49        float pole_position; 
     50        float frequency_offset; 
     51        float a1s; 
     52        float a2; 
     53        float depth_factor; 
     54    } Notch_State; 
     55 
     56    // Instance 
     57    typedef struct 
     58    { 
     59        Notch_Parameters parameters; 
     60        Notch_State state; 
     61        IIR iir; 
     62    } Notch; 
     63 
     64    static void notch_update(Notch &instance, float fs); 
     65    static void notch_execute(Notch &instance, float *in, float *out); 
     66}; 
     67 
     68#endif 
     69#ifndef AUDIOOUTPUTUTIL 
     70#define AUDIOOUTPUTUTIL 
     71 
     72using namespace std; 
     73 
     74#define IIR_NUM_COEFFICIENTS    (3)     // Assumed biquads 
     75 
     76class AudioOutputUtil 
     77{ 
     78 public: 
     79     
     80    //Notch Filter / IRR transformation 
     81    // Parameters 
     82    typedef struct 
     83    { 
     84        uint N; 
     85        uint num_biquads; 
     86        float b[IIR_NUM_COEFFICIENTS]; 
     87        float a[IIR_NUM_COEFFICIENTS]; 
     88    } IIR_Parameters; 
     89     
     90    // State information 
     91    typedef struct 
     92    { 
     93        float a[IIR_NUM_COEFFICIENTS]; 
     94        float b[IIR_NUM_COEFFICIENTS]; 
     95        float x_mem[IIR_NUM_COEFFICIENTS]; 
     96        float y_mem[IIR_NUM_COEFFICIENTS]; 
     97    } IIR_State; 
     98 
     99    // Instance 
     100    typedef struct 
     101    { 
     102        IIR_Parameters parameters; 
     103        IIR_State state; 
     104    } IIR; 
     105 
     106    // Parameters 
     107    typedef struct 
     108    { 
     109        uint N; 
     110        float frequency;        // Notch frequency 
     111    } Notch_Parameters; 
     112 
     113    // State information 
     114 
     115    typedef struct 
     116    { 
     117        float pole_position; 
     118        float frequency_offset; 
     119        float a1s; 
     120        float a2; 
     121        float depth_factor; 
     122    } Notch_State; 
     123 
     124    // Instance 
     125    typedef struct 
     126    { 
     127        Notch_Parameters parameters; 
     128        Notch_State state; 
     129        IIR iir; 
     130    } Notch; 
     131 
     132    static void notch_update(Notch &instance, float fs); 
     133    static void notch_execute(Notch &instance, float *in, float *out); 
     134}; 
     135 
     136#endif 
     137#ifndef AUDIOOUTPUTUTIL 
     138#define AUDIOOUTPUTUTIL 
     139 
     140using namespace std; 
     141 
     142#define IIR_NUM_COEFFICIENTS    (3)     // Assumed biquads 
     143 
     144class AudioOutputUtil 
     145{ 
     146 public: 
     147     
     148    //Notch Filter / IRR transformation 
     149    // Parameters 
     150    typedef struct 
     151    { 
     152        uint N; 
     153        uint num_biquads; 
     154        float b[IIR_NUM_COEFFICIENTS]; 
     155        float a[IIR_NUM_COEFFICIENTS]; 
     156    } IIR_Parameters; 
     157     
     158    // State information 
     159    typedef struct 
     160    { 
     161        float a[IIR_NUM_COEFFICIENTS]; 
     162        float b[IIR_NUM_COEFFICIENTS]; 
     163        float x_mem[IIR_NUM_COEFFICIENTS]; 
     164        float y_mem[IIR_NUM_COEFFICIENTS]; 
     165    } IIR_State; 
     166 
     167    // Instance 
     168    typedef struct 
     169    { 
     170        IIR_Parameters parameters; 
     171        IIR_State state; 
     172    } IIR; 
     173 
     174    // Parameters 
     175    typedef struct 
     176    { 
     177        uint N; 
     178        float frequency;        // Notch frequency 
     179    } Notch_Parameters; 
     180 
     181    // State information 
     182 
     183    typedef struct 
     184    { 
     185        float pole_position; 
     186        float frequency_offset; 
     187        float a1s; 
     188        float a2; 
     189        float depth_factor; 
     190    } Notch_State; 
     191 
     192    // Instance 
     193    typedef struct 
     194    { 
     195        Notch_Parameters parameters; 
     196        Notch_State state; 
     197        IIR iir; 
     198    } Notch; 
     199 
     200    static void notch_update(Notch &instance, float fs); 
     201    static void notch_execute(Notch &instance, float *in, float *out); 
     202}; 
     203 
     204#endif 
     205#ifndef AUDIOOUTPUTUTIL 
     206#define AUDIOOUTPUTUTIL 
     207 
     208using namespace std; 
     209 
     210#define IIR_NUM_COEFFICIENTS    (3)     // Assumed biquads 
     211 
     212class AudioOutputUtil 
     213{ 
     214 public: 
     215  
     216    //Notch Filter / IRR transformation 
     217    // Parameters 
     218    typedef struct 
     219    { 
     220        uint N; 
     221        uint num_biquads; 
     222        float b[IIR_NUM_COEFFICIENTS]; 
     223        float a[IIR_NUM_COEFFICIENTS]; 
     224    } IIR_Parameters; 
     225     
     226    // State information 
     227    typedef struct 
     228    { 
     229        float a[IIR_NUM_COEFFICIENTS]; 
     230        float b[IIR_NUM_COEFFICIENTS]; 
     231        float x_mem[IIR_NUM_COEFFICIENTS]; 
     232        float y_mem[IIR_NUM_COEFFICIENTS]; 
     233    } IIR_State; 
     234 
     235    // Instance 
     236    typedef struct 
     237    { 
     238        IIR_Parameters parameters; 
     239        IIR_State state; 
     240    } IIR; 
     241 
     242    // Parameters 
     243    typedef struct 
     244    { 
     245        uint N; 
     246        float frequency;        // Notch frequency 
     247    } Notch_Parameters; 
     248 
     249    // State information 
     250 
     251    typedef struct 
     252    { 
     253        float pole_position; 
     254        float frequency_offset; 
     255        float a1s; 
     256        float a2; 
     257        float depth_factor; 
     258    } Notch_State; 
     259 
     260    // Instance 
     261    typedef struct 
     262    { 
     263        Notch_Parameters parameters; 
     264        Notch_State state; 
     265        IIR iir; 
     266    } Notch; 
     267 
     268    static void notch_update(Notch &instance, float fs); 
     269    static void notch_execute(Notch &instance, float *in, float *out); 
     270}; 
     271 
     272#endif 
  • mythtv/libs/libmyth/audiooutputbase.cpp

    Property changes on: mythtv/libs/libmyth/audiooutpututil.h
    ___________________________________________________________________
    Added: svn:executable
       + *
    
     
    1313#include "compat.h" 
    1414#include "audiooutputbase.h" 
    1515#include "audiooutputdigitalencoder.h" 
     16#include "audiooutpututil.h" 
    1617#include "SoundTouch.h" 
    1718#include "freesurround.h" 
    1819 
     
    7374    memory_corruption_test1(0xdeadbeef), 
    7475    memory_corruption_test2(0xdeadbeef), 
    7576    memory_corruption_test3(0xdeadbeef), 
    76     memory_corruption_test4(0xdeadbeef) 
     77    memory_corruption_test4(0xdeadbeef), 
     78    vuvuzela(false),            last_vuvuzela(false), 
     79    notch_instance(NULL) 
    7780{ 
    7881    // The following are not bzero() because MS Windows doesn't like it. 
    7982    memset(&src_data,          0, sizeof(SRC_DATA)); 
     
    197200    return (configured_audio_channels == 6); 
    198201} 
    199202 
     203bool AudioOutputBase::ToggleVuvuzela(void) 
     204{ 
     205    vuvuzela = !vuvuzela; 
     206    const AudioSettings settings(audio_bits, source_audio_channels, 
     207                                 audio_codec, source_audio_samplerate, 
     208                                 audio_passthru); 
     209    Reconfigure(settings); 
    200210 
     211    return vuvuzela; 
     212} 
     213 
    201214void AudioOutputBase::Reconfigure(const AudioSettings &orig_settings) 
    202215{ 
    203216    AudioSettings settings = orig_settings; 
     
    229242        settings.samplerate == audio_samplerate && !need_resampler && 
    230243        settings.use_passthru == audio_passthru && 
    231244        lneeds_upmix == needs_upmix && 
     245        last_vuvuzela == vuvuzela && 
    232246        laudio_reenc == audio_reenc); 
    233247    bool upmix_deps = 
    234248        (lsource_audio_channels == source_audio_channels); 
     
    247261        return; 
    248262    } 
    249263 
     264    last_vuvuzela          = vuvuzela; 
     265 
    250266    KillAudio(); 
    251267 
    252268    QMutexLocker lock1(&audio_buflock); 
     
    264280    audio_codec = settings.codec; 
    265281    audio_passthru = settings.use_passthru; 
    266282    needs_upmix = lneeds_upmix; 
     283    vuvuzela = last_vuvuzela; 
    267284 
    268285    if (audio_bits != 8 && audio_bits != 16) 
    269286    { 
     
    341358        need_resampler = true; 
    342359    } 
    343360 
     361    if (vuvuzela) 
     362    { 
     363        VERBOSE(VB_AUDIO, LOC + "Vuvuzela filter enabled. Go Socceroos Go!"); 
     364        if (!notch_instance) 
     365            notch_instance = new AudioOutputUtil::Notch; 
     366    } 
     367 
    344368    if (audio_enc) 
    345369    { 
    346370        VERBOSE(VB_AUDIO, LOC + "Creating AC-3 Encoder"); 
     
    497521    needs_upmix = false; 
    498522    audio_enc = false; 
    499523 
     524    if (notch_instance) 
     525    { 
     526        delete notch_instance; 
     527        notch_instance = NULL; 
     528    } 
     529    vuvuzela = false; 
     530 
    500531    CloseDevice(); 
    501532 
    502533    killAudioLock.unlock(); 
     
    844875    QMutexLocker lock1(&audio_buflock); 
    845876 
    846877    // resample input if necessary 
    847     if (need_resampler && src_ctx) 
     878    if ((need_resampler && src_ctx) || (vuvuzela && notch_instance)) 
    848879    { 
    849880        // Convert to floats 
    850881        short *buf_ptr = (short*)buffer; 
     
    854885            src_in[sample] = (float)buf_ptr[sample] / (1.0 * 0x8000); 
    855886        } 
    856887  
    857         src_data.input_frames = samples; 
    858         src_data.end_of_input = 0; 
    859         int error = src_process(src_ctx, &src_data); 
    860         if (error) 
    861             VERBOSE(VB_IMPORTANT, LOC_ERR + 
    862                     QString("Error occurred while resampling audio: %1") 
    863                     .arg(src_strerror(error))); 
    864         src_float_to_short_array(src_data.data_out, (short int*)tmp_buff, 
    865                             (src_data.output_frames_gen*abps)/sizeof(short)); 
     888        if (vuvuzela && notch_instance) 
     889        { 
     890            notch_instance->parameters.N = numSamples; 
    866891 
    867         _AddSamples(tmp_buff, true, src_data.output_frames_gen, timecode); 
     892            // Notch frequency 
     893            notch_instance->parameters.frequency = 235.0f; 
     894            AudioOutputUtil::notch_update (*notch_instance, (float)source_audio_samplerate); 
     895            AudioOutputUtil::notch_execute (*notch_instance, src_in, src_out); 
     896            notch_instance->parameters.frequency = 465.0f;  // 1st harmonic 
     897            AudioOutputUtil::notch_update (*notch_instance, (float)source_audio_samplerate); 
     898            AudioOutputUtil::notch_execute (*notch_instance, src_out, src_in); 
     899        } 
     900        if (need_resampler) 
     901        { 
     902            src_data.input_frames = samples; 
     903            src_data.end_of_input = 0; 
     904            int error = src_process(src_ctx, &src_data); 
     905            if (error) 
     906                VERBOSE(VB_IMPORTANT, LOC_ERR + 
     907                        QString("Error occurred while resampling audio: %1") 
     908                        .arg(src_strerror(error))); 
     909            src_float_to_short_array(src_data.data_out, (short int*)tmp_buff, 
     910                                (src_data.output_frames_gen*abps)/sizeof(short)); 
     911 
     912            _AddSamples(tmp_buff, true, src_data.output_frames_gen, timecode); 
     913        } 
     914        else 
     915        { 
     916            src_float_to_short_array(src_in, (short int*)tmp_buff, numSamples); 
     917            _AddSamples(tmp_buff, true, samples, timecode); 
     918        } 
    868919    } 
    869920    else 
    870921    { 
  • mythtv/libs/libmyth/libmyth.pro

     
    3030HEADERS += audiopulseutil.h 
    3131HEADERS += programinfo.h programlist.h programinfoupdater.h 
    3232HEADERS += recordingtypes.h remoteutil.h 
    33 HEADERS += rawsettingseditor.h 
     33HEADERS += rawsettingseditor.h audiooutpututil.h 
    3434 
    3535# remove when everything is switched to mythui 
    3636HEADERS += virtualkeyboard_qt.h 
     
    5454SOURCES += audiopulseutil.cpp 
    5555SOURCES += programinfo.cpp programlist.cpp programinfoupdater.cpp 
    5656SOURCES += recordingtypes.cpp remoteutil.cpp 
    57 SOURCES += rawsettingseditor.cpp 
     57SOURCES += rawsettingseditor.cpp audiooutpututil.cpp 
    5858 
    5959# remove when everything is switched to mythui 
    6060SOURCES += virtualkeyboard_qt.cpp 
  • mythtv/libs/libmyth/audiooutput.h

     
    7272    virtual void bufferOutputData(bool y) = 0; 
    7373    virtual int readOutputData(unsigned char *read_buffer, int max_length) = 0; 
    7474    virtual bool ToggleUpmix(void) = 0; 
     75    virtual bool ToggleVuvuzela(void) = 0; 
    7576 
    7677  protected: 
    7778    void Error(const QString &msg); 
  • mythtv/libs/libmyth/audiooutpututil.cpp

     
     1#include "dsputil.h" 
     2#include "mythconfig.h" 
     3#include "audiooutpututil.h" 
     4 
     5#define IIR_NUM_COEFFICIENTS    (3)     // Assumed biquads 
     6 
     7static void iir_update (AudioOutputUtil::IIR &instance) 
     8{ 
     9        // Clear the filter state 
     10    bzero(&instance.state.x_mem[0], IIR_NUM_COEFFICIENTS * sizeof(float)); 
     11    bzero(&instance.state.y_mem[0], IIR_NUM_COEFFICIENTS * sizeof(float)); 
     12     
     13    memcpy(&instance.state.b[0], &instance.parameters.b[0], 
     14           IIR_NUM_COEFFICIENTS * sizeof(float)); 
     15    memcpy(&instance.state.a[0], &instance.parameters.a[0], 
     16           IIR_NUM_COEFFICIENTS * sizeof(float)); 
     17} 
     18 
     19/* Notch filter (c) 2010 Hydrix & Jean-Yves Avenard */ 
     20/* www.hydrix.com */ 
     21 
     22// Processes a single block of samples with a single IIR biquad stage 
     23//    N                   M 
     24//   SUM a(k+1) y(n-k) = SUM b(k+1) x(n-k)      for 1<=n<=length(x) 
     25//   k=0                 k=0 
     26// where N=length(a)-1 and M=length(b)-1. 
     27// Vector s is the initial state of the system. The final state is also returned 
     28// The state vector is a column vector whose length is equal to the 
     29//      length of the longest coefficient vector minus one. 
     30static void iir_biquad (float* x, float* y, 
     31                        float* a, float* b, 
     32                        float* x_mem, float* y_mem, 
     33                        unsigned int N) 
     34{ 
     35   // Direct Form I 
     36   //               N+1               N+1 
     37   //           y(n) = - SUM a(k) y(n-k) + SUM b(k) x(n-k)  for 0 <= n <length(x) 
     38   //               k=1               k=0 
     39    unsigned int n = 0; 
     40    unsigned int k = 0; 
     41    float y_n_minus_k = 0.0f; 
     42    float x_n_minus_k = 0.0f; 
     43    for (n = 0; n < N; n++) 
     44    { 
     45        y[n] = x[n] * b[0]; 
     46 
     47        for (k = 1; k < IIR_NUM_COEFFICIENTS; k++) 
     48        { 
     49            signed int n_minus_k = n - k; 
     50            if (n_minus_k >= 0) 
     51            { 
     52                x_n_minus_k = x[n_minus_k]; 
     53                y_n_minus_k = y[n_minus_k]; 
     54            } 
     55            else 
     56            { 
     57                x_n_minus_k = x_mem[-n_minus_k-1]; 
     58                y_n_minus_k = y_mem[-n_minus_k-1]; 
     59            } 
     60 
     61            y[n] -= a[k] * y_n_minus_k; 
     62            y[n] += b[k] * x_n_minus_k; 
     63        } 
     64    } 
     65 
     66        // Save input and output state, latest first 
     67    unsigned int state_offset = N - 1; 
     68    for (n=0; n < (IIR_NUM_COEFFICIENTS-1); n++) 
     69    { 
     70        x_mem[n] = x[state_offset]; 
     71        y_mem[n] = y[state_offset]; 
     72        state_offset--; 
     73    } 
     74} 
     75 
     76static void iir_execute(AudioOutputUtil::IIR &instance, float* x, float* y) 
     77{ 
     78    iir_biquad(x, y, 
     79               &instance.state.a[0], &instance.state.b[0], 
     80               &instance.state.x_mem[0], &instance.state.y_mem[0], 
     81               instance.parameters.N); 
     82} 
     83 
     84// Notch filter 
     85#define PI_FLOAT                    (3.14159265358979f) 
     86 
     87void AudioOutputUtil::notch_update (Notch &instance, float fs) 
     88{ 
     89    instance.state.pole_position = 0.99f; 
     90    instance.state.frequency_offset = 0.0f; // in normalised frequency (1.0 = fs) 
     91    instance.state.a1s = -instance.state.pole_position; 
     92    instance.state.a2 = -(instance.state.pole_position * instance.state.pole_position); 
     93    instance.state.depth_factor = 1.0f; 
     94 
     95        // Calculate filter coefficients 
     96        // Direct-form IIR 
     97        // Ref: http://www.musicdsp.org/files/Audio-EQ-Cookbook.txt and others 
     98    float normalised_notch_frequency = (2.0f * instance.parameters.frequency / fs); 
     99    normalised_notch_frequency += instance.state.frequency_offset; 
     100    float frequency_factor = -2.0f * cosf(PI_FLOAT * normalised_notch_frequency); 
     101    float a1 = frequency_factor * instance.state.a1s; 
     102    float a2 = instance.state.a2; 
     103    float b1 = frequency_factor * instance.state.depth_factor; 
     104    float b2 = instance.state.depth_factor * instance.state.depth_factor; 
     105    instance.iir.parameters.N = instance.parameters.N; 
     106    instance.iir.parameters.a[0] = 1.0f; 
     107    instance.iir.parameters.a[1] = -a1; 
     108    instance.iir.parameters.a[2] = -a2; 
     109    instance.iir.parameters.b[0] = 1.0f; 
     110    instance.iir.parameters.b[1] = b1; 
     111    instance.iir.parameters.b[2] = b2; 
     112 
     113        // Initialise the IIR stage 
     114    iir_update(instance.iir); 
     115} 
     116 
     117// Processes a single block of samples 
     118void AudioOutputUtil::notch_execute (Notch &instance, float *in, float *out) 
     119{ 
     120    // Apply the rejection filter 
     121    iir_execute(instance.iir, in, out); 
     122} 
  • mythtv/programs/mythfrontend/globalsettings.cpp

    Property changes on: mythtv/libs/libmyth/audiooutpututil.cpp
    ___________________________________________________________________
    Added: svn:executable
       + *
    
     
    181181    return gc; 
    182182} 
    183183 
     184static HostCheckBox *VuvuzelaFilter() 
     185{ 
     186    HostCheckBox *gc = new HostCheckBox("VuvuzelaFilter"); 
     187    gc->setLabel(QObject::tr("Enable vuvuzela filter")); 
     188    gc->setValue(false); 
     189    gc->setHelpText(QObject::tr("With this option enabled, a dedicated vuvuzela " 
     190                                "filter option will be accessible in the playback " 
     191                                "menu")); 
     192    return gc; 
     193} 
     194 
    184195static HostCheckBox *MythControlsVolume() 
    185196{ 
    186197    HostCheckBox *gc = new HostCheckBox("MythControlsVolume"); 
     
    34853496    settings2->addChild(srcqualityoverride); 
    34863497    settings2->addChild(sub3); 
    34873498     
     3499    group2->addChild(VuvuzelaFilter()); 
    34883500    group2->addChild(settings2); 
    34893501    group2->addChild(AggressiveBuffer()); 
    34903502 
  • mythtv/programs/mythtranscode/transcode.cpp

     
    222222        // Do nothing 
    223223        return false; 
    224224    } 
     225    virtual bool ToggleVuvuzela(void) 
     226    { 
     227        // Do nothing 
     228        return false; 
     229    } 
    225230 
    226231    virtual void SetSWVolume(int new_volume, bool save) 
    227232    {