tidalcycles / Clean-Samples

Like Dirt-Samples, but cleaned up
GNU General Public License v3.0
44 stars 4 forks source link

Reference metadata implementation #2

Closed yaxu closed 3 years ago

yaxu commented 3 years ago

It would be nice to start with a python script that reads a folder of samples, and writes a metadata file for them.. As a practical tool and also a reference implementation for people wanting to use clean samples in their cool live coding language.

yaxu commented 3 years ago

Ok here's a test script: https://github.com/tidalcycles/Clean-Samples/blob/main/bin/meta.py With example output: https://github.com/tidalcycles/Clean-Samples/blob/main/example_pack/clean-metadata.json

A json dictionary, which includes a list of dictionaries for each sound. If the file is edited and the script re-run, the old is merged with default values, with the edits taking precedence.

How's this looking?

dktr0 commented 3 years ago

Nice that is JSON. Will make it easy to slurp into Estuary as well. One thought/nuance might be for the top-level JSON object to have a field that uniquely identifies the type of data contained in this JSON record (meta-metadata, as it were), since the other field names are likely to be common in other JSON metadata formats floating around (Estuary will have some, very shortly, that will be similar in some ways to this, but also different in others, for example). Such a field doesn't need to be common to different formats, it just needs to be uniquely identifying (unlikely to be used for some other purpose). For example if there was a field { clean-samples-version: 1.0 } that would serve the dual purpose of identifying how these fields should be interpreted and allowing some graceful evolution between later/earlier versions if the format changes later on.

yaxu commented 3 years ago

Good idea @dktr0, howabout metadata-format: clean-0.1?

I'm hoping that we won't have to have too many 'versions' of the format, if we make it flexible enough.

cleary commented 3 years ago

I like this a lot - simple and extensible

Python means it's simple to add to and there are bindings galore

I wonder if for a first release, sample length and bpm might be something to include - there seem to be some python libraries which may assist with extracting this info: https://stackoverflow.com/questions/8635063/how-to-get-bpm-and-tempo-audio-features-in-python

yaxu commented 3 years ago

(moved from wrong issue)

Ok this:

./bin/meta.py --write --maintainer alex --email alex@slab.org --copyright "(c) 2021 Alex McLean" --sample-subfolder sounds --license cc0 example_pack

Makes this: https://github.com/tidalcycles/Clean-Samples/blob/main/example_pack/example_pack.cleanmeta

I thought giving it its own extension .cleanmeta would be a good idea rather than the generic .json, to make samples more easily searchable / discoverable.

PRs to clean up the script very welcome, I'm not really a python programmer!