To sum up what we did:
1 - described a matlab function (m-file), its input and output
parameters, comments and help, and simple way to set up default
parameter values using nargin.
2 - used the CepsAna from CATbox to demonstrate homomorphic
decomposition (source - filter) and used imagesc to display the
figures. Also showed how multiple plots can be put on one figure
using subplot command and how figure and axes properties can be
changed using set command. Printing formats were mentioned for the
print command.
3 - introduced the miditoolbox and readmidi command. Explain the
basic note matrix structure and showed how playmidi , nmat2snd and
playsound work. Mentioned some of the toolbox functions, such as KK
tonality estimation. Displaying midi can be done using pianoroll
command.
4 - Ben demonstrated some timbral transformations using Loris.
Next week we will proceed to FactorOracle and discuss projects.
---
function [x,t,fs] = chirp(f0,T,fs)
% [x,t,fs] = chirp(f0,T,fs)
% create a changing frequency sound
% f0 is a two dimensional vector of start and end frequency
% T duration in seconds
% fs is sampling frequency
% x - sound vector
% t - time vecotr
if nargin < 1
f0 = 220;
end
if nargin < 2,
T = 1;
end
if nargin < 3,
fs = 8000;
end
if length(f0) == 1,
f0 = [f0; f0];
end
dt = 1/fs;
t = [0:dt:T];
f0i = linspace(f0(1),f0(2),length(t));
% to generalize it into a breakpoint list of f0 and T.
%f0i = interp1(f0,T,t);
Theta = 2*pi*cumsum(f0i)*dt;
%Theta = 2*pi*f0i.*t; %this is the wrong way to do it.
x = sin(Theta);
----
diary
[x,fs] = wavread('svega.wav');
[C,S,E] = cepsana(x);
Warning: Function call cepsana invokes inexact match
/Users/sdubnov/Documents/Research/Computer
Audition/CATbox/Publish/CATbox v0.1/Ceps/CepsAna.m.
whos
Name Size Bytes Class
A 2x3 48 double array
C 512x608 2490368 double array
E 257x608 2500096 double array (complex)
S 257x608 2500096 double array (complex)
T 1x1 8 double array
Theta 1x16001 128008 double array
ans 1x73 146 char array
f0 1x1 8 double array
fs 1x1 8 double array
t 1x16001 128008 double array
x 156160x1 1249280 double array
x1 1x16001 128008 double array
Grand total is 828053 elements using 9124082 bytes
close all
imagesc(E)
??? Error using ==> image
Error using ==> image
Image CData can not be complex.
Error in ==> <a
href="error:/Applications/MATLAB7/toolbox/matlab/specgraph/imagesc.m,18,1">imagesc
at 18</a>
hh = image(varargin{1},'CDataMapping','scaled');
imagesc(real(E))
imagesc(log(real(E))); axis xy
figure
imagesc(log(real(S))); axis xy
figure
specgram(x)
figure
subplot(3,1,1)
specgram(x)
title('Spectrum')
subplot(3,1,2)
imagesc(log(real(S))); axis xy
title('Envelope')
subplot(3,1,3)
imagesc(log(real(E))); axis xy
title('Excitation')
t3 = title('Excitation')
t3 =
622.0006
get(t3)
BackgroundColor = none
Color = [0 0 0]
EdgeColor = none
EraseMode = normal
Editing = off
Extent = [ (1 by 4) double array]
FontAngle = normal
FontName = Helvetica
FontSize = [10]
FontUnits = points
FontWeight = normal
HorizontalAlignment = center
LineStyle = -
LineWidth = [0.5]
Margin = [2]
Position = [303.732 272.519 1.00005]
Rotation = [0]
String = Excitation
Units = data
Interpreter = tex
VerticalAlignment = bottom
BeingDeleted = off
ButtonDownFcn =
Children = []
Clipping = off
CreateFcn =
DeleteFcn =
BusyAction = queue
HandleVisibility = off
HitTest = on
Interruptible = on
Parent = [620]
Selected = off
SelectionHighlight = on
Tag =
Type = text
UIContextMenu = []
UserData = []
Visible = on
set(t3,'FontSize',16)
set(t3,'FontSize',24)
nmat = readmidi('donna.mid');
size(nmat)
ans =
4862 7
nmat(1:10,:)
ans =
Columns 1 through 5
4.0000 0.6250 1.0000 58.0000 98.0000
4.0000 0.6979 1.0000 63.0000 115.0000
4.0000 0.6042 1.0000 55.0000 127.0000
4.0104 0.6250 1.0000 44.0000 115.0000
4.0104 0.6354 1.0000 60.0000 108.0000
4.0208 0.6146 1.0000 32.0000 115.0000
4.1667 0.9375 10.0000 46.0000 83.0000
5.0625 0.2604 10.0000 42.0000 72.0000
5.7708 0.2396 10.0000 42.0000 72.0000
5.9896 0.3646 1.0000 79.0000 124.0000
Columns 6 through 7
1.0000 0.1562
1.0000 0.1745
1.0000 0.1510
1.0026 0.1562
1.0026 0.1589
1.0052 0.1536
1.0417 0.2344
1.2656 0.0651
1.4427 0.0599
1.4974 0.0911
playmidi(nmat(1:100,:))
Press space bar to listen to the MIDI file.
Close the Quicktime Player window after listening.
playmidi(nmat(1:100,:),200)
Press space bar to listen to the MIDI file.
Close the Quicktime Player window after listening.
x = nmat2snd(nmat(1:100,:));
38.15K samples
fs = 8192;
soundsc(x,fs)
diary