<br style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
<div class="gmail_quote">On 31 May 2012 03:41, Kaspar Bumke <span dir="ltr"><<a href="mailto:kaspar.bumke@gmail.com" target="_blank">kaspar.bumke@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


<div>Hey,<br><br>Just
 tested out drumreplacer. Seems to work well. I am going to go through 
the code and see if I can use it as a basis for a more advanced 
drumreplacer. <br><br>For now I was just making an Arch Linux AUR 
package and was wondering about the license (have to put it in the 
package). Is it just public domain or did I miss something?<br>
<br>Regards,<br><br>Kaspar</div></blockquote><div><br>
 <br>
  <br>
  <div class="gmail_quote">On 31 May 2012 09:38, Marc R.J. Brevoort <span dir="ltr"><<a href="mailto:mrjb@dnd.utwente.nl" target="_blank">mrjb@dnd.utwente.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Kaspar,<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Just tested out drumreplacer. Seems to work well. I am going to go through<br>
the code and see if I can use it as a basis for a more advanced<br>
drumreplacer.<br>
</blockquote>
<br></div>
At present it's pretty basic. It does peak detection by looking if a 
wave goes over its treshold level, then (if I remember correctly)<br>
starts a counter to see how long it takes to get to another treshold<br>
level to extract MIDI velocity. In other words, at the moment it works<br>
entirely in the amplitude domain. This works pretty well for multi-track
 recordings, but for existing stereo tracks, doing the work in the 
frequency domain might work better.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
For now I was just making an Arch Linux AUR package and was wondering about<br>
the license (have to put it in the package). Is it just public domain or did<br>
I miss something?<br>
</blockquote>
<br></div>
I usually think of my packages as GPL'ish, but granted, in this case I 
probably forgot explicitly mentioning a licensing scheme, which means<br>
at the moment it's officially under copyright law. Obviously far more<br>
restrictive than I intended.<br>
<br>
I have a slant towards GPL as this will help guaruantee that the<br>
source code is going to remain accessible to the public to tinker with.<br>
So as far as I'm concerned you can release it as GPL and keep this<br>
email as evidence that I've given you written permission to do that.<br>
Adding the generic LICENSE.txt file to the package should suffice.<br>
<br>
Good luck. If you need any help explaining the code let me know. I'll do my best (though it's 3 years back by now!)<br>
<br>
Best,<br>
Marc<br></blockquote><div><br>
    <br>
    <br>
    <div class="gmail_quote">On 31 May 2012 14:43, Kaspar Bumke <span dir="ltr"><<a href="mailto:kaspar.bumke@gmail.com" target="_blank">kaspar.bumke@gmail.com</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Marc,<div><br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
I have a slant towards GPL as this will help guaruantee that the<br>
source code is going to remain accessible to the public to tinker with.<br>
So as far as I'm concerned you can release it as GPL and keep this<br>
email as evidence that I've given you written permission to do that.<br>
Adding the generic LICENSE.txt file to the package should suffice.<br>
<br></blockquote></div><div><br>Cool, I marked it as GPL which means 
GPLv2 or later. Are you OK with that? Common licenses are available by 
default so they don't need to be in the package. <br></div><div><br>I needed to add a stdlib.h include to  src/lib/convertlib.h to make it compile with gcc 4.7 by the way. <br><div>
<br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"> Good luck. If you need any help explaining the code let me know. I'll do my best (though it's 3 years back by now!)</blockquote>



<div> </div></div></div>
I have started looking through the code. The FLTK stuff is a bit 
confusing to me so I think I will start out by trying to extract the 
Jack process and plugging that into the simple command line jack client.
 I want to make an OSC controlled back-end seperate from the GUI so that
 one day maybe I could put it in an embedded system to make an open 
source drum brain! I can see that you started out with a frontend and 
backend directories but looks like you ended putting everything in the 
frontend.<div><br>
<br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">At present it's pretty basic. It does peak detection by looking if a 
wave goes over its treshold level, then (if I remember correctly)<br>
starts a counter to see how long it takes to get to another treshold<br>
level to extract MIDI velocity. In other words, at the moment it works<br>
entirely in the amplitude domain. This works pretty well for multi-track
 recordings, but for existing stereo tracks, doing the work in the 
frequency domain might work better.<br></blockquote></div><div><br>Ah 
OK, cool.  I am really glad I found your project as this is a basic 
enough example for me to start understanding just how to simply get 
audio in and MIDI out, once I have that down I will look at the signal 
processing in more detail, do FFTs etc and maybe a neural network.. haha
 who knows. You wouldn't happen to have any recommended reading on the 
theory behind drum replacement techniques? Any tips on what you changed 
from 0.1 to 0.2 that made that crucial difference in performance?<br>
<br>Kind Regards,<br><br>Kaspar<br></div>
</blockquote></div>
    <br>
 </div></div>
  <br>
</div></div>
<br><br><div class="gmail_quote">On 31 May 2012 22:21, Marc R.J. Brevoort <span dir="ltr"><<a href="mailto:mrjb@dnd.utwente.nl" target="_blank">mrjb@dnd.utwente.nl</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">


Hi Kaspar,<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Cool, I marked it as GPL which means GPLv2 or later. Are you OK with that?<br>
</blockquote></div>
Absolutely.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I needed to add a stdlib.h include to  src/lib/convertlib.h to make it<br>
compile with gcc 4.7 by the way.<br>
</blockquote>
<br></div>
I guess it's already starting to show its age a bit ;)<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
I have started looking through the code. The FLTK stuff is a bit confusing<br>
to me so I think I will start out by trying to extract the Jack process and<br>
plugging that into the simple command line jack client. I want to make an<br>
OSC controlled back-end seperate from the GUI so that one day maybe I could<br>
put it in an embedded system to make an open source drum brain! I can see<br>
that you started out with a frontend and backend directories but looks like<br>
you ended putting everything in the frontend.<br>
</blockquote>
<br></div>
Correct, I based the empty application on another one I did earlier but couldn't be bothered to do proper frontend-backend separation in its early stages. That's probably a mistake.<div><br>
<br>
<blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Ah OK, cool.  I am really glad I found your project as this is a basic<br>
enough example for me to start understanding just how to simply get audio in<br>
and MIDI out<br>
</blockquote>
<br></div>
You'll also notice that it's JACK audio in, but rather than JACK MIDI out, it's ALSA MIDI out instead. Reason is that when I wrote drumreplacer, JACK MIDI was basically unsupported, even by JACK tools such as qjackctl. Things probably have changed at least somewhat, three years down the line.<br>



<br>
Some explanation on how things work - do with it as you please.<br>
<br>
As you've noticed, most of the magic happens in UserInterface::jack_process().<br>
<br>
The peak scanning: As an input wave is being scanned faster than realtime, one can't simply send out MIDI at the moment a peak is detected. Peaks at the end of a wave snippet would be triggered too<br>
quickly compared to peaks at the start of a wave snippet. Instead,<br>
the output has to be scheduled so that the latency between wave<br>
peak and MIDI trigger remains constant. (This is why the MIDI triggering<br>
is done through Fl::add_timeout() instead of just playing the note).<br>
<br>
If I recall correctly, the previous, 1-track version of drumreplacer didn't schedule notes at all and therefore to keep beats steady,<br>
it needed to use very small buffers and always had to triggered its<br>
notes immediately. Obviously this would result in poor performance.<br>
<br>
More about the note triggering: One thing to keep in mind is that Fl::add_timeout() is really a user-interface function. The delay is<br>
specified as milliseconds, but in reality it's not quite that<br>
accurate. Ideally, instead of a user interface timeout one would use<br>
a sample-accurate MIDI note scheduler.<br>
<br>
User interface controls:<br>
<br>
- Sens. is sensitivity, the level at which the note will trigger.<br>
- Res, the resolution - how often a note is allowed to retrigger.<br>
  Related to variable "retrig" in the code.<br>
- Mid ch, note, are the MIDI channel and note number being output<br>
  when the audio surpasses the treshold<br>
- Min veloc and Max veloc are the minimum and maximum velocity settings at which the note is played. If a note only reaches treshold value, it will be played ad minimum velocity; if it reaches maximum value (+1 or -1 as float), it will be played at the maximum given velocity.<br>



<br>
<br>
One clever bit is that when a note is scheduled for playback, the actual velocity at which it will be played isn't known yet because that is only determined *after* the treshold level is reached.<br>
The note playback is scheduled, and at that time the velocity value is set to "minimum velocity".<br>
<br>
But meanwhile, before the MIDI is sent out, the wave scanning proceeds- and may update the velocity to the highest found peak, until either the<br>
resolution knob timeout occurs (after which peak detection is reset) or until the MIDI note schedule demands the note to be played immediately, in which case it will be played at the highest velocity found between triggering the note and the actual playback event.<br>



<br>
Hope this helps!<br>
<br>
Best,<br>
Marc</blockquote></div><br>I copied the whole conversation to LAD just because I like lurking on there and reading technical discussions I don't fully understand. Hope that's all right with you. <br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">


You'll also notice that it's JACK audio in, but rather than JACK MIDI 
out, it's ALSA MIDI out instead. Reason is that when I wrote 
drumreplacer, JACK MIDI was basically unsupported, even by JACK tools 
such as qjackctl. Things probably have changed at least somewhat, three 
years down the line.<br></blockquote><div><br>That's weird, because it appears as a Jack MIDI program/device in Jack (qjackctl) which I noticed right away because my MIDI-USB devices appear under ALSA and it is a (minor) annoyance to deal with the two different MIDIs and get them to connect. Most things still seem to default to ALSA these days for better or for worse (maybe someone from LAD could chime in here with their wealth of knowledge--accurate to 1/1000 of a second it says in your comments, is that still the case? is that bad?).<br>


<br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">Some explanation on how things work - do with it as you please.<br></blockquote><br>Thanks so much the explanation. I may hit you up with more questions as I dive more into the code.<br>

<br>Kind Regards,<br><br>Kaspar<br><br><br><br><br><br></div>


<br>