all_signals Program

Uses

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

Plays sequentially each type of available signal.


Calls

program~~all_signals~~CallsGraph program~all_signals all_signals proc~add_karplus_strong add_karplus_strong program~all_signals->proc~add_karplus_strong proc~add_karplus_strong_stretched add_karplus_strong_stretched program~all_signals->proc~add_karplus_strong_stretched proc~add_noise add_noise program~all_signals->proc~add_noise proc~add_sawtooth_wave add_sawtooth_wave program~all_signals->proc~add_sawtooth_wave proc~add_sine_wave add_sine_wave program~all_signals->proc~add_sine_wave proc~add_square_wave add_square_wave program~all_signals->proc~add_square_wave proc~add_triangle_wave add_triangle_wave program~all_signals->proc~add_triangle_wave proc~add_weierstrass add_weierstrass program~all_signals->proc~add_weierstrass proc~adsr_new ADSR_envelope%ADSR_new program~all_signals->proc~adsr_new proc~close_wav_file WAV_file%close_WAV_file program~all_signals->proc~close_wav_file proc~create_wav_file WAV_file%create_WAV_file program~all_signals->proc~create_wav_file proc~fr fr program~all_signals->proc~fr proc~get_name WAV_file%get_name program~all_signals->proc~get_name proc~mix_tracks tape_recorder%mix_tracks program~all_signals->proc~mix_tracks proc~adsr_level ADSR_envelope%ADSR_level proc~add_noise->proc~adsr_level proc~add_sawtooth_wave->proc~adsr_level proc~add_sine_wave->proc~adsr_level proc~add_square_wave->proc~adsr_level proc~add_triangle_wave->proc~adsr_level proc~add_weierstrass->proc~adsr_level proc~weierstrass weierstrass proc~add_weierstrass->proc~weierstrass 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
type(ADSR_envelope) :: env
real(kind=wp) :: f_A
real(kind=wp) :: t

Source Code

program all_signals
    use forsynth, only: wp
    use wav_file_class, only: WAV_file
    use music, only: fr
    use signals, only: add_sine_wave, add_square_wave, &
                     & add_sawtooth_wave, add_triangle_wave, &
                     & add_karplus_strong, add_karplus_strong_stretched, &
                     & add_noise, add_weierstrass
    use envelopes, only: ADSR_envelope

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

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

    ! Notes frequencies are obtained with the fr() function:
    f_A = fr("A3")             ! A 220 Hz
    ! Notes duration in seconds:
    dnote = 3.0_wp

    t = 0.0_wp

    associate(tape => demo%tape_recorder)

    ! We add each signal on the track between times t1 and t2:
    print *, "Sinusoidal signal"
    call add_sine_wave(tape, track=1, t1=t, t2=t+dnote, f=f_A, Amp=1.0_wp, envelope=env)
    print *, "Square wave"
    call add_square_wave(tape, track=1, t1=t+dnote, t2=t+2*dnote, f=f_A, Amp=1.0_wp, envelope=env)
    print *, "Sawtooth wave"
    call add_sawtooth_wave(tape, track=1, t1=t+2*dnote, t2=t+3*dnote, f=f_A, Amp=1.0_wp, envelope=env)
    print *, "Triangle wave"
    call add_triangle_wave(tape, track=1, t1=t+3*dnote, t2=t+4*dnote, f=f_A, Amp=1.0_wp, envelope=env)
    print *, "Summing the four signals together"
    call add_sine_wave(tape,     track=1, t1=t+4*dnote, t2=t+5*dnote, f=f_A, Amp=0.5_wp, envelope=env)
    call add_square_wave(tape,   track=1, t1=t+4*dnote, t2=t+5*dnote, f=f_A, Amp=0.5_wp, envelope=env)
    call add_sawtooth_wave(tape, track=1, t1=t+4*dnote, t2=t+5*dnote, f=f_A, Amp=0.5_wp, envelope=env)
    call add_triangle_wave(tape, track=1, t1=t+4*dnote, t2=t+5*dnote, f=f_A, Amp=0.5_wp, envelope=env)
    print *, "Noise"
    call add_noise(tape, track=1, t1=t+5*dnote, t2=t+6*dnote, Amp=1.0_wp, envelope=env)
    print *, "Weierstrass"
    call add_weierstrass(tape, track=1, t1=t+6*dnote, t2=t+7*dnote, f=f_A, Amp=1.0_wp, envelope=env)
    print *, "Karplus Strong"
    call add_karplus_strong(tape, track=1, t1=t+7*dnote, t2=t+8*dnote, f=f_A, Amp=1.0_wp)
    print *, "Karplus Strong stretched"
    call add_karplus_strong_stretched(tape, track=1, t1=t+8*dnote, t2=t+9*dnote, f=f_A, Amp=1.0_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 all_signals