mirror of
https://github.com/iluvcapra/wavinfo.git
synced 2025-12-31 08:50:41 +00:00
Get timed ranges
This commit is contained in:
@@ -28,6 +28,14 @@ class TestCue(TestCase):
|
||||
self.assertEqual("Marker 1", label)
|
||||
self.assertIsNone(note)
|
||||
|
||||
def test_range(self):
|
||||
file = "tests/test_files/cue_chunks/izotoperx_cues_test.wav"
|
||||
w1 = wavinfo.WavInfoReader(file)
|
||||
self.assertIsNotNone(w1.cues)
|
||||
assert w1.cues is not None
|
||||
|
||||
self.assertEqual(w1.cues.range(3), 10000)
|
||||
|
||||
def test_encoding_fallback(self):
|
||||
"""
|
||||
Added this after I noticed that iZotope RX seems to just encode "notes"
|
||||
|
||||
@@ -221,18 +221,31 @@ class WavCuesReader:
|
||||
for cue in self.cues:
|
||||
yield (cue.name, cue.sample_offset)
|
||||
|
||||
def label_and_note(self, cue_ident: int) -> Tuple[Optional[str], Optional[str]]:
|
||||
def label_and_note(self, cue_ident: int) -> Tuple[Optional[str],
|
||||
Optional[str]]:
|
||||
"""
|
||||
Get the label and note (extended comment) for a cue.
|
||||
|
||||
:param cue_ident: the cue's name, it's unique identifying number
|
||||
:param cue_ident: the cue's name, its unique identifying number
|
||||
:returns: a tuple of the the cue's label (if present) and note (if
|
||||
present)
|
||||
"""
|
||||
label = next((l.text for l in self.labels if l.name == cue_ident), None)
|
||||
note = next((n.text for n in self.notes if n.name == cue_ident), None)
|
||||
label = next((l.text for l in self.labels
|
||||
if l.name == cue_ident), None)
|
||||
note = next((n.text for n in self.notes
|
||||
if n.name == cue_ident), None)
|
||||
return (label, note)
|
||||
|
||||
def range(self, cue_ident: int) -> Optional[int]:
|
||||
"""
|
||||
Get the length of the time range for a cue, if it has one.
|
||||
|
||||
:param cue_ident: the cue's name, its unique identifying number
|
||||
:returns: the length of the marker's range, or `None`
|
||||
"""
|
||||
return next((r.length for r in self.ranges
|
||||
if r.name == cue_ident), None)
|
||||
|
||||
def to_dict(self) -> Dict[str, Any]:
|
||||
return dict(cues=[c.__dict__ for c in self.cues],
|
||||
labels=[l.__dict__ for l in self.labels],
|
||||
|
||||
Reference in New Issue
Block a user