@@ -8,7 +8,7 @@ class WaveSmplLoop(NamedTuple):
88 loop_type : int
99 start : int
1010 end : int
11- fraction : int
11+ detune_cents : int
1212 repetition_count : int
1313
1414 def loop_type_desc (self ):
@@ -30,7 +30,7 @@ def to_dict(self):
3030 'loop_type_description' : self .loop_type_desc (),
3131 'start_samples' : self .start ,
3232 'end_samples' : self .end ,
33- 'fraction ' : self .fraction ,
33+ 'detune_cents ' : self .detune_cents ,
3434 'repetition_count' : self .repetition_count ,
3535 }
3636
@@ -42,8 +42,8 @@ def __init__(self, smpl_data: bytes):
4242 Read sampler metadata from smpl chunk.
4343 """
4444
45- header_field_fmt = "<IIIIIIbbbbII "
46- loop_field_fmt = "<IIIIII "
45+ header_field_fmt = "<IIIIiIbbbbII "
46+ loop_field_fmt = "<IIIIiI "
4747 header_size = struct .calcsize (header_field_fmt )
4848 loop_size = struct .calcsize (loop_field_fmt )
4949
@@ -65,7 +65,7 @@ def __init__(self, smpl_data: bytes):
6565 self .midi_note : int = unpacked_data [3 ]
6666
6767 #: The number of semitones above the MIDI note the loops tune for.
68- self .midi_pitch_fraction_semis : int = unpacked_data [4 ]
68+ self .midi_pitch_detune_cents : int = unpacked_data [4 ]
6969
7070 #: SMPTE timecode format, one of (0, 24, 25, 29, 30)
7171 self .smpte_format : int = unpacked_data [5 ]
@@ -89,21 +89,24 @@ def __init__(self, smpl_data: bytes):
8989 loop_type = unpacked_loop [1 ],
9090 start = unpacked_loop [2 ],
9191 end = unpacked_loop [3 ],
92- fraction = unpacked_loop [4 ],
92+ detune_cents = unpacked_loop [4 ],
9393 repetition_count = unpacked_loop [5 ]))
9494
9595 #: Sampler-specific user data.
96- self .sampler_udata : bytes = smpl_data [
97- header_size + loop_size * loop_count :
98- header_size + loop_size * loop_count + sampler_udata_length ]
96+ self .sampler_udata : bytes | None = None
97+
98+ if sampler_udata_length > 0 :
99+ self .sampler_udata = smpl_data [
100+ header_size + loop_size * loop_count :
101+ header_size + loop_size * loop_count + sampler_udata_length ]
99102
100103 def to_dict (self ):
101104 return {
102105 'manufactuer' : self .manufacturer ,
103106 'product' : self .product ,
104107 'sample_period_ns' : self .sample_period_ns ,
105108 'midi_note' : self .midi_note ,
106- 'midi_pitch_fraction_semis ' : self .midi_pitch_fraction_semis ,
109+ 'midi_pitch_detune_cents ' : self .midi_pitch_detune_cents ,
107110 'smpte_format' : self .smpte_format ,
108111 'smpte_offset' : "%02i:%02i:%02i:%02i" % self .smpte_offset ,
109112 'loops' : [x .to_dict () for x in self .sample_loops ],
0 commit comments