"""
Helper functions to interface with puredata
"""
from __future__ import annotations
from typing import TYPE_CHECKING
if TYPE_CHECKING:
    from typing import *
import struct


def timidGetInfo(path: str) -> Tuple[int, int]:
    """
    Get information about .timid files generated by timbreID

    Returns a subdivision (number-of-templates, feature-length-of-each-template)
    """
    f = open(path, 'rb')
    numtemplates, feature_length = f.read(4), f.read(4)  
    numtemplates = struct.unpack("l", numtemplates)[0]
    feature_length = struct.unpack("l", feature_length)[0]
    return numtemplates, feature_length

