
16 currentfilename = country_files(i).name;
17 [currentsound, fs_c(i)] = audioread(currentfilename);
18 country_cells{i} = currentsound;
19 end
20
21 % get all sounds into column matrix
22 column_length = 500000;%number of samples per son
23
24 % form matrix of didgeridoo music
25 d_matrix = zeros(column_length, dsounds);
26 for i = 1:dsounds
27 s = cell2mat(didgeridoo_cells(i));
28 s = s(1:column_length,1);
29 d_matrix(:, i) = s‘;
30 end
31
32 % form matrix of country music
33 c_matrix = zeros(column_length, csounds);
34 for i = 1:csounds
35 s = cell2mat(country_cells(i));
36 s = s(1:column_length,1);
37 c_matrix(:, i) = s‘;
38 end
Picking an Appropriate Basis
It is important to choose a basis that will separate the different types of music in space. In im-
age recognition wavelets are a popular choice for a basis- this is because they are an excellent
edge detection method, which is important for recognizing shapes in images. However, in this
example wavelets are unlikely to provide a proper basis, as edge detection is not necessar-
ily important in detecting different types of music. It makes intuitive sense that a basis which
can detect frequency patterns would be of great use, since music is simply a combination of
sinusoids of different frequencies and amplitudes. This leaves us with a few different options,
namely the Fourier, Discrete Cosine, and Discrete Sine transforms. In order to simplify the
problem (hopefully without losing any accuracy) the Discrete Cosine Transform (DCT) is used
to extract the frequency content of the signal. The Fourier Transform, though appropriate in this
scenario, would require processing of real and imaginary values which we avoid for the sake of
simplicity. There are several forms for the discrete cosine transform (DCT). To check to see if
the frequency content between the two classes can be exploited, we can create spectrograms
of samples from each class. In Figure 1, it can be observed that the didgeridoo music and
country music have different frequency content. This is a good indication that using the DCT is
appropriate for this case. In MATLAB, the implementation of the DCT command is known as
the DCT-II, which is the most commonly used form. The equation for the transform is given by
Assignment № 3 Page 2