ws-audio2: music/okt (Oktalyzer): it family with ProTracker periods (PAL), mixed channel pairs and their shared volume, three arpeggios, note slides, sustain loops released by R
This commit is contained in:
1 parent
6b5e8ec6cf
commit
9a5f3796e2
6 files changed
+455
No files matched your search
@@ -749,3 +749,35 @@ def write_far(title, samples, orders, patterns, speed=4, pans=None, breaks=None,
|
||||
1 if bps == 2 else 0, 8 if s.get("loop") else 0)
|
||||
body += s["data"]
|
||||
return bytes(body)
|
||||
|
||||
|
||||
def write_okt(samples, orders, patterns, cmod=(0, 0, 0, 0), speed=6):
|
||||
"""samples: [{name, data (signed bytes, even length), volume 0..64, type 0 paired / 1 raw / 2 both, loop: (start,
|
||||
length) in bytes (even) | None}]; patterns: [[row: [(note, ins, effect, param)] * channels] * rows] with note 0 =
|
||||
none else 1..36 (13 = C-5 of the module), ins 1-based; cmod: the four Amiga channels, 1 = a mixed pair"""
|
||||
def chunk(cid, data):
|
||||
return cid + struct.pack(">I", len(data)) + data
|
||||
out = bytearray(b"OKTASONG")
|
||||
out += chunk(b"CMOD", b"".join(struct.pack(">H", c) for c in cmod))
|
||||
sh = bytearray()
|
||||
for i in range(36):
|
||||
if i < len(samples):
|
||||
s = samples[i]
|
||||
ls, ll = s.get("loop") or (0, 0)
|
||||
sh += name(s.get("name", ""), 20) + struct.pack(">IHHHH", len(s["data"]), ls // 2, ll // 2, s.get("volume", 64), s.get("type", 2))
|
||||
else:
|
||||
sh += b"\0" * 32
|
||||
out += chunk(b"SAMP", bytes(sh))
|
||||
out += chunk(b"SPEE", struct.pack(">H", speed))
|
||||
out += chunk(b"SLEN", struct.pack(">H", len(patterns)))
|
||||
out += chunk(b"PLEN", struct.pack(">H", len(orders)))
|
||||
out += chunk(b"PATT", bytes(orders) + b"\0" * (128 - len(orders)))
|
||||
for pat in patterns:
|
||||
pb = bytearray(struct.pack(">H", len(pat)))
|
||||
for row in pat:
|
||||
for (note, ins, fx, param) in row:
|
||||
pb += bytes([note, max(0, ins - 1), fx, param])
|
||||
out += chunk(b"PBOD", bytes(pb))
|
||||
for s in samples:
|
||||
out += chunk(b"SBOD", s["data"])
|
||||
return bytes(out)
|
||||
Reference in new issue
Block a user