function wellenrauschen % WELLENRAUSCHEN simulates the sound of waves at a beach, % given the sound of water as an input file. % This file was generated by students as a partial fulfillment % for the requirements of the course "Fractals", Winter term % 2004/2005, Stuttgart University. % Author : Sebastian Hösch, Alexander Lenz % Date : Feb 2005 % Version: 1.0 clear; % input path - choose your wav-file eingabe='d:\sounds\samples\regen\meer2.wav'; % output directory output='d:\sounds\samples\regen\'; [sample,fs,nbits] = wavread(eingabe); % separation in left and right % The input consisting of two channels has to be separated % in order to process each stereo channel. samplel = sample(:,1); sampler = sample(:,2); % column vector -> row vector samplel = samplel(:)'; % For processing a noise like the sound of water only a small % part of the sample is needed. The numbers used here are chosen % deliberately and correspond to 3 seconds of musik (at a sampling % rate of 44.1 kHz) samplel = samplel(1:132300); % splitting the left channel in three parts, for better % manipulation samplel1 = samplel(1:44100); samplel2 = samplel(44101:88200); samplel3 = samplel(88201:132300); % all the same for the right channel: sampler = sampler(:)'; sampler = sampler(1:132300); sampler1 = sampler(1:44100); sampler2 = sampler(44101:88200); sampler3 = sampler(88201:132300); % The aim is a pulsating rise and decline of the sound - % therefore some additional functions are needed ... a = (1:44100); b = sin(pi*a/44100); d = abs(sin(2*pi*a/44100)); c = d.*cos(pi*a/44100); % ... which are multiplied with the left ... samplel1 = samplel1.*b; samplel2 = samplel2.*d; samplel3 = samplel3.*c; % ... and the right sample vector sampler1 = sampler1.*c; sampler2 = sampler2.*b; sampler3 = sampler3.*d; % the separated pieces are put together ... samplel = [samplel1 samplel2 samplel3]; sampler = [sampler1 sampler2 sampler3]; % ... and changed by the Kronecker product samplel = kron(samplel,[0.6 0.4 0.5 0.55 0.6 0.45]); sampler = kron(sampler,[0.45 0.4 0.3 0.25 0.7 0.55]); samplel = kron(samplel,[0.7 0.3]); sampler = kron(sampler,[0.3 0.7]); % In the end, the two channels are shifted samplel = [samplel(20001:end) samplel(1:20000)]; sampler = [sampler(2201:end) sampler(1:2200)]; % The output needs a matrix with two columns ausgabe = [samplel(:) sampler(:)]; % write the output file wavwrite(ausgabe,fs,nbits,[output,'welleausnatürlichensamplen.wav']); clear;