Skip to content

Instantly share code, notes, and snippets.

@csik
Forked from jhw/.PICO_DRUMS.md
Last active January 11, 2022 18:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save csik/415bd02440b1c41e839ae02d8de3d23a to your computer and use it in GitHub Desktop.
Save csik/415bd02440b1c41e839ae02d8de3d23a to your computer and use it in GitHub Desktop.
Parse Pico Drums packs
bin
include
lib
share
tmp
*.pyc
*.zip

download

justin@justin-XPS-13-9360:~/work$ python download.py 
Default
Complex Waveforms
DJ Raitis Vinyl Cuts
IB Magnetic Saturation
Richard Devine
Nero Bellum
Pitch Black
Legowelt
Otto Von Schirach
Baseck
Clipping

parse

justin@justin-XPS-13-9360:~/work$ python parse.py pico_drum_default_pack.bin 
justin@justin-XPS-13-9360:~/work $ unzip -vl pico_drum_default_pack.zip 
Archive:  pico_drum_default_pack.zip
 Length   Method    Size  Cmpr    Date    Time   CRC-32   Name
--------  ------  ------- ---- ---------- ----- --------  ----
    8794  Stored     8794   0% 2019-11-08 18:33 a92bbce0  01. 7007 bd.wav
   12058  Stored    12058   0% 2019-11-08 18:33 69cabdd6  02. 8008 bd.wav
  108898  Stored   108898   0% 2019-11-08 18:33 af1f3126  03. 9009 bd.wav
    1088  Stored     1088   0% 2019-11-08 18:33 bcd505be  04. buchla bd.wav
    7120  Stored     7120   0% 2019-11-08 18:33 c74eff0f  05. ib bd 1.wav
   14892  Stored    14892   0% 2019-11-08 18:33 56258142  06. ib bd 2.wav
   32406  Stored    32406   0% 2019-11-08 18:33 96695ff6  07. jungle bd.wav
    3851  Stored     3851   0% 2019-11-08 18:33 89a32ee8  08. 9009 bd.wav

links

virtualenv

  • virtualenv -p /usr/bin/python3.6 .
  • source bin/activate
  • pip install -r requirements.txt
  • {...}
  • deactivate
import json, time, urllib.request
Endpoint="http://data.ericasynths.lv/picodrum/"
def fetch_json(path):
return json.loads(urllib.request.urlopen(Endpoint+path).read())
def fetch_bin(path):
return urllib.request.urlopen(Endpoint+path).read()
if __name__=="__main__":
for item in fetch_json("pack_list.json"):
print (item["name"])
with open(item["file"], 'wb') as f:
f.write(fetch_bin(item["file"]))
time.sleep(1)
from zipfile import ZipFile
import re
def filter_blocks(buf):
def format_block(block):
tokens=block.split(b"data")
name=tokens[0][1:-1]
data=(b"data".join(tokens[1:]))
offset=data.index(b"RIFF")
return (name, data[offset:])
return [format_block(block.split(b"<?xpacket begin")[0])
for block in buf.split(b"\202\244name")[1:]]
if __name__=="__main__":
try:
import os, sys
if len(sys.argv) < 2:
raise RuntimeError("Please enter filename")
filename= sys.argv[1]
if not os.path.exists(filename):
raise RuntimeError("File does not exist")
if (not "pico_drum" in filename or
not filename.endswith("pack.bin")):
raise RuntimeError("File must be of form pico_drum_*_pack.bin")
buf=open(filename, mode='rb').read()
print (type(buf))
with ZipFile("%s" % filename.replace("bin", "zip"), 'w') as zf:
for name, data in filter_blocks(buf):
zf.writestr(name.decode("ascii"),data)
except RuntimeError as error:
print ("Error: %s" % str(error))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment