hum.lite_sample_sounds¶
Generate simple waveforms
-
class
hum.lite_sample_sounds.
AnnotatedWaveform
(chk_size_frm=43008, freq=440, sr=44100, max_amplitude=30000)[source]¶ Creates a waveform with chunks corresponding to the tags in tag_to_wf_gen_func. >>> np.random.seed(1) >>> annotated_wf = AnnotatedWaveform(chk_size_frm = 4) >>> chk_tag_gen = annotated_wf.chk_and_tag_gen() >>> wf, annots = annotated_wf.get_wf_and_annots() >>> list(wf) [3003, -17828, -24808, 2511, 0, 1902, 3797, 5677, -30000, -29900, -29800, -29700, 30000, 30000, 30000, 30000] >>> assert list(next(chk_tag_gen)[0]) == [20057, 13723, -22187, 22047]
-
hum.lite_sample_sounds.
chk_from_pattern
(chk_size_frm=43008, pattern=None)[source]¶ Returns a chk with length chk_size_frm that repeats pattern if given, or creates a random pattern of length 100 >>> np.random.seed(1) >>> assert all(chk_from_pattern(5) == [3003, -17828, -24808, 2511, 20057]) >>> chk = chk_from_pattern(6, [1,2,3]) >>> assert all(chk == [1, 2, 3, 1, 2, 3])
-
hum.lite_sample_sounds.
pure_tone
(chk_size_frm=43008, freq=440, sr=44100, max_amplitude=30000)[source]¶ Generates a pure tone using given arguments >>> np.random.seed(1) >>> assert all(pure_tone(5) == [0, 1902, 3797, 5677, 7534])
-
hum.lite_sample_sounds.
random_samples
(chk_size_frm=43008, max_amplitude=30000, **kwargs)[source]¶ Returns a random sample of integers of length chk_size_frm in the range [-max_amplitude, max_amplitude] >>> np.random.seed(1) >>> assert all(random_samples(5) == [3003, -17828, -24808, 2511, 20057])
-
hum.lite_sample_sounds.
square_tone
(chk_size_frm=43008, freq=440, sr=44100, max_amplitude=30000)[source]¶ Generates a square tone using given arguments >>> np.random.seed(1) >>> assert all(square_tone(5) == [30000, 30000, 30000, 30000, 30000])
-
hum.lite_sample_sounds.
tag_wf_gen
(tag_wfgen_map: Optional[Mapping[object, Callable[], Sequence]]] = None, tag_sequence=None)[source]¶ Generate (tag, wf) pairs. :param tag_wfgen_map: A {tag: wfgen, …} map where wfgen is a callable taking no arguments and returning a sequence :param tag_sequence: A sequence of tags (that should all be keys of tag_wfgen_map) :return: