def generate_wave(message, wpm=WPM, framerate=FRAMERATE, skip_frame=0, amplitude=AMPLITUDE, frequency=FREQUENCY, word_ref=WORD): """ Generate binary Morse code of message at a given code speed wpm and framerate Parameters ---------- word : string wpm : int or float - word per minute framerate : nb of samples / seconds word_spaced : bool - calculate with spaces between 2 words (default is False) skip_frame : int - nb of frame to skip Returns ------- value : float """ lst_bin = _encode_binary(message) if amplitude > 1.0: amplitude = 1.0 if amplitude < 0.0: amplitude = 0.0 seconds_per_dot = _seconds_per_dot(word_ref) # =1.2 for i in count(skip_frame): bit = morse_bin(i=i, lst_bin=lst_bin, wpm=wpm, framerate=framerate, default_value=0.0, seconds_per_dot=seconds_per_dot) sine = sine_wave(i=i, frequency=frequency, framerate=framerate, amplitude=amplitude) yield sine * bit
def preview_wave(message, wpm=WPM, frequency=FREQUENCY, framerate=FRAMERATE, amplitude=AMPLITUDE, word_ref=WORD): """ Listen (preview) wave sounddevice is required http://python-sounddevice.readthedocs.org/ $ pip install sounddevice """ samp_nb = samples_nb(message=message, wpm=wpm, framerate=framerate, word_spaced=False) import sounddevice as sd lst_bin = _encode_binary(message) amplitude = _limit_value(amplitude) seconds_per_dot = _seconds_per_dot(word_ref) # 1.2 a = [ calculate_wave(i, lst_bin, wpm, frequency, framerate, amplitude, seconds_per_dot) for i in range(samp_nb) ] sd.play(a, framerate, blocking=True)
def preview_wave(message, wpm=WPM, frequency=FREQUENCY, framerate=FRAMERATE, amplitude=AMPLITUDE, word_ref=WORD): """ Listen (preview) wave sounddevice is required http://python-sounddevice.readthedocs.org/ $ pip install sounddevice """ samp_nb = samples_nb(message=message, wpm=wpm, framerate=framerate, word_spaced=False) import sounddevice as sd lst_bin = _encode_binary(message) amplitude = _limit_value(amplitude) seconds_per_dot = _seconds_per_dot(word_ref) # 1.2 a = [calculate_wave(i, lst_bin, wpm, frequency, framerate, amplitude, seconds_per_dot) for i in range(samp_nb)] sd.play(a, framerate, blocking=True)