set_time_signature Subroutine

public subroutine set_time_signature(self, numerator, denominator, metronome, tsnotes)

The time signature includes the numerator, the denominator, the number of MIDI clocks between metronome ticks, (there are 24 MIDI clocks per quarter note) and the number of 32nd notes in a quarter note. The number of "MIDI clocks" between metronome clicks.

Type Bound

MIDI_file

Arguments

Type IntentOptional Attributes Name
class(MIDI_file), intent(inout) :: self
integer, intent(in) :: numerator
integer, intent(in) :: denominator
integer, intent(in) :: metronome
integer, intent(in), optional :: tsnotes

Calls

proc~~set_time_signature~~CallsGraph proc~set_time_signature MIDI_file%set_time_signature proc~checked_int8 checked_int8 proc~set_time_signature->proc~checked_int8 proc~delta_time MIDI_file%delta_time proc~set_time_signature->proc~delta_time proc~checked_int32 checked_int32 proc~delta_time->proc~checked_int32 proc~write_variable_length_quantity MIDI_file%write_variable_length_quantity proc~delta_time->proc~write_variable_length_quantity proc~variable_length_quantity variable_length_quantity proc~write_variable_length_quantity->proc~variable_length_quantity

Called by

proc~~set_time_signature~~CalledByGraph proc~set_time_signature MIDI_file%set_time_signature proc~new MIDI_file%new proc~new->proc~set_time_signature program~blues blues program~blues->proc~new program~canon canon program~canon->proc~new program~circle_of_fifths circle_of_fifths program~circle_of_fifths->proc~new program~la_folia la_folia program~la_folia->proc~new program~motifs motifs program~motifs->proc~new program~third_kind third_kind program~third_kind->proc~new

Source Code

    subroutine set_time_signature(self, numerator, denominator, metronome, tsnotes)
        class(MIDI_file), intent(inout) :: self
        integer, intent(in) :: numerator, denominator, metronome  ! 8 bits
        integer, optional, intent(in) :: tsnotes                  ! 8 bits
        integer(int8) :: octets(0:6)

        ! MIDI events must always be preceded by a "delta time", even if null:
        call self%delta_time(0)

        ! Metadata always begin by 0xFF. Here, these bytes mean we will define
        ! the time signature:
        octets(0) = int(z'FF', int8)
        octets(1) = int(z'58', int8)
        octets(2) = int(z'04', int8)
        ! The data:
        octets(3) = checked_int8(numerator)
        ! That byte is the power of 2 of the denominator, for example 3 for
        ! a denominator whose value is 8:
        octets(4) = checked_int8(nint(log(real(denominator))/log(2.0)))
        octets(5) = checked_int8(metronome)
        if (present(tsnotes)) then
            octets(6) = checked_int8(tsnotes)
        else
            octets(6) = 8_int8     ! Default value
        end if

        write(self%unit, iostat=self%status) octets
    end subroutine set_time_signature