drone_music Program

Uses

  • program~~drone_music~~UsesGraph program~drone_music drone_music module~envelopes envelopes program~drone_music->module~envelopes module~forsynth forsynth program~drone_music->module~forsynth module~music music program~drone_music->module~music module~wav_file_class wav_file_class program~drone_music->module~wav_file_class module~envelopes->module~forsynth module~tape_recorder_class tape_recorder_class module~envelopes->module~tape_recorder_class iso_fortran_env iso_fortran_env module~forsynth->iso_fortran_env module~music->module~envelopes module~music->module~forsynth module~music_common music_common module~music->module~music_common module~signals signals module~music->module~signals module~music->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~signals->module~envelopes module~signals->module~forsynth module~signals->module~tape_recorder_class module~tape_recorder_class->module~forsynth

Experimental drone music.


Calls

program~~drone_music~~CallsGraph program~drone_music drone_music proc~apply_fade_in apply_fade_in program~drone_music->proc~apply_fade_in proc~apply_fade_out apply_fade_out program~drone_music->proc~apply_fade_out proc~close_wav_file WAV_file%close_WAV_file program~drone_music->proc~close_wav_file proc~create_wav_file WAV_file%create_WAV_file program~drone_music->proc~create_wav_file proc~get_name WAV_file%get_name program~drone_music->proc~get_name proc~mix_tracks tape_recorder%mix_tracks program~drone_music->proc~mix_tracks 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
real(kind=wp) :: Amp
type(WAV_file) :: demo
real(kind=wp) :: f0
real(kind=wp) :: f1
real(kind=wp) :: f2
integer :: i
real(kind=wp) :: omega1
real(kind=wp) :: omega2
real(kind=wp) :: omegaLFO1
real(kind=wp) :: omegaLFO2
real(kind=wp) :: t
real(kind=wp) :: t1
real(kind=wp) :: t2

Source Code

program drone_music
    use forsynth, only: wp, dt, RATE, PI
    use wav_file_class, only: WAV_file
    use music, only: SEMITONE
    use envelopes, only: apply_fade_in, apply_fade_out

    implicit none
    type(WAV_file) :: demo
    ! Time in seconds:
    real(wp) :: t, t1, t2, f0, f1, f2
    ! Pulsation (radians/second):
    real(wp) :: omega1, omega2, omegaLFO1, omegaLFO2
    real(wp) :: Amp
    integer  :: i

    ! Fundamental frequency:
    f0 = 80._wp
    ! Low Frequency Oscillators:
    omegaLFO1 = 2*PI * 0.03_wp
    omegaLFO2 = 2*PI * 0.001_wp

    Amp = 1._wp

    print *, "**** Creating drone_music.wav ****"
    t1 = 0._wp
    t2 = 180._wp
    ! We create a new WAV file, and define the number of tracks and its duration:
    call demo%create_WAV_file('drone_music.wav', tracks=1, duration=t2)

    associate(tape => demo%tape_recorder)

    t = 0._wp
    do i = nint(t1*RATE), nint(t2*RATE)-1
        ! Fundamental:
        f1 = f0 * (1 + 0.01_wp*sin(omegaLFO1 * t))
        omega1 = 2*PI * f1
        tape%left(1, i)  = Amp * sin(omega1*t)

        ! Perfect fifth (7 semitones higher):
        f2 = f0*(SEMITONE**7) * (1 + 0.01_wp*sin(omegaLFO2 * t))
        omega2 = 2*PI * f2
        tape%left(1, i)  = tape%left(1, i) + Amp * sin(omega2*t)

        tape%right(1, i) = tape%left(1, i)
        t = t + dt
    end do

    call apply_fade_in( tape, track=1, t1=0._wp, t2=3._wp)
    call apply_fade_out(tape, track=1, t1=t2-3,  t2=t2)

    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 drone_music