06 December 2006

unicomb / delay / vibrato

1) unicomb filter 'all pass' mode implemented
  • calculations too long; why?
  • spectrogram plot: search/make something decent
  • watch out with commands wavread and wavwrite --> you have to give the right sampling frequency, otherwise your sound is totally distorted, while it's not the fault of your algorithm
  • we worked on a vibrato, nut didn't succeed; maybe just because previous point :( --> we should try it again !!
2) to implement delay mode
  • problems with calculation time... not able to use it because of duration/ why?
  • a delay with parameters M=20000 so approx. 0.5 seconds results in no sound when using La.wav (it's own duration is also 0.5sec) This is because everything falls outside the window then. But do you have to sum the original signal with this one? Because it seems that this is already done in the figure (DAFX ch3). --> We must sum, it is NOT done in the picture
3) vibrato
  • same problem: too long ! frustrating !
  • ok, it was because of the parameterchoice... shorter, but still not short enough.

05 December 2006

spectrogram function by Evan Ruzanski

function spectrogram(x,fs,bw)
% Plot grayscale spectrogram with variable sampling rate and bandwidth
% Evan Ruzanski, ECE259, 2/26/2003

% Set minimum FFT length
fftmin = 256;

% Set 2*fs/bw variable window length for good resolution with long block length
% will provide higher frequency resolution as main-lobe of the window
% function will be narrow and short block length will provide higher time
% resolution as less averaging across samples is performed for each
% STFT value
winlen = floor(2*fs/bw);

% Get FFT length
fftlen = max([winlen fftmin]);

% Create window (Hamming for favorable sidelobe attenuation) and zero pad accordingly
win = [hamming(winlen) ; zeros(fftlen-winlen,1)];
win = win/sum(win); %normalizing?
windel = (0:(length(win)-1)) * win;
??

hmm from hereon I loose it... someone?
% Set overlap (Effects expansion of spectrogram display as no overlap plots
% fftlen data points and maximum overlap gives 1 data point) ?? This I don't understand?
ntime = 500; % Choose based on trial-and-error for best looking plot
overlap = floor(max(fftlen/2, (ntime*fftlen-length(x))/(ntime-1)));
ntime = floor((length(x)-overlap)/(fftlen-overlap));

% Create arrays
c1=(1:fftlen)';
r1=(0:ntime-1)*(fftlen-overlap);

% Take FFT of real data
b = fft(x(c1(:,ones(1,ntime))+r1(ones(fftlen,1),:)).*win(:,ones(1,ntime)));
if size(b,1) == 1
m = length(b1);
b(floor((m+4)/2):m) = [];
else
m=size(b,1);
b(floor((m+4)/2):m,:) = [];
end
b = b.*conj(b);

% Setup pixel locations for plot on frequency axis and time axis
f=(0:fftlen/2)*fs/fftlen; % Point spacing
t = (r1+windel)/fs;

% Set limit for dB scale
lim = max(b(:))*0.0001;

% Set dB scale
b=2.5*log10(max(b,lim));

% Plot
imh = imagesc(t,f/1000,b);

% Set up axis and labels for plot
axis('xy');
title('Spectrogram');
xlabel('Time (s)');
ylabel('Frequency (kHz)');

% Set and apply grayscale levels
colormap(gray);
map2 = colormap;
map2 = 1 - map2;
colormap(map2);
colorbar; % Applies color legend to plot
orient landscape;

matlab session on my own

To login to ESAT from a remote computer I use Filezilla:
host: login.esat.kuleuven.be
port: 22
servertype: SFTP using SSH2
user: rvandenb
Here I hold the folder 'Thesis', where all the documents are placed.

To give labels to axes:
xlabel('Time');
ylabel('Frequency (Hz)');
I tried understanding the command spectrogram, but...
Even the chirp example given by matlab I don't understand. I now try searching google on it.

Found an at first sight, very exciting URL: http://www.nd.edu/~nkottens/
Some other m-files about audio on the mathworks file-exchange also with some effects!

There is a spectrogram function on this site with better visual effect.
I'll study this one in another post

weekly update and some matlab 5nov2006

Just before the first weekly update since like a month, I worked a little bit on matlab.
I tried making a simple m-file which does all kinds of standard stuff for audio processing. Load a file, play a file, view the plot and spectrogram.
Some points of attention:
  • subplot(numberOfRows, numberOfColumns, indexOfPlot)
    after that, comma-separated, you specify the plot (plot(), stem(),...)
    and then several things you like, like: title(''), ...
    indexOfPlot counts from left-to-right and top-to-bottom.
  • wavread:
    [soundFile,sampleFrequency] = wavread('La.wav');
    soundFile is a vector with all the samples (values between -1 and 1). If you want to see only the first n bits, you add n after the filename at the RHS of the equation. To see the vector you omit the point comma.
    sampleFrequency in Hertz
    You also can specify the number of bits used to encode every sample (Quantisation), therefore you add 'NBits' after 'sampleFrequency'
  • Supports multi-channel data, with up to 32 bits per sample.
  • This file reader only supports Microsoft PCM data format.
  • Also auread is possible
  • To control the axes of the plot a website previously specified uses: axis('tight')
    This sets the limit of the axes to the range of data. I think that the y-axis is too tight then, so I put it on auto (still quite tight though). What I search for is a command to set only the y-axis (to -1, 1)
  • I think it's best to always add 'clear all;' in the beginning of an m-file.
  • The website still used specgram, but matlab prefers spectrogram now.
    I will study this soon.
Then the update with toon and tony.
We really should start implementing some effects in matlab. When encountering problems we don't have to bother disturbing toon.
We talked a bit about simulink/matlab/... According to toon best is to implement in matlab. He thinks there's no way to implement realtime functions in matlab (although he heard that in a newer version of matlab there'd be a possibility to do exactly so). The normal procedure would be to translate the matlab code to C or JAVA.
More wasn't really said I think. Before the exams we must really try to implement some effects and get used to the matlab environment.
We also can start searching for articles on audio feature extraction.
That's all.

01 December 2006

Problems and questions encountered when working with matlab

I'm doing a matlab session today and it clearly needs a warm-up.
In almost every m-file I try from the book DAFX, I either don't fully understand it, either it gives errors, either I don't see how it can be used with an audio fragment.
A short google search on "matlab commands functions for digital audio" gives me a few interesting looking URL's:
http://ccrma.stanford.edu/~jos/filters/Matlab_Utilities.html
and further on "audio in matlab":
matlab audio processing examples
http://vise.www.ecn.purdue.edu/VISE/ee438L/matlab/help/pdf/audio.pdf
audio processing


Some questions I have:
  • How do you allow figures to be in one window? And with a title...
  • What must you do when a function used in an example m-file of the book DAFX isn't recognized by matlab? (like CreateNewTrack)

09 November 2006

weekly meeting thursday 9nov2006

I met Sam, the other two were not present.
I read the chapter about nonlinear processing techniques and finally succeeded installing matlab (after download in hetdepot and problems with the image processing toolbar which I then didn't install)
Next (this afternoon) we will start implementing a delay effect (or so) in matlab. Sam and me talked about simulink and matlab and we'll begin implementing in both languages. To see which one will fit best. For realtime simulink is easier, but maybe this must be a problem for later on.
Next meeting on next thursday two o'clock PM.

02 November 2006

weekly meeting tuesday 31oct2006

I read through chapters 1 to 5 in DAFX. I was also making a list of possible effects and their possible parameters. This was an extensive job leading to the understanding that you can keep on inventing parameters for effects.
We assume that an effect algorithm starts with the basic effect and its parameters and after that you can make it more complex and add parameters. We thought that it might be better to start implementing effects right away starting with the basics and then experimenting with its parameters and adding parameters on the fly. The same with extraction algorithms. This instead of reading about them and then looking after the possibilities, because this might leave some possibilities unsought.
Also we will start searching search engines looking for articles about our subject.

http://scholar.google.com/
Google Scholar (niet specifiek voor audio, maar
wel zowat de beste zoekmachine die er is voor wetenschappelijke
publicaties)

http://www.aes.org/search/
Journal of the Audio Engineering Society + AES Conventions

http://scitation.aip.org/vsearch/servlet/VerityServlet?KEY=JASMAN&ONLINE=YES
The Journal of the Acoustical Society of America