extract voices from music signal -凯发k8网页登录
implement a basic digital music synthesizer and use it to play a traditional song in a three-voice arrangement. specify a sample rate of 2 khz. save the song as a matlab® timetable.
fs = 2e3; t = 0:1/fs:0.3-1/fs; fq = [-inf -9:2]/12; note = @(f,g) [1 1 1]*sin(2*pi*440*2.^[fq(g)-1 fq(g) fq(f) 1]'.*t); mel = [5 3 1 3 5 5 5 0 3 3 3 0 5 8 8 0 5 3 1 3 5 5 5 5 3 3 5 3 1] 1; acc = [5 0 8 0 5 0 5 5 3 0 3 3 5 0 8 8 5 0 8 0 5 5 5 0 3 3 5 0 1] 1; song = []; for kj = 1:length(mel) song = [song note(mel(kj),acc(kj)) zeros(1,0.01*fs)]; end song = song'/(max(abs(song)) 0.1); % to hear, type sound(song,fs) tune = timetable(song,samplerate=fs);
open signal analyzer and drag the timetable from the workspace browser to the signal table. click display grid to create a two-by-two grid of displays. add a spectrum view to the top two displays and the lower left display. select the lower right display, click time-frequency to add a spectrogram view, and click time to remove the time view. drag the song to all four displays. select the lower right display, and on the spectrogram tab, specify a time resolution of 0.31
second and 0
% overlap between adjoining segments. set the power limits to –50
db and –10
db.
on the analyzer tab, click duplicate three times to create three copies of the song. rename the copies as high
, medium
, and low
by double-clicking the name column in the signal table. move the copies to the top two and lower left displays.
select all three duplicate signals in the signal table and click preprocess to enter the preprocessing mode.
select the
high
signal by clicking its name in the signal table. select highpass from the functions gallery. in the function parameters panel, enter a passband frequency of450
hz and increase the steepness to0.95
. click apply.select the
medium
signal by clicking its name in the signal table. select bandpass from the functions gallery. in the function parameters panel, enter230
hz and450
hz as the lower and upper passband frequencies, respectively. increase the steepness to0.95
. click apply.select the
low
signal by clicking its name in the signal table. select lowpass from the functions gallery. in the function parameters panel, enter a passband frequency of230
hz and increase the steepness to0.95
. click apply.
click accept all to save the preprocessing results and exit the mode.
view a spectrogram on each of the three displays containing filtered signals.
remove the original signal by clearing the check box next to its name.
on the display tab, click time-frequency to add a spectrogram view and click time to remove the time view.
on the spectrogram tab, specify a time resolution of
0.31
second and0
% overlap between adjoining segments. set the power limits to–50
db and–10
db.
select the three filtered signals by clicking their name column in the signal table. on the analyzer tab, click export and save the signals to a mat-file called music.mat
. in matlab, load the file to the workspace. plot the spectra of the three signals.
load music pspectrum(low) hold on pspectrum(medium) pspectrum(high) hold off
% to hear the different voices, type % sound(low.low,fs), pause(5), sound(medium.medium,fs), pause(5), sound(high.high,fs)
see also
apps
functions
- | | | |