write_variable_length_quantity Subroutine

public subroutine write_variable_length_quantity(self, i)

Writes the integer i in the MIDI file using the variable length quantity representation:

Type Bound

MIDI_file

Arguments

Type IntentOptional Attributes Name
class(MIDI_file), intent(inout) :: self
integer(kind=int32), intent(in) :: i

Calls

proc~~write_variable_length_quantity~~CallsGraph proc~write_variable_length_quantity MIDI_file%write_variable_length_quantity proc~variable_length_quantity variable_length_quantity proc~write_variable_length_quantity->proc~variable_length_quantity

Called by

proc~~write_variable_length_quantity~~CalledByGraph proc~write_variable_length_quantity MIDI_file%write_variable_length_quantity proc~delta_time MIDI_file%delta_time proc~delta_time->proc~write_variable_length_quantity proc~write_string MIDI_file%write_string proc~write_string->proc~write_variable_length_quantity proc~write_string->proc~delta_time proc~control_change MIDI_file%Control_Change proc~control_change->proc~delta_time proc~copyright_notice MIDI_file%copyright_notice proc~copyright_notice->proc~write_string proc~cue_point MIDI_file%cue_point proc~cue_point->proc~write_string proc~end_of_track MIDI_file%end_of_track proc~end_of_track->proc~delta_time proc~instrument_name MIDI_file%instrument_name proc~instrument_name->proc~write_string proc~lyric MIDI_file%lyric proc~lyric->proc~write_string proc~marker MIDI_file%marker proc~marker->proc~write_string proc~pitch_bend MIDI_file%Pitch_Bend proc~pitch_bend->proc~delta_time proc~play_broken_chord MIDI_file%play_broken_chord proc~play_broken_chord->proc~delta_time proc~play_chord MIDI_file%play_chord proc~play_chord->proc~delta_time proc~play_note MIDI_file%play_note proc~play_note->proc~delta_time proc~program_change MIDI_file%Program_Change proc~program_change->proc~delta_time proc~sequence_track_name MIDI_file%sequence_track_name proc~sequence_track_name->proc~write_string proc~set_tempo MIDI_file%set_tempo proc~set_tempo->proc~delta_time proc~set_time_signature MIDI_file%set_time_signature proc~set_time_signature->proc~delta_time proc~text_event MIDI_file%text_event proc~text_event->proc~write_string program~blues blues program~blues->proc~delta_time program~blues->proc~control_change program~blues->proc~end_of_track program~blues->proc~play_chord program~blues->proc~program_change proc~new MIDI_file%new program~blues->proc~new proc~track_header MIDI_file%track_header program~blues->proc~track_header proc~new->proc~copyright_notice proc~new->proc~end_of_track proc~new->proc~set_tempo proc~new->proc~set_time_signature proc~new->proc~text_event proc~new->proc~track_header proc~track_header->proc~sequence_track_name proc~track_header->proc~text_event program~canon canon program~canon->proc~control_change program~canon->proc~end_of_track program~canon->proc~play_note program~canon->proc~program_change program~canon->proc~new program~canon->proc~track_header program~circle_of_fifths circle_of_fifths program~circle_of_fifths->proc~control_change program~circle_of_fifths->proc~end_of_track program~circle_of_fifths->proc~play_chord program~circle_of_fifths->proc~program_change program~circle_of_fifths->proc~new program~circle_of_fifths->proc~track_header program~la_folia la_folia program~la_folia->proc~control_change program~la_folia->proc~end_of_track program~la_folia->proc~play_broken_chord program~la_folia->proc~play_chord program~la_folia->proc~program_change program~la_folia->proc~new program~la_folia->proc~track_header program~motifs motifs program~motifs->proc~control_change program~motifs->proc~end_of_track program~motifs->proc~play_broken_chord program~motifs->proc~play_chord program~motifs->proc~play_note program~motifs->proc~program_change program~motifs->proc~new program~motifs->proc~track_header program~third_kind third_kind program~third_kind->proc~end_of_track program~third_kind->proc~play_note program~third_kind->proc~program_change program~third_kind->proc~new program~third_kind->proc~track_header

Source Code

    subroutine write_variable_length_quantity(self, i)
        class(MIDI_file), intent(inout) :: self
        integer(int32), intent(in) :: i
        integer(int32) :: j
        integer(int8), allocatable, dimension(:) :: array

        ! The maximum possible MIDI value:
        if (i > int(z'0FFFFFFF', int32)) then
            write(error_unit, *) "ERROR 2: delay > 0x0FFFFFFF ! ", i
            error stop 2
        end if

        array = variable_length_quantity(i)
        ! The bytes are now written in the file:
        do j = 1, size(array)
            write(self%unit, iostat=self%status) array(j)
        end do
    end subroutine write_variable_length_quantity