<< Chapter < Page
  Virtual drum kit   Page 1 / 1
Chapter >> Page >

Audio processing

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.

Ambient noise level

Also called background noise level, is utilized to find the relative trigger level when a peak reached a certain height. We first test the ambient noise in the environment by recording a period of sound and take an average. The noise level will determine the sound trigger level. The larger the noise, the harder the player may need to hit the drum to produce a sound.

The big spike contained in the red box indicates the stick hit the drum kit.

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

Get Jobilize Job Search Mobile App in your pocket Now!

Get it on Google Play Download on the App Store Now




Source:  OpenStax, Virtual drum kit. OpenStax CNX. Dec 19, 2013 Download for free at http://cnx.org/content/col11607/1.1
Google Play and the Google Play logo are trademarks of Google Inc.

Notification Switch

Would you like to follow the 'Virtual drum kit' conversation and receive update notifications?

Ask