<- previous    index    next ->

Lecture plot_wave


A basic Fourier transform can convert a function in the time domain
to a function in the frequency domain. For example, consider a sound
wave where the amplitude is varying with time. We can use a discrete
Fourier transform on the sound wave and get the frequency spectrum.

This is plot_wave.wav 
plot_wave.wav




This is plot_waved.wav   sin  canged to  cos
plot_waved.wav



This is plot_waved2.wav  derivative of plot_wave
plot_waved2.wav



Java files to produce above:
plot_wave.java
plot_waved.java
plot_waved2.java
plot_wave.mws
plot_wave_mws.out


Above made using:
plot_fft.m reads .dat amplitudes
wav_to_dat.c make .dat from .wav

cat.wav, sound file, was converted cat.dat, amplitude data file
cat.wav sound
cat.dat amplitude in 18,814 time steps


square_wave_gen.c using series
square_wave_gen_c.out cos and sin

A more general program for the FFT of large data in Java is:
Cxfft.java
read_wav.java reads and writes .wav
read_wave_java.out output
these may be combined for use in HW5.
fft_wav.java transform and inverse
fft_frame.java with a very crude frequency plot
 very crude frequency plot

Python using downloaded  numpy  has fft
testfft.py
testfft.out
fftwav.py3
fftwav.py3_out
write_ran_wav.py3
plotwav.py3
print_afile.py3

 
MatLab has fft as well as almost every other function
test_fft.m
test_fft_m.out
test_fft2.m
test_fft2_m.out

Reading and Writing .wav files for HW5

Here is a program that just reads a .wav file and writes a copy, and does a little printing. This with extensions can be the basis of Homework 5. fftwav.py3 , fft1_wav.c , You may modify to suit your desires. These only work for single channel, 8 bit per sample PCM .wav files. (not all the .wav files listed below) Note: sound does not work from a remote computer, e.g. ssh Some programs require special libraries or operating systems. read_wav.c read_wav.out train1.wav short_count.wav rocky4.wav cat.wav Splitting out read and write wav: rw_wav.h rw_wav.c test_rw_wav.c test_rw_wav.out And here are three .wav files from very small to larger for testing: ok.wav train.wav roll.wav short_count.wav Suppose you wanted to compute a sound. Here is a generator for a simple sine wave. It sounds cruddy. sine_wav.c sine_wav.out sine.wav P.S. When using MediaPlayer or QuickTime be sure to close the file before trying to rewrite it. Your web browser can usually play .wav files. Use file:/// path to your directory /xxx.wav In Java, ClipPlayer.java reads and plays .wav and other files. The driver program is ClipPlayerTest.java In Python, M$ only, with the WX graphics available, play .wav files with sound.py or on linux linux_sound.py rocky4.wav In MatLab play .wav, old wave replaced by audio, must be on local computer with speaker. waveplay.m short_count.wav Im MatLab play .dat files that have a value for each sample. soundplay.m short_count.dat Here is Rocky speaking and the dynamic spectrum rocky4.wav This needs modifications for 2 channel and 16 bits per sample.
    <- previous    index    next ->

Other links

Go to top