blues Program

Uses

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

A random walk on a blues scale.


Calls

program~~blues~~CallsGraph program~blues blues proc~add_karplus_strong add_karplus_strong program~blues->proc~add_karplus_strong proc~apply_tremolo_effect apply_tremolo_effect program~blues->proc~apply_tremolo_effect proc~close_wav_file WAV_file%close_WAV_file program~blues->proc~close_wav_file proc~create_wav_file WAV_file%create_WAV_file program~blues->proc~create_wav_file proc~fr fr program~blues->proc~fr proc~get_name WAV_file%get_name program~blues->proc~get_name proc~mix_tracks tape_recorder%mix_tracks program~blues->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
type(WAV_file) :: demo
real(kind=wp) :: dnote
integer :: i
integer :: k
real(kind=wp) :: r
real(kind=wp) :: t

Source Code

program blues
    use forsynth, only: wp
    use wav_file_class, only: WAV_file
    use signals, only: add_karplus_strong
    use music, only: fr
    use music_common, only: HEXATONIC_BLUES_SCALE
    use audio_effects, only: apply_tremolo_effect

    implicit none
    type(WAV_file) :: demo
    real(wp) :: t, dnote
    real(wp) :: r   ! Random number
    integer  :: i, k

    print *, "**** Demo Blues ****"
    ! We create a new WAV file, and define the number of tracks and its duration:
    call demo%create_WAV_file('blues.wav', tracks=1, duration=35._wp)

    associate(tape => demo%tape_recorder)

    ! Notes duration in seconds:
    dnote = 0.5_wp
    t = 0.0_wp

    print *, "A blues scale"
    t = t + dnote
    do i = 1, 6
        call add_karplus_strong(tape, track=1, t1=t, t2=t+dnote, &
                            & f=fr(trim(HEXATONIC_BLUES_SCALE(i))//'3'), Amp=1.0_wp)
        t = t + dnote
    end do

    print *, "Random walk on that blues scale"
    k = 1
    do i = 1, 60
        call random_number(r)
        if (r < 0.5_wp) then
            k = k - 1
        else
            k = k + 1
        end if

        if (k < 1) k = 1
        if (k > 6) k = 6

        call random_number(r)
        r = min(1.0_wp, r+0.25_wp)
        call add_karplus_strong(tape, track=1, t1=t, t2=t+dnote*(r+0.25_wp), &
                            & f=fr(trim(HEXATONIC_BLUES_SCALE(k))//'2'), Amp=1.0_wp)
        t = t + dnote*(r + 0.25_wp)
    end do

    ! A tremolo at 3 Hz and an amplitude of 0.2:
    call apply_tremolo_effect(tape, track=1, t1=0.0_wp, t2=t, f=3.0_wp, AmpLFO=0.2_wp)

    end associate

    print *, "Final mix..."
    ! 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 blues