Ticket #746: visualisers.patch

File visualisers.patch, 5.2 KB (added by eskil <myth@…>, 18 years ago)

patch for visualisers

  • mythplugins/mythmusic/mythmusic/goom/mythgoom.cpp

    diff --exclude='#*#' --exclude='*.orig' --exclude='*.rej' --exclude='*~' --exclude='Makefile*' --exclude='*svn*' --exclude='moc_*.cpp' -rNu ../decoderlocking/mythplugins/mythmusic/mythmusic/goom/mythgoom.cpp mythplugins/mythmusic/mythmusic/goom/mythgoom.cpp
    old new  
    7878        return true;
    7979
    8080    int numSamps = 512;
     81    int step = 1;
     82
    8183    if (node->length < 512)
    82         numSamps = node->length;
     84        step = 512 / node->length;
    8385
    8486    signed short int data[2][512];
    8587   
    8688    int i = 0;
    87     for (i = 0; i < numSamps; i++)
     89    for (i = 0; i < numSamps; i += step)
    8890    {
    8991        data[0][i] = node->left[i];
    9092        if (node->right)
    9193            data[1][i] = node->right[i];
    9294        else
    9395            data[1][i] = data[0][i];
     96
     97        if (step > 1)
     98            for (int j = 1; j < step; j++)
     99            {
     100                data[0][i+j] = data[0][i];
     101                data[1][i+j] = data[1][i];
     102            }
    94103    }
    95104
    96105    for (; i < 512; i++)
  • mythplugins/mythmusic/mythmusic/inlines.h

    diff --exclude='#*#' --exclude='*.orig' --exclude='*.rej' --exclude='*~' --exclude='Makefile*' --exclude='*svn*' --exclude='moc_*.cpp' -rNu ../decoderlocking/mythplugins/mythmusic/mythmusic/inlines.h mythplugins/mythmusic/mythmusic/inlines.h
    old new  
    1111
    1212// *fast* convenience functions
    1313
     14static inline void smoothen_mono(short *in_data, short *out_data, int len, int new_len)
     15{
     16    int step = new_len/len;
     17    int dii = 0;
     18    for (int ii = 0; ii < len; ii++)           
     19    {
     20        out_data[dii] = in_data[ii];
     21       
     22        short smooth = 0;
     23
     24        if (ii < len-1)
     25            smooth = in_data[ii+1] - in_data[ii];
     26
     27        if (smooth)
     28            smooth /= step;
     29       
     30        for (int cc = 1; cc < step; cc++) {
     31            out_data[dii+cc] = out_data[dii+cc-1] + smooth;
     32        }
     33       
     34        dii += step;
     35    }
     36}
     37
     38static inline void smoothen_stereo(short *l_in_data, short *l_out_data,
     39                                   short *r_in_data, short *r_out_data,
     40                                   int len, int new_len)
     41{
     42    int step = new_len/len;
     43    int dii = 0;
     44    for (int ii = 0; ii < len; ii++)           
     45    {
     46        l_out_data[dii] = l_in_data[ii];
     47        r_out_data[dii] = r_in_data[ii];
     48       
     49        short l_smooth = 0;
     50        short r_smooth = 0;
     51
     52        if (ii < len-1) {
     53            l_smooth = l_in_data[ii+1] - l_in_data[ii];
     54            r_smooth = r_in_data[ii+1] - r_in_data[ii];
     55        }
     56
     57        if (l_smooth)
     58            l_smooth /= step;
     59       
     60        if (r_smooth)
     61            r_smooth /= step;
     62       
     63        for (int cc = 1; cc < step; cc++) {
     64            l_out_data[dii+cc] = l_out_data[dii+cc-1] + l_smooth;
     65            r_out_data[dii+cc] = r_out_data[dii+cc-1] + r_smooth;
     66        }
     67       
     68        dii += step;
     69    }
     70}
     71
    1472static inline void stereo16_from_stereopcm8(register short *l,
    1573                                            register short *r,
    1674                                            register uchar *c,
  • mythplugins/mythmusic/mythmusic/mainvisual.cpp

    diff --exclude='#*#' --exclude='*.orig' --exclude='*.rej' --exclude='*~' --exclude='Makefile*' --exclude='*svn*' --exclude='moc_*.cpp' -rNu ../decoderlocking/mythplugins/mythmusic/mythmusic/mainvisual.cpp mythplugins/mythmusic/mythmusic/mainvisual.cpp
    old new  
    229229    else
    230230        len = 0;
    231231
     232    if (len < 512)
     233    {
     234        short *new_l = 0;
     235        short *new_r = 0;
     236
     237        if (c == 1)
     238        {
     239            new_l = new short[512];
     240            smoothen_mono(l, new_l, len, 512);
     241            delete r;
     242            delete l;
     243            r = new_r;
     244            l = new_l;
     245        }
     246
     247        if (c == 2)
     248        {
     249            new_l = new short[512];
     250            new_r = new short[512];
     251            smoothen_stereo(l, new_l, r, new_r, len, 512);
     252            delete r;
     253            delete l;
     254            r = new_r;
     255            l = new_l;
     256        }
     257
     258        len = 512;
     259    }
     260
    232261    nodes.append(new VisualNode(l, r, len, w));
    233262}
    234263
     
    401430    long s, indexTo;
    402431    double *magnitudesp = magnitudes.data();
    403432    double valL, valR, tmpL, tmpR;
    404     double index, step = 512.0 / size.width();
    405433
    406434    if (node) {
    407         index = 0;
     435    double step = (node->length < 512 ? node->length : 512.0) / size.width();
     436        double index = 0;
    408437        for ( i = 0; i < size.width(); i++) {
    409438            indexTo = (int)(index + step);
    410439            if (indexTo == (int)(index))
     
    600629    double *magnitudesp = magnitudes.data();
    601630    double val, tmp;
    602631
    603     double index, step = 512.0 / size.width();
    604 
    605632    if (node)
    606633    {
    607         index = 0;
     634        double step = (node->length < 512 ? node->length : 512.0) / size.width();
     635        double index = 0;
    608636        for ( i = 0; i < size.width(); i++)
    609637        {
    610638            indexTo = (int)(index + step);