-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathwavfile_test.f90
36 lines (24 loc) · 1.25 KB
/
wavfile_test.f90
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
program wavfile_test
use mod_wavfile
implicit none
real(real32), parameter :: frequency1 = 440
real(real32), parameter :: frequency2 = 880
integer(int16), dimension(:,:), allocatable :: payload_stereo, payload_mono
integer :: counter
real(real64) :: t ! time
type(wavfile) :: my_wav_stereo, my_wav_mono
allocate(payload_stereo(1:2,0:10*SAMPLES_PER_SECOND))
allocate(payload_mono(1:1,0:10*SAMPLES_PER_SECOND))
do counter=0,10*SAMPLES_PER_SECOND
t =real(counter,real32)/SAMPLES_PER_SECOND
payload_stereo(1,counter) = int(20000*sin(2*c_pi*frequency1*t), kind=int16)
payload_stereo(2,counter) = int(20000*sin(2*c_pi*frequency2*t), kind=int16)
payload_mono(1,counter) = int(20000*sin(2*c_pi*frequency1*t), kind=int16)
enddo
my_wav_stereo = wavfile('test_stereo.wav', stereo = .true.)
call my_wav_stereo % wf_write(payload_stereo, 2*SAMPLES_PER_SECOND+1 )
call my_wav_stereo % wf_close
my_wav_mono = wavfile('test_mono.wav')
call my_wav_mono % wf_write(payload_mono, 2*SAMPLES_PER_SECOND+1 )
call my_wav_mono % wf_close
end program wavfile_test