pytimbre.spectral.spectral_frame_builder.FrameBuilder

class pytimbre.spectral.spectral_frame_builder.FrameBuilder(fs: float = 48000, overlap_pct: float = 0, frame_width_sec: float = 0.25, data_length: int = 48000)

Bases: object

This class provides a method to store the start and stop samples/times for the Waveform.trim function. It overwrites the ability to create the subset of the waveform that is passed to the Spectrum object for the creation of the frequency spectrum.

__init__(fs: float = 48000, overlap_pct: float = 0, frame_width_sec: float = 0.25, data_length: int = 48000)

This function creates the new windowing function to create the subsets of the Waveform with specific increments in the representation. The function is used within the TimeHistory classes to create the subset of audio that is passed to the Spectrum object. The length of the subset is defined by the frame_width_sec as a duration in seconds. The amount of time that we increment the start time is defined by the relationship between the frame width and the overlap. :param fs: the sample rate of the waveform :type fs: float :param overlap_pct: the amount of the frame length that we want the next frame to overlap the current frame :type overlap_pct: float :param frame_width_sec: the width of the frame in seconds :type frame_width_sec: float :param data_length: The number of samples in the waveform :type data_length: int

Methods

__init__([fs, overlap_pct, frame_width_sec, ...])

This function creates the new windowing function to create the subsets of the Waveform with specific increments in the representation.

from_waveform(wfm[, overlap_pct, ...])

get_next_waveform_subset(wfm)

This function takes the current starting and ending samples, increments them by the appropriate amount and returns the next subset of the waveform. It also increments the internal representation of the start and stop samples. :return: A new waveform that is the next increment in the waveform. :rtype: Waveform.

Attributes

complete_frame_count

This will determine the number of complete frames (all samples within the frame are filled from the original waveform).

duration

excess_duration

This is the amount of time that will contain only partial frames :return: :rtype: float

frame_length_samples

frame_length_seconds

overlap_percentage

overlap_samples

sample_increment

sample_rate

start_sample

stop_sample

time_increment

property complete_frame_count

This will determine the number of complete frames (all samples within the frame are filled from the original waveform). :return: the number of complete frames :rtype: int

property excess_duration

This is the amount of time that will contain only partial frames :return: :rtype: float

get_next_waveform_subset(wfm: Waveform)

This function takes the current starting and ending samples, increments them by the appropriate amount and returns the next subset of the waveform. It also increments the internal representation of the start and stop samples. :return:

A new waveform that is the next increment in the waveform.

Return type:

Waveform