add_morse_code Subroutine

public subroutine add_morse_code(tape, track, t1, f, Amp, string)

Adds on the specified track a Morse code translation of the string, starting at time t1. The frequency f must correspond to a high tone, for example 880 Hz.

Arguments

Type IntentOptional Attributes Name
type(tape_recorder), intent(inout) :: tape
integer, intent(in) :: track
real(kind=wp), intent(in) :: t1
real(kind=wp), intent(in) :: f
real(kind=wp), intent(in) :: Amp
character(len=*), intent(in) :: string

Calls

proc~~add_morse_code~~CallsGraph proc~add_morse_code add_morse_code proc~add_sine_wave add_sine_wave proc~add_morse_code->proc~add_sine_wave proc~adsr_level ADSR_envelope%ADSR_level proc~add_sine_wave->proc~adsr_level

Called by

proc~~add_morse_code~~CalledByGraph proc~add_morse_code add_morse_code program~radioactivity radioactivity program~radioactivity->proc~add_morse_code

Source Code

    subroutine add_morse_code(tape, track, t1, f, Amp, string)
        type(tape_recorder), intent(inout) :: tape
        integer, intent(in)  :: track
        real(wp), intent(in) :: t1, f, Amp
        character(len=*), intent(in)  :: string

        character(len=1) :: c
        real(wp) :: t               ! Time in seconds
        real(wp) :: dot = 0.050_wp  ! The fundamental duration in seconds
        integer  :: i

        t = t1
        do i = 1, len_trim(string)
            c = string(i:i)
            select case (c)
                case ('.')
                    call add_sine_wave(tape, track, t, t+1*dot, f, Amp)
                    t = t + 1*dot
                case ('-')  ! A dash last three times longer than a dot
                    call add_sine_wave(tape, track, t, t+3*dot, f, Amp)
                    t = t + 3*dot
                case (' ')
                    t = t + (3-1)*dot   ! Silence between letters of a word,
                                        ! taking into account the silence added after END SELECT
                    ! A double space means we are between two words, and the
                    ! total silence must last 7 dots:
                    if (string(i+1:i+1) == ' ') then
                        t = t + 4*dot
                    end if
            end select

            t = t + dot     ! A silence between dots and dashes in a character
        end do
    end subroutine add_morse_code