wav_file_class Module

The main class that you will use to create your WAV files.


Uses

  • module~~wav_file_class~~UsesGraph module~wav_file_class wav_file_class iso_fortran_env iso_fortran_env module~wav_file_class->iso_fortran_env module~forsynth forsynth module~wav_file_class->module~forsynth module~tape_recorder_class tape_recorder_class module~wav_file_class->module~tape_recorder_class module~forsynth->iso_fortran_env module~tape_recorder_class->module~forsynth

Used by

  • module~~wav_file_class~~UsedByGraph module~wav_file_class wav_file_class program~all_signals all_signals program~all_signals->module~wav_file_class program~arpeggios arpeggios program~arpeggios->module~wav_file_class program~blues blues program~blues->module~wav_file_class program~chords_and_melody chords_and_melody program~chords_and_melody->module~wav_file_class program~demo_effects demo_effects program~demo_effects->module~wav_file_class program~doppler_effect doppler_effect program~doppler_effect->module~wav_file_class program~drone_music drone_music program~drone_music->module~wav_file_class program~drum_machine drum_machine program~drum_machine->module~wav_file_class program~misc_sounds misc_sounds program~misc_sounds->module~wav_file_class program~shepard_risset_glissando shepard_risset_glissando program~shepard_risset_glissando->module~wav_file_class program~shepard_scale shepard_scale program~shepard_scale->module~wav_file_class

Variables

Type Visibility Attributes Name Initial
integer, public, parameter :: MAX_AMPLITUDE = 32767

Maximum amplitude in a WAV [-32768 ; +32767]:

integer, private :: status

Derived Types

type, public, extends(tape_recorder) ::  WAV_file

Components

Type Visibility Attributes Name Initial
real(kind=wp), public :: duration

Duration in seconds:

character(len=:), public, allocatable :: filename
integer, public :: fileunit
real(kind=wp), public, dimension(:, :), allocatable :: left

Two arrays stocking the stereo tracks:

real(kind=wp), public, dimension(:, :), allocatable :: right

Two arrays stocking the stereo tracks:

integer, public :: samples

Number of samples:

integer, public :: tracks

Number of audio tracks (excluding track 0 reserved for the final mix):

Type-Bound Procedures

procedure, public :: clear_tracks
procedure, public :: close_WAV_file
procedure, public :: copy_section
procedure, public :: create_WAV_file
procedure, public :: finalize
procedure, public :: get_name
procedure, public :: mix_tracks
procedure, public :: new
procedure, private :: write_header
procedure, private :: write_normalized_data

Functions

public function get_name(self)

Returns the name of the WAV file:

Arguments

Type IntentOptional Attributes Name
class(WAV_file), intent(inout) :: self

Return Value character(len=len(self%filename))


Subroutines

public subroutine close_WAV_file(self)

Must be called at the end. It normalizes the channels, writes them in the WAV file and closes it. It also deallocate the tape arrays.

Arguments

Type IntentOptional Attributes Name
class(WAV_file), intent(inout) :: self

public subroutine create_WAV_file(self, filename, tracks, duration)

Create a WAV file with a header:

Arguments

Type IntentOptional Attributes Name
class(WAV_file), intent(inout) :: self
character(len=*), intent(in) :: filename
integer, intent(in) :: tracks
real(kind=wp), intent(in) :: duration

public subroutine write_header(self)

Creates the 44 bytes WAV header and prints some information:

Arguments

Type IntentOptional Attributes Name
class(WAV_file), intent(inout) :: self

WAV parameters:

Read more…

public subroutine write_normalized_data(self)

This method normalizes the sound amplitude on track 0, before saving the left and right channels in the WAV file.

Arguments

Type IntentOptional Attributes Name
class(WAV_file), intent(inout) :: self