34 Commits

Author SHA1 Message Date
Jamie Hardt
453606d5b7 Update __init__.py
Nudged version
2023-05-30 16:04:25 -07:00
Jamie Hardt
2ae3a69d56 Delete requirements.txt
No longer needed.
2023-05-30 15:56:53 -07:00
Jamie Hardt
14b9cbb496 Update README.md
STEINBERG metadata in readme
2023-02-26 11:48:03 -08:00
Jamie Hardt
83742cc15e Update pythonpublish.yml 2023-02-26 11:42:36 -08:00
Jamie Hardt
3c46d81302 Bumped version to 2.2.0 2023-02-26 11:35:23 -08:00
Jamie Hardt
aa4aaee396 Added Steinberg metadata to docs 2023-02-26 11:31:55 -08:00
Jamie Hardt
a78f5121a5 Merge branch 'master' of https://github.com/iluvcapra/wavinfo 2023-02-26 11:18:59 -08:00
Jamie Hardt
ea6f1d9d49 Added __short_version__ back for docs 2023-02-26 11:15:27 -08:00
Jamie Hardt
037a1f8333 Update .readthedocs.yaml
Fixing requirements for docs build
2023-02-26 11:13:46 -08:00
Jamie Hardt
f268feff40 Tweaking workflow to install dependencies 2023-02-26 11:08:19 -08:00
Jamie Hardt
8772d3eb78 Transitioned to pyproject.toml installation 2023-02-26 11:01:18 -08:00
Jamie Hardt
71936e9441 Modified setup, removed 3.12 classifier 2023-02-26 10:49:40 -08:00
Jamie Hardt
2f8f5d962b Adding alpha version 2023-02-26 10:25:16 -08:00
Jamie Hardt
071ca79d5e Adding Python 3.12 to support 2023-02-26 10:22:48 -08:00
Jamie Hardt
f7681d077b tweal 2022-12-07 20:05:49 -08:00
Jamie Hardt
fa99b9d321 Steinberg in progress 2022-12-07 20:03:34 -08:00
Jamie Hardt
75395b5922 Steinberg metadata impl in progress 2022-12-08 02:32:51 +00:00
Jamie Hardt
9be4487e21 Added nuendo notes 2022-12-07 11:50:22 -08:00
Jamie Hardt
3ff62fb345 Fixed dumb bug with stream reading 2022-12-07 10:39:10 -08:00
Jamie Hardt
4c5754a1b8 Fixed opening of streams 2022-12-07 10:07:42 -08:00
Jamie Hardt
03bf50d496 Test file management 2022-12-07 10:04:57 -08:00
Jamie Hardt
2a410cef00 Added __short_version__ field 2022-12-07 09:13:51 -08:00
Jamie Hardt
514160df87 Merge branch 'master' of https://github.com/iluvcapra/wavinfo 2022-12-02 10:32:43 -08:00
Jamie Hardt
3b0e754e7f Adding Nuendo test files 2022-12-02 10:32:23 -08:00
Jamie Hardt
62e1548031 Create CODE_OF_CONDUCT.md 2022-11-27 15:25:54 -08:00
Jamie Hardt
79cd1109b3 Update wave_bext_reader.py 2022-11-27 11:48:53 -08:00
Jamie Hardt
a5f7d574bd Update wave_info_reader.py
Fixed typo
2022-11-26 23:06:32 -08:00
Jamie Hardt
d7cafd4d5d Doc typos 2022-11-26 21:15:55 -08:00
Jamie Hardt
ec85811aaa wavfind tool 2022-11-26 21:06:46 -08:00
Jamie Hardt
ea60cb21b3 Docs 2022-11-26 20:32:41 -08:00
Jamie Hardt
16d3c47373 Docs 2022-11-26 20:30:31 -08:00
Jamie Hardt
4c9e388030 References links 2022-11-26 20:10:33 -08:00
Jamie Hardt
391a97d39a README
Made all documentation links internal.

Added reference documentation
2022-11-26 19:54:00 -08:00
Jamie Hardt
cf39d19ef2 Documentation 2022-11-26 19:33:35 -08:00
56 changed files with 543 additions and 136 deletions

View File

@@ -28,7 +28,7 @@ jobs:
run: |
python -m pip install --upgrade pip
python -m pip install flake8 pytest
if [ -f requirements.txt ]; then pip install -r requirements.txt; fi
python -m pip install -e .
- name: Setup FFmpeg
uses: FedericoCarboni/setup-ffmpeg@v2
- name: Lint with flake8

View File

@@ -16,13 +16,13 @@ jobs:
- name: Install dependencies
run: |
python -m pip install --upgrade pip
pip install setuptools wheel twine lxml
pip install setuptools build wheel twine lxml
- name: Build and publish
env:
TWINE_USERNAME: __token__
TWINE_PASSWORD: ${{ secrets.PYPI_APIKEY }}
run: |
python setup.py sdist bdist_wheel
python -m build .
twine upload dist/*
- name: Report to Mastodon
uses: cbrgm/mastodon-github-action@v1.0.1

View File

@@ -25,5 +25,8 @@ formats:
#Optionally declare the Python requirements required to build your docs
python:
install:
- requirements: requirements.txt
install:
- method: pip
path: .
extra_requirements:
- docs

128
CODE_OF_CONDUCT.md Normal file
View File

@@ -0,0 +1,128 @@
# Contributor Covenant Code of Conduct
## Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
nationality, personal appearance, race, religion, or sexual identity
and orientation.
We pledge to act and interact in ways that contribute to an open, welcoming,
diverse, inclusive, and healthy community.
## Our Standards
Examples of behavior that contributes to a positive environment for our
community include:
* Demonstrating empathy and kindness toward other people
* Being respectful of differing opinions, viewpoints, and experiences
* Giving and gracefully accepting constructive feedback
* Accepting responsibility and apologizing to those affected by our mistakes,
and learning from the experience
* Focusing on what is best not just for us as individuals, but for the
overall community
Examples of unacceptable behavior include:
* The use of sexualized language or imagery, and sexual attention or
advances of any kind
* Trolling, insulting or derogatory comments, and personal or political attacks
* Public or private harassment
* Publishing others' private information, such as a physical or email
address, without their explicit permission
* Other conduct which could reasonably be considered inappropriate in a
professional setting
## Enforcement Responsibilities
Community leaders are responsible for clarifying and enforcing our standards of
acceptable behavior and will take appropriate and fair corrective action in
response to any behavior that they deem inappropriate, threatening, offensive,
or harmful.
Community leaders have the right and responsibility to remove, edit, or reject
comments, commits, code, wiki edits, issues, and other contributions that are
not aligned to this Code of Conduct, and will communicate reasons for moderation
decisions when appropriate.
## Scope
This Code of Conduct applies within all community spaces, and also applies when
an individual is officially representing the community in public spaces.
Examples of representing our community include using an official e-mail address,
posting via an official social media account, or acting as an appointed
representative at an online or offline event.
## Enforcement
Instances of abusive, harassing, or otherwise unacceptable behavior may be
reported to the community leaders responsible for enforcement at
[the GitHub Issues Tab](https://github.com/iluvcapra/wavinfo/issues).
All complaints will be reviewed and investigated promptly and fairly.
All community leaders are obligated to respect the privacy and security of the
reporter of any incident.
## Enforcement Guidelines
Community leaders will follow these Community Impact Guidelines in determining
the consequences for any action they deem in violation of this Code of Conduct:
### 1. Correction
**Community Impact**: Use of inappropriate language or other behavior deemed
unprofessional or unwelcome in the community.
**Consequence**: A private, written warning from community leaders, providing
clarity around the nature of the violation and an explanation of why the
behavior was inappropriate. A public apology may be requested.
### 2. Warning
**Community Impact**: A violation through a single incident or series
of actions.
**Consequence**: A warning with consequences for continued behavior. No
interaction with the people involved, including unsolicited interaction with
those enforcing the Code of Conduct, for a specified period of time. This
includes avoiding interactions in community spaces as well as external channels
like social media. Violating these terms may lead to a temporary or
permanent ban.
### 3. Temporary Ban
**Community Impact**: A serious violation of community standards, including
sustained inappropriate behavior.
**Consequence**: A temporary ban from any sort of interaction or public
communication with the community for a specified period of time. No public or
private interaction with the people involved, including unsolicited interaction
with those enforcing the Code of Conduct, is allowed during this period.
Violating these terms may lead to a permanent ban.
### 4. Permanent Ban
**Community Impact**: Demonstrating a pattern of violation of community
standards, including sustained inappropriate behavior, harassment of an
individual, or aggression toward or disparagement of classes of individuals.
**Consequence**: A permanent ban from any sort of public interaction within
the community.
## Attribution
This Code of Conduct is adapted from the [Contributor Covenant][homepage],
version 2.0, available at
https://www.contributor-covenant.org/version/2/0/code_of_conduct.html.
Community Impact Guidelines were inspired by [Mozilla's code of conduct
enforcement ladder](https://github.com/mozilla/diversity).
[homepage]: https://www.contributor-covenant.org
For answers to common questions about this code of conduct, see the FAQ at
https://www.contributor-covenant.org/faq. Translations are available at
https://www.contributor-covenant.org/translations.

View File

@@ -10,27 +10,28 @@ The `wavinfo` package allows you to probe WAVE and [RF64/WAVE files][eburf64] an
`wavinfo` reads:
* [__Broadcast-WAVE__][ebu] metadata, including embedded program
loudness, coding history and [__SMPTE UMID__][smpte_330m2011].
* [__ADM__][adm] track metadata and schema, including channel, pack formats, object, content and programme.
* [__Dolby Digital Plus__][ebu3285s6] and Dolby Atmos `dbmd` metadata.
* [__iXML__][ixml] production recorder metadata, including project, scene, and take tags, recorder notes
* [Broadcast-WAVE][bext] metadata, including embedded program
loudness, coding history and [SMPTE UMID][smpte_330m2011].
* [ADM][adm] track metadata and schema, including channel, pack formats, object, content and programme.
* [Dolby Digital Plus][ebu3285s6] and Dolby Atmos `dbmd` metadata.
* [iXML][ixml] production recorder metadata, including project, scene, and take tags, recorder notes
and file family information.
* Most of the common [__RIFF INFO__][info-tags] metadata fields.
* iXML `STEINBERG` sound library attributes.
* Most of the common [RIFF INFO][info-tags] metadata fields.
* The __wav format__ is also parsed, so you can access the basic sample rate and channel count
information.
In progress:
* Pro Tools __embedded regions__.
* iXML `STEINBERG` sound library attributes.
[ebu]:https://tech.ebu.ch/docs/tech/tech3285.pdf
[ebu3285s6]:https://tech.ebu.ch/docs/tech/tech3285s6.pdf
[adm]:https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2076-2-201910-I!!PDF-E.pdf
[smpte_330m2011]:http://standards.smpte.org/content/978-1-61482-678-1/st-330-2011/SEC1.abstract
[ixml]:http://www.ixml.info
[bext]:https://wavinfo.readthedocs.io/en/latest/scopes/bext.html
[smpte_330m2011]:https://wavinfo.readthedocs.io/en/latest/scopes/bext.html#wavinfo.wave_bext_reader.WavBextReader.umid
[adm]:https://wavinfo.readthedocs.io/en/latest/scopes/adm.html
[ebu3285s6]:https://wavinfo.readthedocs.io/en/latest/scopes/dolby.html
[ixml]:https://wavinfo.readthedocs.io/en/latest/scopes/ixml.html
[info-tags]:https://wavinfo.readthedocs.io/en/latest/scopes/info.html
[eburf64]:https://tech.ebu.ch/docs/tech/tech3306v1_1.pdf
[info-tags]:https://exiftool.org/TagNames/RIFF.html#Info
## How To Use

View File

@@ -1,25 +0,0 @@
alabaster==0.7.12
Babel==2.11.0
certifi==2022.9.24
charset-normalizer==2.1.1
docutils==0.17.1
idna==3.4
imagesize==1.4.1
Jinja2==3.1.2
lxml==4.9.1
MarkupSafe==2.1.1
packaging==21.3
Pygments==2.13.0
pyparsing==3.0.9
pytz==2022.6
requests==2.28.1
snowballstemmer==2.2.0
Sphinx==5.3.0
sphinx-rtd-theme==1.1.1
sphinxcontrib-applehelp==1.0.2
sphinxcontrib-devhelp==1.0.2
sphinxcontrib-htmlhelp==2.0.0
sphinxcontrib-jsmath==1.0.1
sphinxcontrib-qthelp==1.0.3
sphinxcontrib-serializinghtml==1.1.5
urllib3==1.26.12

View File

@@ -27,7 +27,7 @@ copyright = u'2022, Jamie Hardt'
author = u'Jamie Hardt'
# The short X.Y version
version = wavinfo.__version__
version = wavinfo.__short_version__
# The full version, including alpha/beta/rc tags
release = wavinfo.__version__

View File

@@ -19,8 +19,8 @@ music production metadata.
quickstart
command_line
scopes/*
classes
references
Indices and tables

View File

@@ -14,7 +14,10 @@ instance of :class:`WaveInfoReader`.
path = 'path/to/your/wave/audio.wav'
info = wavinfo.WavInfoReader(path)
adm_metadata = info.adm
ixml_metadata = info.ixml
.. module:: wavinfo
:noindex:

View File

@@ -0,0 +1,39 @@
References
==========
Wave File Format
----------------
* `ITU Recommendation BS.2088-1-2019 — Long-form file format for the international exchange of audio programme materials with metadata <https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2088-1-201910-I!!PDF-E.pdf>`_
* `IETF Network Working Group RFC2361 — WAVE and AVI Codec Registries <https://www.rfc-editor.org/rfc/rfc2361>`_
Broadcast Wave Format
---------------------
* `EBU Tech 3285 — Specification of the Broadcast Wave Format (BWF) <https://tech.ebu.ch/docs/tech/tech3285.pdf>`_
* `EBU Tech 3306 — MBWF / RF64: An extended File Format for Audio <https://tech.ebu.ch/docs/tech/tech3306v1_1.pdf>`_
* `SMPTE ST 330-2011 — Unique Material Identifier <https://ieeexplore.ieee.org/document/9787389>`_
Audio Definition Model
----------------------
* `ITU Recommendation BS.2076-2-2019 — Audio definition model <https://www.itu.int/dms_pubrec/itu-r/rec/bs/R-REC-BS.2076-2-201910-I!!PDF-E.pdf>`_
* `EBU Tech 3285 Supplement 5 — <axml> Chunk <https://tech.ebu.ch/docs/tech/tech3285s5.pdf>`_
* `EBU ADM Guidelines <https://adm.ebu.io>`_
Dolby
-----
* `EBU Tech 3285 Supplement 6 — Dolby Metadata <https://tech.ebu.ch/docs/tech/tech3285s6.pdf>`_
* `Dolby Laboratories Atmos ADM Profile <https://developer.dolby.com/globalassets/documentation/technology/dolby_atmos_master_adm_profile_v1.0.pdf>`_
iXML
----
* `Gallery Software iXML Specification <http://www.gallery.co.uk/ixml/>`_
RIFF INFO
---------
* `Exiftool Documentation <https://exiftool.org/TagNames/RIFF.html#Info_docs>`_

View File

@@ -40,4 +40,9 @@ Class Reference
.. autoclass:: wavinfo.wave_ixml_reader.WavIXMLFormat
:members:
Steinberg-Specific iXML Metadata
--------------------------------
.. autoclass:: wavinfo.wave_ixml_reader.SteinbergMetadata
:members:

70
pyproject.toml Normal file
View File

@@ -0,0 +1,70 @@
[build-system]
requires = ["flit_core >=3.2,<4"]
build-backend = "flit_core.buildapi"
[project]
name = "wavinfo"
authors = [{name = "Jamie Hardt", email = "jamiehardt@me.com"}]
readme = "README.md"
dynamic = ["version", "description"]
requires-python = "~=3.8"
classifiers = [
'Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Topic :: Multimedia',
'Topic :: Multimedia :: Sound/Audio',
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"
]
dependencies = [
"lxml ~= 4.9.2"
]
keywords = [
'waveform',
'metadata',
'audio',
'ebu',
'smpte',
'avi',
'library',
'film',
'broadcast'
]
[tool.flit.module]
name = "wavinfo"
[project.optional-dependencies]
doc = [
'sphinx >= 5.3.0',
'sphinx_rtd_theme >= 1.1.1',
]
[project.urls]
Home = "https://github.com/iluvcapra/wavinfo"
Documentation = "https://wavinfo.readthedocs.io/"
Source = "https://github.com/iluvcapra/wavinfo.git"
Issues = 'https://github.com/iluvcapra/wavinfo/issues'
[project.entry_points.console_scripts]
wavinfo = 'wavinfo.__main__:main'
[project.scripts]
wavinfo = "wavinfo.__main__:main"
[tool.pyright]
typeCheckingMode = "basic"
[tool.pylint]
max-line-length = 88
disable = [
"C0103", # (invalid-name)
"C0114", # (missing-module-docstring)
"C0115", # (missing-class-docstring)
"C0116", # (missing-function-docstring)
"R0903", # (too-few-public-methods)
"R0913", # (too-many-arguments)
"W0105", # (pointless-string-statement)
]

View File

@@ -1 +0,0 @@
lxml==4.9.1

View File

@@ -1,40 +0,0 @@
from setuptools import setup
from wavinfo import __author__, __license__, __version__
with open("README.md", "r") as fh:
long_description = fh.read()
setup(name='wavinfo',
version=__version__,
author=__author__,
author_email='jamiehardt@me.com',
description='Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.',
long_description_content_type="text/markdown",
long_description=long_description,
license=__license__,
url='https://github.com/iluvcapra/wavinfo',
project_urls={
'Source':
'https://github.com/iluvcapra/wavinfo',
'Documentation':
'https://wavinfo.readthedocs.io/',
'Issues':
'https://github.com/iluvcapra/wavinfo/issues',
},
packages=['wavinfo'],
classifiers=['Development Status :: 5 - Production/Stable',
'License :: OSI Approved :: MIT License',
'Topic :: Multimedia',
'Topic :: Multimedia :: Sound/Audio',
"Programming Language :: Python :: 3.8",
"Programming Language :: Python :: 3.9",
"Programming Language :: Python :: 3.10",
"Programming Language :: Python :: 3.11"],
keywords='waveform metadata audio ebu smpte avi library film tv editing editorial',
install_requires=['lxml'],
entry_points={
'console_scripts': [
'wavinfo = wavinfo.__main__:main'
]
}
)

View File

@@ -1,3 +1,44 @@
from . import test_wave_parsing
from io import BytesIO
from typing import Generator
import zipfile as zf
import os.path
import os
from contextlib import contextmanager
# class TestFileLoader:
# """
# This guy manages the test_files archive.
# """
# def __init__(self, test_file_arch_name = 'archive.zip') -> None:
# self.base_path = os.path.join(os.path.dirname(__file__), "test_files")
# self.test_file_arch_name = test_file_arch_name
# self._gather_test_files_into_archive()
# @property
# def arch_path(self):
# return os.path.join(self.base_path, self.test_file_arch_name)
# @contextmanager
# def open(self, name) -> Generator[BytesIO]:
# z = zf.ZipFile(self.arch_path, 'r')
# member = z.open(name, 'r')
# try:
# yield member
# finally:
# zf.close()
# def _gather_test_files_into_archive(self):
# with zf.ZipFile(self.arch_path, 'a') as zip:
# for root, _, files in os.walk(self.base_path):
# for name in files:
# if root == self.base_path and name == self.test_file_arch_name:
# continue
# else:
# p = os.path.join(root, name)
# zip.write(p)
# os.unlink(p)

View File

@@ -1,12 +1,9 @@
"""
methods to probe a WAV file for various kinds of production metadata.
See the documentation for `wavinfo.WavInfoReader` for more information.
Probe WAVE Files for iXML, Broadcast-WAVE and other metadata.
"""
from .wave_reader import WavInfoReader
from .riff_parser import WavInfoEOFError
__version__ = '2.1.0'
__author__ = 'Jamie Hardt <jamiehardt@gmail.com>'
__license__ = "MIT"
__version__ = '2.2.1'
__short_version__ = '2.2.1'

View File

@@ -19,7 +19,7 @@ class MissingDataError(RuntimeError):
def main():
parser = OptionParser()
parser.usage = 'wavinfo (--adm | --ixml) [FILES]'
parser.usage = 'wavinfo (--adm | --ixml) <FILE> +'
# parser.add_option('-f', dest='output_format', help='Set the output format',
# default='json',
@@ -42,7 +42,7 @@ def main():
raise MissingDataError("adm")
elif options.ixml:
if this_file.ixml:
sys.stdout.write(this_file.ixml.xml_bytes())
sys.stdout.write(this_file.ixml.xml_str())
else:
raise MissingDataError("ixml")
else:

View File

@@ -53,7 +53,7 @@ class WavADMReader:
def programme(self) -> dict:
"""
Extract the ADM audioProgramme data structure and some of its reference properties
Read the ADM `audioProgramme` data structure and some of its reference properties.
"""
ret_dict = dict()
@@ -95,7 +95,7 @@ class WavADMReader:
return ret_dict
def track_info(self, index):
def track_info(self, index) -> dict:
"""
Information about a track in the WAV file.
@@ -151,7 +151,7 @@ class WavADMReader:
return ret_dict
def to_dict(self):
def to_dict(self) -> dict: #FIXME should be "asdict"
"""
Get ADM metadata as a dictionary.
"""

View File

@@ -25,34 +25,47 @@ class WavBextReader:
#: Description. A free-text field up to 256 characters long.
self.description : str = sanitize_bytes(unpacked[0])
#: Originator. Usually the name of the encoding application, sometimes
#: a artist name.
#: an artist name.
self.originator : str = sanitize_bytes(unpacked[1])
#: A unique identifier for the file, a serial number.
self.originator_ref : str = sanitize_bytes(unpacked[2])
#: Date of the recording, in the format YYYY-MM-DD in the local calendar
#: Date of the recording, in the format YYYY-MM-DD.
self.originator_date : str = sanitize_bytes(unpacked[3])
#: Time of the recording, in the format HH:MM:SS on the local clock
#: Time of the recording, in the format HH:MM:SS.
self.originator_time : str = sanitize_bytes(unpacked[4])
#: The sample offset of the start of the file relative to an
#: epoch, usually midnight the day of the recording.
#: The sample offset of the start, usually relative
#: to midnight.
self.time_reference : int = unpacked[5]
#: A variable-length text field containing a list of processes and
#: and conversions performed on the file.
self.coding_history : str = sanitize_bytes(bext_data[rest_starts:])
#: BEXT version.
self.version : int = unpacked[6]
#: SMPTE 330M UMID of this audio file, 64 bytes are allocated though the UMID
#: may only be 32 bytes long.
self.umid : Optional[bytes] = None
#: EBU R128 Integrated loudness, in LUFS.
self.loudness_value : Optional[float] = None
#: EBU R128 Loudness rante, in LUFS.
#: EBU R128 Loudness range, in LUFS.
self.loudness_range : Optional[float] = None
#: True peak level, in dBFS TP
self.max_true_peak : Optional[float] = None
#: EBU R128 Maximum momentary loudness, in LUFS
self.max_momentary_loudness : Optional[float] = None
#: EBU R128 Maximum short-term loudness, in LUFS.
self.max_shortterm_loudness : Optional[float] = None

View File

@@ -598,7 +598,7 @@ class WavDolbyMetadataReader:
return retval
def __init__(self, dbmd_data) -> None:
def __init__(self, dbmd_data):
self.segment_list = []
h = BytesIO(dbmd_data)

View File

@@ -21,7 +21,7 @@ class WavInfoChunkReader:
self.album : Optional[str] = self.product
#: 'IGNR' Genre
self.genre : Optional[str] = self._get_field(f, b'IGNR')
#: 'ISBJ' Supject
#: 'ISBJ' Subject
self.subject : Optional[str] = self._get_field(f, b'ISBJ')
#: 'IART' Artist, composer, author
self.artist : Optional[str] = self._get_field(f, b'IART')
@@ -59,7 +59,7 @@ class WavInfoChunkReader:
else:
return None
def to_dict(self):
def to_dict(self) -> dict: #FIXME should be asdict
"""
A dictionary with all of the key/values read from the INFO scope.
"""

View File

@@ -2,10 +2,139 @@ from lxml import etree as ET
import io
from collections import namedtuple
from typing import Optional
from enum import IntEnum
IXMLTrack = namedtuple('IXMLTrack', ['channel_index', 'interleave_index', 'name', 'function'])
class SteinbergMetadata:
"""
Vendor-specific Steinberg metadata.
"""
class AudioSpeakerArrangement(IntEnum):
"""
Steinberg speaker format enumeration.
"""
MONO = 0
STEREO = 1
LRC = 10
LRCS = 14
QUAD = 15
CINE_50 = 18
CINE_51 = 19
CINE_60 = 20
CINE_61 = 22
CINE_70 = 25
CINE_71 = 27
SDDS_70 = 24
SDDS_71 = 26
MUSIC_60 = 21 #??
MUSIC_61 = 23
ATMOS_712 = 33
ATMOS_504 = 35
ATMOS_514 = 36
ATMOS_714 = 44
ATMOS_702 = 48
ATMOS_716 = 51
ATMOS_914 = 53
ATMOS_916 = 55
AMB_1ORDER = 45
AMB_2ORDER = 46
AMB_3ORDER = 47
AURO_10_0 = 37
AURO_10_1 = 38
AURO_11_0 = 39
AURO_11_1 = 40
AURO_13_0 = 41
AURO_13_1 = 42
Steinberg_xpath = "//BWFXML/STEINBERG"
@classmethod
def present(cls, xml: ET.ElementTree) -> bool:
"""
Test if `xml` has Steinberg metadata.
:param xml: an iXML ElementTree
"""
x = xml.find(cls.Steinberg_xpath)
return len(x) > 0
def __init__(self, xml: ET.ElementTree) -> None:
"""
Parse Steinberg iXML data.
:param xml: The entire iXML Tree
"""
self.parsed = xml.find("//BWFXML/STEINBERG")
@property
def audio_speaker_arrangement(self) -> Optional[AudioSpeakerArrangement]:
"""
`AudioSpeakerArrangement` property
"""
val = self.parsed.find("./ATTR_LIST/ATTR[NAME/text() = 'AudioSpeakerArrangement']/VALUE/text()")
if len(val) > 0:
return type(self).AudioSpeakerArrangement(int(val[0]))
else:
return None
@property
def sample_format_size(self) -> Optional[int]:
"""
AudioSampleFormatSize
"""
pass
@property
def media_company(self) -> Optional[str]:
"""
MediaCompany
"""
pass
@property
def media_drop_frames(self) -> Optional[bool]:
"""
MediaDropFrames
"""
pass
@property
def media_duration(self) -> Optional[float]:
"""
MediaDuration
"""
pass
@property
def media_start_time(self) -> Optional[float]:
"""
MediaStartTime
"""
pass
@property
def media_track_title(self) -> Optional[str]:
"""
MediaTrackTitle
"""
pass
@property
def program_name(self) -> Optional[str]:
"""
ProgramName
"""
pass
@property
def program_version(self) -> Optional[str]:
"""
ProgramVersion
"""
pass
class WavIXMLFormat:
"""
iXML recorder metadata.
@@ -18,7 +147,7 @@ class WavIXMLFormat:
self.source = xml
xml_bytes = io.BytesIO(xml)
parser = ET.XMLParser(recover=True)
self.parsed = ET.parse(xml_bytes, parser=parser)
self.parsed : ET.ElementTree = ET.parse(xml_bytes, parser=parser)
def _get_text_value(self, xpath) -> Optional[str]:
e = self.parsed.find("./" + xpath)
@@ -27,11 +156,11 @@ class WavIXMLFormat:
else:
return None
def xml_bytes(self):
def xml_str(self) -> str:
return ET.tostring(self.parsed).decode("utf-8")
@property
def raw_xml(self):
def raw_xml(self) -> ET.ElementTree:
"""
The root entity of the iXML document.
"""
@@ -41,7 +170,8 @@ class WavIXMLFormat:
def track_list(self):
"""
A description of each track.
:returns: An Iterator
:yields: `IXMLTrack` for each track.
"""
for track in self.parsed.find("./TRACK_LIST").iter():
if track.tag == 'TRACK':
@@ -93,6 +223,16 @@ class WavIXMLFormat:
"""
return self._get_text_value("FILE_SET/FAMILY_NAME")
@property
def steinberg(self) -> Optional[SteinbergMetadata]:
"""
Steinberg vendor iXML metadata if present.
"""
if SteinbergMetadata.present(self.raw_xml):
return SteinbergMetadata(self.raw_xml)
else:
return None
def to_dict(self):
return dict(track_list=list(map(lambda x: x._asdict(), self.track_list)),
project=self.project,

View File

@@ -34,7 +34,7 @@ class WavInfoReader:
Create a new reader object.
:param path:
A filesystem path to the wav file you wish to probe or a
A pathlike object or IO to the wav file you wish to probe or a
file handle to an open file.
:param info_encoding:
@@ -45,17 +45,37 @@ class WavInfoReader:
The text encoding to use when decoding the string
fields of the Broadcast-WAV extension. Per EBU 3285 this is ASCII
but this parameter is available to you if you encounter a weirdo.
"""
self.info_encoding = info_encoding
self.bext_encoding = bext_encoding
#: Wave audio data format.
self.fmt :Optional[WavAudioFormat] = None
#: Statistics of the `data` section.
self.data :Optional[WavDataDescriptor] = None
#: Broadcast-Wave metadata.
self.bext :Optional[WavBextReader] = None
#: iXML metadata.
self.ixml :Optional[WavIXMLFormat] = None
#: ADM Audio Definiton Model metadata.
self.adm :Optional[WavADMReader]= None
#: Dolby bitstream metadata.
self.dolby :Optional[WavDolbyMetadataReader] = None
#: RIFF INFO metadata.
self.info :Optional[WavInfoChunkReader]= None
if hasattr(path, 'read'):
self.get_wav_info(path)
self.url = 'about:blank'
self.path = repr(path)
else:
absolute_path = os.path.abspath(path)
@@ -63,28 +83,7 @@ class WavInfoReader:
self.url: pathlib.Path = pathlib.Path(absolute_path).as_uri()
self.path = absolute_path
#: Wave audio data format.
self.fmt :Optional[WavAudioFormat] = None
#: Statistics of the `data` section.
self.data :Optional[WavDataDescriptor] = None
#: Broadcast-Wave metadata.
self.bext :Optional[WavBextReader] = None
#: iXML metadata.
self.ixml :Optional[WavIXMLFormat] = None
#: ADM Audio Definiton Model metadata.
self.adm :Optional[WavADMReader]= None
#: Dolby bitstream metadata.
self.dolby :Optional[WavDolbyMetadataReader] = None
#: RIFF INFO metadata.
self.info :Optional[WavInfoChunkReader]= None
with open(path, 'rb') as f:
self.get_wav_info(f)

34
wavinfo/wavfind.py Normal file
View File

@@ -0,0 +1,34 @@
"""
"""
from optparse import OptionParser, OptionGroup
import sys
def main():
parser = OptionParser()
parser.usage = "wavfind [--scene=SCENE] [--take=TAKE] [--desc=DESC] <PATH> +"
primaries = OptionGroup(parser, title="Search Predicates",
description="Argument values can be globs, and are logically-AND'ed.")
primaries.add_option("--scene",
help='Search for this scene',
metavar='SCENE')
primaries.add_option("--take",
help='Search for this take',
metavar='TAKE')
primaries.add_option("--desc",
help='Search descriptions',
metavar='DESC')
(options, args) = parser.parse_args(sys.argv)
if __name__ == "__main__":
main()