On Sat, 29 Aug 2009, A. Zimmer wrote:

> From: Eric Welsh <ewe...@bi...> - 2009-08-28 03:56
>
> > Adding a decent release envelope solved the problem. This is not a
> > problem with timidity, but a problem with the instrument not having any
> > kind of sane envelope.
>
> Using the swami soundfont editor (http://swami.resonance.org/trac) I can
> also modify the volume envelope release value and eliminate the clicking
> noise.

I have attached a reasonably proper (I think) fix for the problem.  Rather
than deal with it during instrument loading, or checking to be sure that
envelope values get set to reasonable parameters in the first place, I
went to the lowest level of the problem and fixed it directly in the
mixing routines.  Now, any envelope ramp (from starting volume to final
ending volume) MUST take place over a minimum of 0.5 msec.  This should
gaurantee that the problem is solved even for unforseen combinations of
envelope settings in the future.  The problematic recorder sounds much
much better now :)

> However, using swami to take a quick survey of the many SF2 soundfonts
> that I have gathered from the Web, I discover that perhaps the majority
> of them have a near zero release value set.  All these fonts should
> therefore cause problems with Timididty++, but as I have indicated
> previously, they will not cause problems with the fluidsynth software
> synthesizer.  So, is the assessment that these soundfonts lack a
> "sane envelope" really a correct one?

TiMidity was originally written to use GUS pats.  There are several
kludges and lots of comments with ?? that deal with specific weirdness in
GUS pats.  I have been using TiMidity since around 1996, since before SF2
files, and have edited many many instrument files from all sorts of
different sources.  My memory is a little fuzzy on pre-PAT formats, such
as instruments from Kurzweil, Roland, and Yamaha synthesizer disks, but I
seem to remember all of them having reasonable release envelopes.  So, up
until SF2 files, most digital instruments had reasonable envelope
parameters.  Then there was a flood of SF2 instruments, many of which had
either no envelopes at all, or really strange envelopes.  From my
(relatively ancient) perspective, these SF2 files have broken envelopes.

While I still maintain that the SF2 files are broken, as several people
have pointed out, TiMidity should still be able to deal with it and at
least avoid generating popping sounds.  I totally agree ... there was just
a large energy barrier to digging back into the TiMidity source code after
several years of inactivity....

The patch was generated off a not-current version of mix.c.  If the patch
offsets are too far off, or the file has changed too much from the current
version (which I think is unlikely), the patch is within the next_stage(int v)
function, and it should be fairly obvious where to insert the new code
given the surrounding code chunks in the patch.



If I could ever get the softsynth to compile and run properly in Windows,
I'd fix some XG SYSEX event handling problems too....  The normal midi
file playing routines already have fixes for the issue, but they never
made it into the realtime synth routines.  Does anybody have any
experience getting the realtime softsynth to compile and run under
Windows?

-Eric
*** mix.c.orig  Mon Jan 23 03:07:44 2006
--- mix.c       Sun Sep  6 14:41:41 2009
***************
*** 1628,1634 ****
  {
        int stage, ch, eg_stage;
        int32 offset, val;
!       FLOAT_T rate;
        Voice *vp = &voice[v];
  
        stage = vp->envelope_stage++;
--- 1628,1634 ----
  {
        int stage, ch, eg_stage;
        int32 offset, val;
!       FLOAT_T rate, temp_rate;
        Voice *vp = &voice[v];
  
        stage = vp->envelope_stage++;
***************
*** 1637,1642 ****
--- 1637,1651 ----
        if (vp->envelope_volume == offset
                        || (stage > EG_GUS_SUSTAIN && vp->envelope_volume < 
offset))
                return recompute_envelope(v);
+ 
+       /* HACK -- force ramps to occur over 0.5 msec windows to avoid pops */
+       temp_rate = labs(vp->envelope_volume - offset) /
+                       (play_mode->rate * 0.0005);
+       if (temp_rate < 1)
+           temp_rate = 1;
+       if (temp_rate < rate)
+           rate = temp_rate;
+ 
        ch = vp->channel;
        /* there is some difference between GUS patch and Soundfont at 
envelope. */
        eg_stage = get_eg_stage(v, stage);
------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day 
trial. Simplify your report design, integration and deployment - and focus on 
what you do best, core application coding. Discover what's new with 
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
Timidity-talk mailing list
Timidity-talk@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/timidity-talk

Reply via email to