demo_effects Program

Uses

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

All available audio effects are applied sequentially on a chord sequence.


Calls

program~~demo_effects~~CallsGraph program~demo_effects demo_effects proc~add_chord add_chord program~demo_effects->proc~add_chord proc~adsr_new ADSR_envelope%ADSR_new program~demo_effects->proc~adsr_new proc~apply_autopan_effect apply_autopan_effect program~demo_effects->proc~apply_autopan_effect proc~apply_delay_effect apply_delay_effect program~demo_effects->proc~apply_delay_effect proc~apply_fuzz_effect apply_fuzz_effect program~demo_effects->proc~apply_fuzz_effect proc~apply_tremolo_effect apply_tremolo_effect program~demo_effects->proc~apply_tremolo_effect proc~close_wav_file WAV_file%close_WAV_file program~demo_effects->proc~close_wav_file proc~copy_section tape_recorder%copy_section program~demo_effects->proc~copy_section proc~create_wav_file WAV_file%create_WAV_file program~demo_effects->proc~create_wav_file proc~fr fr program~demo_effects->proc~fr proc~get_name WAV_file%get_name program~demo_effects->proc~get_name proc~mix_tracks tape_recorder%mix_tracks program~demo_effects->proc~mix_tracks proc~add_note add_note proc~add_chord->proc~add_note 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~add_sine_wave add_sine_wave proc~add_note->proc~add_sine_wave proc~clear_tracks tape_recorder%clear_tracks proc~new->proc~clear_tracks proc~adsr_level ADSR_envelope%ADSR_level proc~add_sine_wave->proc~adsr_level

Variables

Type Attributes Name Initial
type(WAV_file) :: demo
real(kind=wp) :: dnote
type(ADSR_envelope) :: env
integer :: i
real(kind=wp) :: t

Source Code

program demo_effects
    use forsynth, only: wp
    use wav_file_class, only: WAV_file
    use music_common, only: MAJOR_CHORD
    use music, only: fr, add_chord
    use audio_effects, only: apply_fuzz_effect, apply_tremolo_effect, &
                           & apply_autopan_effect, apply_delay_effect
    use envelopes, only: ADSR_envelope

    implicit none
    type(WAV_file) :: demo
    type(ADSR_envelope) :: env
    integer  :: i
    real(wp) :: t, dnote

    print *, "**** Demo of the audio effects ****"
    ! We create a new WAV file, and define the number of tracks and its duration:
    call demo%create_WAV_file('demo_effects.wav', tracks=1, duration=120._wp)
    ! We create an ADSR envelope that will be passed to signals (add_chord):
    call env%new(A=10._wp, D=40._wp, S=80._wp, R=30._wp)

    ! Notes duration in seconds:
    dnote = 1.5_wp

    associate(tape => demo%tape_recorder)

    print *, "Track 1: repeating G D F C chords..."
    t = 0.0_wp
    call add_chord(tape, track=1, t1=t,      t2=t+dnote,   f=fr("G3"), Amp=1.0_wp, chord=MAJOR_CHORD, envelope=env)
    call add_chord(tape, track=1, t1=t+dnote,   t2=t+2*dnote, f=fr("D3"), Amp=1.0_wp, chord=MAJOR_CHORD, envelope=env)
    call add_chord(tape, track=1, t1=t+2*dnote, t2=t+3*dnote, f=fr("F3"), Amp=1.0_wp, chord=MAJOR_CHORD, envelope=env)
    call add_chord(tape, track=1, t1=t+3*dnote, t2=t+4*dnote, f=fr("C3"), Amp=1.0_wp, chord=MAJOR_CHORD, envelope=env)
    ! Repeat those four chords until the end of the track:
    do i = 1, 19
        call demo%copy_section(from_track=1, to_track=1, t1=t, t2=t+4*dnote, t3=4*dnote*i)
    end do

    ! Apply the different effects, every four chords, 
    ! after four chords without effect:
    call apply_fuzz_effect(   tape, track=1, t1=t+4*dnote,  t2=t+8*dnote,  level=0.8_wp)
    call apply_tremolo_effect(tape, track=1, t1=t+8*dnote,  t2=t+12*dnote, f=4.0_wp,  AmpLFO=0.3_wp)
    call apply_autopan_effect(tape, track=1, t1=t+12*dnote, t2=t+16*dnote, f=0.33_wp, AmpLFO=0.8_wp)
    call apply_delay_effect(  tape, track=1, t1=t+16*dnote, t2=t+20*dnote, delay=0.4_wp,  Amp=0.4_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 demo_effects