[Freepats] [LAU] Steinway_IMIS2 soundfont

Ben Collver collver at peak.org
Fri Jul 6 01:35:17 EST 2007


Roberto Gordo Saez wrote:
> On Thu, Jul 05, 2007 at 01:13:02AM +0200, Marcos Guglielmetti wrote:
>>  | I also like the fact that it's long samples without 
>>  | the need for looping. However it seems that loops are on, although you
>>  | have to play really long notes to hear it :-)
>>
>> Loops are on? Oh shit! you are right! :P
> 
> It seems that pysf has added the loops. I don't know why. Ben Collver is
> pysf's author and he is usually on this list, maybe he could help us.

When converting from XML to SF2, pysf enabled looping if it found loop points.  The original soundfont file had loop points, and the new soundfont file had looping enabled.  Here is the culprit code.
                if Loopstart != 0 or Loopend != 0:
                    LoopType = 3 # Release
                else:
                    LoopType = 0 # None

I've updated my working copy of pysf.py to fix this issue.  You can get it at the following URL.
http://terrorpin.net/~ben/docs/alt/music/soundfont/pysf-wip/pysf.py

If you want to enable looping you will need to add a new key to each zone.
<sampleModes>3_LoopRelease</sampleModes>

Cheers,

Ben


p.s.  Here is what changed.

--- pysf.py.orig   2007-03-10 16:14:09.000000000 -0800
+++ pysf.py     2007-07-05 08:27:40.000000000 -0700
@@ -608,7 +608,11 @@
                         else:
                             ZDict[ustr(Name)] = WAmount
                     elif SfGenOper == 54:
-                        pass
+                        if Zt.KeyN == 'preset':
+                            logging.warn('ignoring sampleModes in preset')
+                        else:
+                            ZDict[ustr(Name)] = Def(Val(SfSampleModes,
+                              WAmount), "0_LoopNone")
                     else:
                         Generators.append({u'comment': Name,
                             u'hexAmount': "0x%x" % WAmount, u'oper': SfGenOper}
)
@@ -917,12 +921,21 @@
                     Loopend = Wavetable[u'loop'][u'end']
                 except (IndexError, KeyError):
                     (Loopstart, Loopend) = (0, 0)
-                if Loopstart != 0 or Loopend != 0:
-                    LoopType = 3 # Release
+                SampleModesStr = Def(Val(Zone, u'sampleModes'), "0_LoopNone")
+                if SampleModesStr == "0_LoopNone":
+                     SampleModes = 0
+                elif SampleModesStr == "1_LoopContinuous":
+                     SampleModes = 1
+                elif SampleModesStr == "2_LoopReserved":
+                     SampleModes = 2
+                elif SampleModesStr == "3_LoopRelease":
+                     SampleModes = 3
                 else:
-                    LoopType = 0 # None
+                    logging.warn("%s %d unknown sampleModes %s" % (
+                        Zt.KeyN, Order + 1, SampleModesStr))
+                    SampleModes = 0
                 IopsCount = IopsCount + 1
-                GenD = GenD + struct.pack('<HH', 54, LoopType)
+                GenD = GenD + struct.pack('<HH', 54, SampleModes)
             EnvDelay = SfLog(Zone, u'delayVolEnv', SHOOBVAL)
             if EnvDelay > SHOOBVAL:
                 IopsCount = IopsCount + 1
@@ -1089,6 +1102,10 @@
     13: 'Channel Pressure',
     14: 'Pitch Wheel',
     16: 'Pitch Wheel Sensitivity'}
+SfSampleModes = {0: '0_LoopNone',
+    1: '1_LoopContinuous',
+    2: '2_LoopReserved',
+    3: '3_LoopRelease'}
 SfModTypeDescs = ('Linear', 'Concave', 'Convex', 'Switch')
 XmlHeaderStr = u'<sf:pysf version="' + ustr(PysfVersion) + u'" xmlns:sf="http:/
/terrorpin.net/~ben/docs/alt/music/soundfont/pysf" xmlns:xsi="http://www.w3.org/
2001/XMLSchema-instance" xsi:schemaLocation="http://terrorpin.net/~ben/docs/alt/
music/soundfont/pysf pysf.xsd">'
 XmlRootStr = XmlHeaderStr + u'</sf:pysf>'


More information about the Freepats mailing list