<< Chapter < Page | Chapter >> Page > |
Each time the stick hits the paper, the sound impulse created by the collision is detected by the microphone. The sound impulse is used in conjunction with the coordinates of the drum stick position to generate the appropriate drum sound. We used template matching by calculating the Euclidean distance.
Audio input and detecting hit
% config and caliberate audio input
% return ai audio object and th: threshhold volume calculated from% caliberation
function [ai,th]= configAudio(samplePeriodConstant)
ai = analoginput('winsound'); % create an analog input deviceaddchannel(ai,1);
Fs=8000;set(ai, 'TriggerType', 'manual');
set(ai, 'SamplesPerTrigger', 8000);set(ai,'TriggerDelay',0);
set(ai,'TriggerDelayUnits','samples');ai.TriggerRepeat = inf;
start(ai);% wait ready
pause(1);% trigger data
trigger(ai);% get recent 1x8000 sample
data = getdata(ai);% caliberated volume
th = mean(abs(data));% new trigger length for constantly checking impulses
stop(ai);set(ai, 'SamplesPerTrigger', samplePeriodConstant);
start(ai);pause(1);
end
Notification Switch
Would you like to follow the 'Elec 301 projects fall 2013' conversation and receive update notifications?