mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
Another test file, more jupyter experiments
This commit is contained in:
@@ -148,6 +148,58 @@
|
|||||||
"print(ptinfo.bext)"
|
"print(ptinfo.bext)"
|
||||||
]
|
]
|
||||||
},
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 17,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"data": {
|
||||||
|
"text/plain": [
|
||||||
|
"'<BWFXML><IXML_VERSION>1.61</IXML_VERSION><STEINBERG><ATTR_LIST><ATTR><TYPE>string</TYPE><NAME>MediaLibrary</NAME><VALUE>The Recordist Christmas 2018</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MediaCategoryPost</NAME><VALUE>Bullets</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MediaLibraryManufacturerName</NAME><VALUE>Creative Sound Design, LLC</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>AudioSoundEditor</NAME><VALUE>Frank Bry</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MediaComment</NAME><VALUE>BULLET Impact Plastic LCD TV Screen Shatter Debris 2x</VALUE></ATTR><ATTR><TYPE>string</TYPE><NAME>MusicalCategory</NAME><VALUE>Bullets</VALUE></ATTR></ATTR_LIST></STEINBERG></BWFXML>'"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"execution_count": 17,
|
||||||
|
"metadata": {},
|
||||||
|
"output_type": "execute_result"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"library_sound = testfile_path + 'BULLET Impact Plastic LCD TV Screen Shatter Debris 2x.wav'\n",
|
||||||
|
"\n",
|
||||||
|
"recinfo = wavinfo.WavInfoReader(library_sound)\n",
|
||||||
|
"\n",
|
||||||
|
"recinfo.ixml.source"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"cell_type": "code",
|
||||||
|
"execution_count": 18,
|
||||||
|
"metadata": {},
|
||||||
|
"outputs": [
|
||||||
|
{
|
||||||
|
"name": "stdout",
|
||||||
|
"output_type": "stream",
|
||||||
|
"text": [
|
||||||
|
"[ ChunkDescriptor(ident=b'fmt ', start=20, length=40),\n",
|
||||||
|
" ChunkDescriptor(ident=b'bext', start=68, length=604),\n",
|
||||||
|
" ChunkDescriptor(ident=b'data', start=680, length=2833404),\n",
|
||||||
|
" ChunkDescriptor(ident=b'ID3 ', start=2834092, length=2048),\n",
|
||||||
|
" ChunkDescriptor(ident=b'SMED', start=2836148, length=5468),\n",
|
||||||
|
" ListChunkDescriptor(signature=b'INFO', children=[ChunkDescriptor(ident=b'IPRD', start=2841636, length=30), ChunkDescriptor(ident=b'IGNR', start=2841674, length=8), ChunkDescriptor(ident=b'IART', start=2841690, length=10), ChunkDescriptor(ident=b'ICMT', start=2841708, length=54), ChunkDescriptor(ident=b'ICOP', start=2841770, length=84), ChunkDescriptor(ident=b'ISFT', start=2841862, length=12), ChunkDescriptor(ident=b'ICRD', start=2841882, length=12)]),\n",
|
||||||
|
" ChunkDescriptor(ident=b'iXML', start=2841902, length=686),\n",
|
||||||
|
" ChunkDescriptor(ident=b'umid', start=2842596, length=24),\n",
|
||||||
|
" ChunkDescriptor(ident=b'_PMX', start=2842628, length=3560)]\n"
|
||||||
|
]
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"source": [
|
||||||
|
"with open(library_sound,'rb') as f:\n",
|
||||||
|
" chunk_tree = wavinfo.wave_parser.parse_chunk(f)\n",
|
||||||
|
"\n",
|
||||||
|
"pp.pprint(chunk_tree.children)"
|
||||||
|
]
|
||||||
|
},
|
||||||
{
|
{
|
||||||
"cell_type": "code",
|
"cell_type": "code",
|
||||||
"execution_count": null,
|
"execution_count": null,
|
||||||
|
|||||||
Binary file not shown.
@@ -3,9 +3,9 @@ import struct
|
|||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
ListChunkDescriptor = namedtuple('ListChunk' , 'signature children')
|
ListChunkDescriptor = namedtuple('ListChunkDescriptor' , 'signature children')
|
||||||
|
|
||||||
class ChunkDescriptor(namedtuple('Chunk', 'ident start length') ):
|
class ChunkDescriptor(namedtuple('ChunkDescriptor', 'ident start length') ):
|
||||||
def read_data(self, from_stream):
|
def read_data(self, from_stream):
|
||||||
from_stream.seek(self.start)
|
from_stream.seek(self.start)
|
||||||
return from_stream.read(self.length)
|
return from_stream.read(self.length)
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ import struct
|
|||||||
|
|
||||||
from collections import namedtuple
|
from collections import namedtuple
|
||||||
|
|
||||||
from .wave_parser import parse_chunk
|
from .wave_parser import parse_chunk, ChunkDescriptor, ListChunkDescriptor
|
||||||
from .wave_ixml_reader import WavIXMLFormat
|
from .wave_ixml_reader import WavIXMLFormat
|
||||||
|
|
||||||
WavDataDescriptor = namedtuple('WavDataDescriptor','byte_count frame_count')
|
WavDataDescriptor = namedtuple('WavDataDescriptor','byte_count frame_count')
|
||||||
@@ -37,10 +37,12 @@ class WavInfoReader():
|
|||||||
|
|
||||||
def _find_chunk_data(self, ident, from_stream, default_none=False):
|
def _find_chunk_data(self, ident, from_stream, default_none=False):
|
||||||
chunk_descriptor = None
|
chunk_descriptor = None
|
||||||
|
top_chunks = (chunk for chunk in self.main_list if type(chunk) is ChunkDescriptor)
|
||||||
|
|
||||||
if default_none:
|
if default_none:
|
||||||
chunk_descriptor =next((chunk for chunk in self.main_list if chunk.ident == ident),None)
|
chunk_descriptor = next((chunk for chunk in top_chunks if chunk.ident == ident),None)
|
||||||
else:
|
else:
|
||||||
chunk_descriptor = next((chunk for chunk in self.main_list if chunk.ident == ident))
|
chunk_descriptor = next((chunk for chunk in top_chunks if chunk.ident == ident))
|
||||||
|
|
||||||
if chunk_descriptor:
|
if chunk_descriptor:
|
||||||
return chunk_descriptor.read_data(from_stream)
|
return chunk_descriptor.read_data(from_stream)
|
||||||
|
|||||||
Reference in New Issue
Block a user