Merge branch 'rochade'
[alioth/musescore.git] / debian / patches / experiments / valid-soundfont.diff
index a22fee0..c86d77a 100644 (file)
@@ -18,7 +18,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
 
 --- a/fluid/sfont.cpp
 +++ b/fluid/sfont.cpp
-@@ -589,6 +589,7 @@ Sample::Sample(SFont* s)
+@@ -610,6 +610,7 @@ Sample::Sample(SFont* s)
        data        = 0;
        amplitude_that_reaches_noise_floor_is_valid = false;
        amplitude_that_reaches_noise_floor = 0.0;
@@ -26,22 +26,20 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
        }
  
  //---------------------------------------------------------
-@@ -625,11 +626,12 @@ void Sample::load()
- #ifdef SOUNDFONT3
-             char* p = new char[size];
-             if (fd.read(p, size) != size) {
--                  printf("  read %d failed\n", size);
-                   delete[] p;
+@@ -647,18 +648,22 @@ void Sample::load()
+             std::vector<char> p;
+             p.resize(size);
+             if (fd.read(p.data(), size) != size) {
+-                  qDebug("read %d failed", size);
 +                  qWarning("SoundFont(%s) Sample(%s) read %u bytes failed", qPrintable(sf->get_name()), name, size);
 +                  setValid(false);
                    return;
                    }
--            decompressOggVorbis(p, size);
-+            setValid(decompressOggVorbis(p, size));
-             delete[] p;
+-            decompressOggVorbis(p.data(), size);
++            setValid(decompressOggVorbis(p.data(), size));
  #endif
              }
-@@ -637,8 +639,11 @@ void Sample::load()
+       else {
              data = new short[size];
              size *= sizeof(short);
  
@@ -54,7 +52,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
  
              if (QSysInfo::ByteOrder == QSysInfo::BigEndian) {
                    unsigned char hi, lo;
-@@ -652,11 +657,34 @@ void Sample::load()
+@@ -672,11 +677,34 @@ void Sample::load()
                          data[i] = s;
                          }
                    }
@@ -90,7 +88,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
        optimize();
        }
  
-@@ -725,6 +753,8 @@ bool SFont::load()
+@@ -745,6 +773,8 @@ bool SFont::load()
              }
        SFChunk chunk;
  
@@ -99,7 +97,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
        try {
              readchunk(&chunk);
              if (chunkid(chunk.id) != RIFF_ID)
-@@ -1599,9 +1629,7 @@ void SFont::load_shdr (int size)
+@@ -1624,9 +1654,7 @@ void SFont::load_shdr (int size)
        for (int i = 0; i < size; i++) {
              Sample* p = new Sample(this);
              sample.append(p);
@@ -110,7 +108,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
              READD (p->start);
              READD (p->end);         /* - end, loopstart and loopend */
              READD (p->loopstart);     /* - will be checked and turned into */
-@@ -1616,28 +1644,47 @@ void SFont::load_shdr (int size)
+@@ -1641,28 +1669,47 @@ void SFont::load_shdr (int size)
                    continue;
                    }
              if ((p->end > getSamplesize()) || (p->start > (p->end - 4))) {
@@ -173,7 +171,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
        FSKIP (SFSHDRSIZE);     /* skip terminal shdr */
 --- a/fluid/sfont.h
 +++ b/fluid/sfont.h
-@@ -147,8 +147,10 @@ class Sample {
+@@ -150,8 +150,10 @@ class Sample {
            filled out automatically */
        /* Set this to zero, when submitting a new sample. */
  
@@ -185,7 +183,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
  
        Sample(SFont*);
        ~Sample();
-@@ -159,7 +161,7 @@ class Sample {
+@@ -162,7 +164,7 @@ class Sample {
        bool valid() const    { return _valid; }
        void setValid(bool v) { _valid = v; }
  #ifdef SOUNDFONT3
@@ -276,7 +274,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
        return true;
 --- a/fluid/voice.cpp
 +++ b/fluid/voice.cpp
-@@ -1170,8 +1170,8 @@ void Voice::update_param(int _gen)
+@@ -1171,8 +1171,8 @@ void Voice::update_param(int _gen)
              case GEN_STARTADDRCOARSEOFS:        /* SF2.01 section 8.1.3 # 4 */
                    if (sample != 0) {
                          start = (sample->start
@@ -287,7 +285,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
                          check_sample_sanity_flag = FLUID_SAMPLESANITY_CHECK;
                          }
                    break;
-@@ -1180,8 +1180,8 @@ void Voice::update_param(int _gen)
+@@ -1181,8 +1181,8 @@ void Voice::update_param(int _gen)
              case GEN_ENDADDRCOARSEOFS:           /* SF2.01 section 8.1.3 # 12 */
                    if (sample != 0) {
                          end = (sample->end
@@ -298,7 +296,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
                          check_sample_sanity_flag = FLUID_SAMPLESANITY_CHECK;
                          }
                    break;
-@@ -1190,8 +1190,8 @@ void Voice::update_param(int _gen)
+@@ -1191,8 +1191,8 @@ void Voice::update_param(int _gen)
              case GEN_STARTLOOPADDRCOARSEOFS:     /* SF2.01 section 8.1.3 # 45 */
                    if (sample != 0) {
                          loopstart = (sample->loopstart
@@ -309,7 +307,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
                          check_sample_sanity_flag = FLUID_SAMPLESANITY_CHECK;
                          }
                    break;
-@@ -1200,8 +1200,8 @@ void Voice::update_param(int _gen)
+@@ -1201,8 +1201,8 @@ void Voice::update_param(int _gen)
              case GEN_ENDLOOPADDRCOARSEOFS:       /* SF2.01 section 8.1.3 # 50 */
                    if (sample != 0) {
                          loopend = (sample->loopend
@@ -320,7 +318,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
                          check_sample_sanity_flag = FLUID_SAMPLESANITY_CHECK;
                          }
                    break;
-@@ -1636,22 +1636,22 @@ float Voice::get_lower_boundary_for_atte
+@@ -1646,22 +1646,22 @@ float Voice::get_lower_boundary_for_atte
   */
  void Voice::check_sample_sanity()
        {
@@ -340,18 +338,18 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
              return;
  
  #if 0
--      printf("Sample from %i to %i\n", sample->start, sample->end);
--      printf("Sample loop from %i %i\n", sample->loopstart, sample->loopend);
--      printf("Playback from %i to %i\n", start, end);
--      printf("Playback loop from %i to %i\n", loopstart, loopend);
-+      printf("Sample from %u to %u\n", sample->start, sample->end);
-+      printf("Sample loop from %u to %u\n", sample->loopstart, sample->loopend);
-+      printf("Playback from %u to %u\n", start, end);
-+      printf("Playback loop from %u to %u\n", loopstart, loopend);
+-printf("Sample from %i to %i\n", sample->start, sample->end);
+-printf("Sample loop from %i %i\n", sample->loopstart, sample->loopend);
+-printf("Playback from %i to %i\n", start, end);
+-printf("Playback loop from %i to %i\n", loopstart, loopend);
++printf("Sample from %u to %u\n", sample->start, sample->end);
++printf("Sample loop from %u to %u\n", sample->loopstart, sample->loopend);
++printf("Playback from %u to %u\n", start, end);
++printf("Playback loop from %u to %u\n", loopstart, loopend);
  #endif
  
        /* Keep the start point within the sample data */
-@@ -1668,7 +1668,7 @@ void Voice::check_sample_sanity()
+@@ -1678,7 +1678,7 @@ printf("Playback loop from %i to %i\n",
  
        /* Keep start and end point in the right order */
        if (start > end) {
@@ -360,7 +358,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
              start    = end;
              end      = temp;
              }
-@@ -1694,7 +1694,7 @@ void Voice::check_sample_sanity()
+@@ -1704,7 +1704,7 @@ printf("Playback loop from %i to %i\n",
  
              /* Keep loop start and end point in the right order */
              if (loopstart > loopend){
@@ -369,7 +367,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
                    loopstart = loopend;
                    loopend   = temp;
                    }
-@@ -1706,7 +1706,7 @@ void Voice::check_sample_sanity()
+@@ -1716,7 +1716,7 @@ printf("Playback loop from %i to %i\n",
              /* The loop points may have changed. Obtain a new estimate for the loop volume. */
              /* Is the voice loop within the sample loop?
               */
@@ -378,7 +376,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
                    /* Is there a valid peak amplitude available for the loop? */
                    if (sample->amplitude_that_reaches_noise_floor_is_valid) {
                          amplitude_that_reaches_noise_floor_loop = sample->amplitude_that_reaches_noise_floor;
-@@ -1745,13 +1745,13 @@ void Voice::check_sample_sanity()
+@@ -1755,13 +1755,13 @@ printf("Playback loop from %i to %i\n",
              * the sample, enter the loop and proceed as expected => no
              * actions required.
              */
@@ -394,7 +392,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
  
      /* Sample sanity has been assured. Don't check again, until some
         sample parameter is changed by modulation.
-@@ -1795,7 +1795,6 @@ void Sample::optimize()
+@@ -1805,7 +1805,6 @@ void Sample::optimize()
        signed short peak;
        float normalized_amplitude_during_loop;
        double result;
@@ -402,7 +400,7 @@ Forwarded: https://github.com/musescore/MuseScore/pull/7728
  
        /* ignore ROM and other(?) invalid samples */
        if (!s->valid())
-@@ -1803,7 +1802,7 @@ void Sample::optimize()
+@@ -1813,7 +1812,7 @@ void Sample::optimize()
  
        if (!s->amplitude_that_reaches_noise_floor_is_valid) { /* Only once */
              /* Scan the loop */