multiplication_bells Program

Uses

  • program~~multiplication_bells~~UsesGraph program~multiplication_bells multiplication_bells module~forsynth forsynth program~multiplication_bells->module~forsynth module~music music program~multiplication_bells->module~music module~signals signals program~multiplication_bells->module~signals module~wav_file_class wav_file_class program~multiplication_bells->module~wav_file_class iso_fortran_env iso_fortran_env module~forsynth->iso_fortran_env module~music->module~forsynth module~music->module~signals module~envelopes envelopes module~music->module~envelopes module~music_common music_common module~music->module~music_common module~tape_recorder_class tape_recorder_class module~music->module~tape_recorder_class module~signals->module~forsynth module~signals->module~envelopes module~signals->module~tape_recorder_class module~wav_file_class->module~forsynth module~wav_file_class->iso_fortran_env module~wav_file_class->module~tape_recorder_class module~envelopes->module~forsynth module~envelopes->module~tape_recorder_class module~tape_recorder_class->module~forsynth

An example with a lot of bells, either periodic or random. https://en.wikipedia.org/wiki/Campanology


Calls

program~~multiplication_bells~~CallsGraph program~multiplication_bells multiplication_bells proc~add_bell add_bell program~multiplication_bells->proc~add_bell proc~close_wav_file WAV_file%close_WAV_file program~multiplication_bells->proc~close_wav_file proc~create_wav_file WAV_file%create_WAV_file program~multiplication_bells->proc~create_wav_file proc~get_name WAV_file%get_name program~multiplication_bells->proc~get_name proc~mix_tracks tape_recorder%mix_tracks program~multiplication_bells->proc~mix_tracks proc~fit_exp fit_exp proc~add_bell->proc~fit_exp proc~finalize tape_recorder%finalize proc~close_wav_file->proc~finalize proc~write_normalized_data WAV_file%write_normalized_data proc~close_wav_file->proc~write_normalized_data proc~new tape_recorder%new proc~create_wav_file->proc~new proc~write_header WAV_file%write_header proc~create_wav_file->proc~write_header proc~clear_tracks tape_recorder%clear_tracks proc~new->proc~clear_tracks

Variables

Type Attributes Name Initial
type(WAV_file) :: demo
real(kind=wp), parameter :: dnote = 3._wp
integer :: i
integer, parameter :: iend = 15
real(kind=wp) :: r1
real(kind=wp) :: r2
real(kind=wp) :: r3
integer, parameter :: shift(0:5) = [4, 7, 10, 12, 16, 19]
real(kind=wp), parameter :: t2 = 75._wp

Source Code

program multiplication_bells
    use forsynth, only: wp
    use wav_file_class, only: WAV_file, tape_recorder
    use music, only: SEMITONE, PITCH
    use signals, only: add_bell

    implicit none
    type(WAV_file) :: demo
    ! Total duration in seconds:
    real(wp), parameter :: t2 = 75._wp
    ! Duration of the basic note:
    real(wp), parameter :: dnote = 3._wp
    ! Semitones for major third, fifth, 7th, octave, major third, fifth:
    integer, parameter :: shift(0:5) = [ 4, 7, 10, 12, 16, 19 ]
    integer, parameter  :: iend = 15    ! Nb of periods for the periodic bells
    integer  :: i               ! Loop counter
    real(wp) :: r1, r2, r3      ! Random numbers

    ! We create a new WAV file, and define the number of tracks and its duration:
    call demo%create_WAV_file('multiplication_bells.wav', tracks=1, duration=t2)
    print *, "**** Creating " // demo%get_name() // " ****"
    print *, "Be patient, it may take up to one minute..."

    associate(tape => demo%tape_recorder)

    ! Intro:
    call add_bell(tape, track=1, t1=0._wp, f=PITCH*SEMITONE**(-7), Amp=2._wp)

    ! Periodic bells:
    do i = 1, iend
        call add_bell(tape, track=1, t1=i*dnote,             f=PITCH*SEMITONE**(-4), Amp=1._wp)
        call add_bell(tape, track=1, t1=i*dnote + dnote/4,   f=PITCH*SEMITONE**(0) , Amp=1._wp)
        call add_bell(tape, track=1, t1=i*dnote + 3*dnote/4, f=PITCH*SEMITONE**(0) , Amp=1._wp)
    end do

    ! Random bells:
    do i = 1, 100
        call random_number(r1)  ! Starting time
        call random_number(r2)  ! Tone
        call random_number(r3)  ! Amplitude
        call add_bell(tape, track=1, t1=4._wp + (iend-2)*dnote*r1, f=PITCH*SEMITONE**(shift(int(r2*6))), Amp=1._wp*r3)
    end do

    ! Outro:
    call add_bell(tape, track=1, t1=(iend+2)*dnote, f=PITCH*SEMITONE**(-7), Amp=2._wp)

    end associate

    ! All tracks will be mixed on track 0.
    ! Needed even if there is only one track!
    call demo%mix_tracks()
    call demo%close_WAV_file()

    print *,"You can now play the file ", demo%get_name()
end program multiplication_bells