Page 1 of 2

Drum detector (stream to midi)

Posted: Sun Sep 28, 2014 9:42 pm
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.

Re: Drum detector (stream to midi)

Posted: Mon Sep 29, 2014 2:19 am
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.

Re: Drum detector (stream to midi)

Posted: Mon Sep 29, 2014 6:21 pm
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...

Re: Drum detector (stream to midi)

Posted: Mon Sep 29, 2014 7:11 pm
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. :)

Re: Drum detector (stream to midi)

Posted: Tue Sep 30, 2014 2:44 pm
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..?

Re: Drum detector (stream to midi)

Posted: Tue Sep 30, 2014 6:48 pm
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

Re: Drum detector (stream to midi)

Posted: Wed Oct 08, 2014 2:23 pm
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?

Re: Drum detector (stream to midi)

Posted: Thu Oct 09, 2014 10:34 am
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.

Re: Drum detector (stream to midi)

Posted: Sat Oct 11, 2014 6:51 pm
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?

Re: Drum detector (stream to midi)

Posted: Sat Oct 11, 2014 7:54 pm
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.