Drum detector (stream to midi)

Post any examples or modules that you want to share here
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Drum detector (stream to midi)

Post by KG_is_back »

The title says it all... a module that can detect transients in signal and play midi notes. It's just a prototype.
Attachments
drum detector.fsm
(30.35 KiB) Downloaded 1207 times
User avatar
martinvicanek
Posts: 1334
Joined: Sat Jun 22, 2013 8:28 pm

Re: Drum detector (stream to midi)

Post by martinvicanek »

Hey, KG, that's quite cool! 8-)
I believe the main challenge is the DSP drum detection part. There is some material on the Web regarding onset detection algos, although yours works quite well already if you adjust the parameters right.
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Drum detector (stream to midi)

Post by KG_is_back »

martinvicanek wrote:Hey, KG, that's quite cool! 8-)
I believe the main challenge is the DSP drum detection part. There is some material on the Web regarding onset detection algos, although yours works quite well already if you adjust the parameters right.


Exactly... I got inspired by TS audio to midi converter which also uses similar algorithm to extract and detect transient. This one basically uses difference of two envelope followers with the same release but different attack. That is then also highpassed to minimize the long sustaining differences. That is then passed through a detector which sends impulse when the modified envelope crosses the threshold upwards.

And also I do not know if I have the latency set right. The latency outputs time which takes to bufer in the frame into ruby, but the midi also may have an effect one asio buffer later, so the drum hit midi may still be 1 buffer late. I'll have to test that in the future...
Perfect Human Interface
Posts: 643
Joined: Sun Mar 10, 2013 7:32 pm

Re: Drum detector (stream to midi)

Post by Perfect Human Interface »

KG_is_back wrote:This one basically uses difference of two envelope followers with the same release but different attack.


I had a similar idea. I don't think you need more than one envelope follower though. Basically subtract the envelope follower from the abs of the original signal (without actually performing abs of course), and with the attack time set right you should get only the peaks. Not sure but I think this would be a better solution. :)
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Drum detector (stream to midi)

Post by Youlean »

Cool, I was asking for audio to MIDI just to make drums trigger. Here is how I have solved MIDI on, and off. While on input is 1, MIDI will be on, and when it goes off, MIDI will be off.
If you connect square osc ( with modification to go from 0 to 1 ) on my schematics, you can get steam accurate triggers, but CPU usage is to big...
So, is there any way we can reduce CPU? Maybe to detection be less precise..?
Attachments
audio to midi fix.fsm
(21.82 KiB) Downloaded 1197 times
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Drum detector (stream to midi)

Post by KG_is_back »

Maybe using hop in the stream part and checking the buffer in bigger jumps might be less CPU heavy.

like the stream part would be:
streamin in;
streamout out;
float previn;
hop(32){
out=1&(in>previn)+2&(in<previn);
previn=in;

}


and the ruby part would be modification of that yours:

Code: Select all

def event i,v,t

siz=@fram.size/32
for j in 0...siz #check all samples
x=j*32
   if @fram[x]==1
   then
      on=Midi.new 144,1,60,100 #midi note on
      output 0,on,t+x/@SR
   end   
   
   if @fram[x]==2
   then   
      off=Midi.new 128,1,60,100 #midi note off
      output 0,off,t+x/@SR
   end
end
end
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Drum detector (stream to midi)

Post by Youlean »

KG_is_back wrote:Maybe using hop in the stream part and checking the buffer in bigger jumps might be less CPU heavy.

like the stream part would be:
streamin in;
streamout out;
float previn;
hop(32){
out=1&(in>previn)+2&(in<previn);
previn=in;

}


and the ruby part would be modification of that yours:

Code: Select all

def event i,v,t

siz=@fram.size/32
for j in 0...siz #check all samples
x=j*32
   if @fram[x]==1
   then
      on=Midi.new 144,1,60,100 #midi note on
      output 0,on,t+x/@SR
   end   
   
   if @fram[x]==2
   then   
      off=Midi.new 128,1,60,100 #midi note off
      output 0,off,t+x/@SR
   end
end
end

Thanks KG!
BTW do you have some of your work, I would like to check it out?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Drum detector (stream to midi)

Post by KG_is_back »

Youlean wrote:Thanks KG!
BTW do you have some of your work, I would like to check it out?


Unfortunately I'm one of those guys who implement really awesome idea into working form, but are too lazy to finish it into a product xD I literally have several projects with the "core" stuff fully working but I'm lazy to finish gui and stuff.
Youlean
Posts: 176
Joined: Mon Jun 09, 2014 2:49 pm

Re: Drum detector (stream to midi)

Post by Youlean »

KG_is_back wrote:
Youlean wrote:Thanks KG!
BTW do you have some of your work, I would like to check it out?


Unfortunately I'm one of those guys who implement really awesome idea into working form, but are too lazy to finish it into a product xD I literally have several projects with the "core" stuff fully working but I'm lazy to finish gui and stuff.

Too bad, you seam like really skillful person...
What do you have in working form?
KG_is_back
Posts: 1196
Joined: Tue Oct 22, 2013 5:43 pm
Location: Slovakia

Re: Drum detector (stream to midi)

Post by KG_is_back »

Youlean wrote:Too bad, you seam like really skillful person...
What do you have in working form?

For example this string modeler. I have improved the algorithm drastically (now it calculates the stuff practically instantaneously), but it still has no GUI and I'm struggling with creating the DWG-synth that would use the measured models (the model file format is also improved).
Also I have made a "midi to multivoice-poly" module that instead of playing all valid voices just randomly picks one. That is very useful for creating drum samplers (where you need to partially randomize the samples but scale them by velocity) which I have not finished until today.
Post Reply