Page 1 of 1

Fixed length freq per midi-key

Posted: Mon Jul 21, 2014 11:46 pm
by tulamide
I wanted to have signals that run for a specified time when a note-on event for special keys is recognized. My current solution is filtering the incoming midi and then generate midi notes with Note Event, since I can assign a time value.

The downside is that any new note of the same key overrides the older one, so I also implemented a counter that spits out a new midi note number for each orignial note on event. That's ok, since I only need the start and the time, generating a fixed freqenzy from it.

But I need this construction for each key I use and that seems a bit weird. So I looked for simpler solutions. Midi to Sample isn't sufficient since I don't get a fixed length for each note-on. I also tried dsp code (but that's my weak point). I can easily seperate the keys and send out frequencies on dedicated streamouts, but I don't see how to time those freq. I played around with a counter, but that stopped each signal on a streamout, not just the one that timed out.

Generally, what I'm looking for is a timing system that converts incoming note-ons to to a start-stop-mechanic, where each midi key can be triggered even overlapping without stopping the prior event (up to 32 times), and also for each midi key the start-stop-mechanic can be edited individually in case of duration.

Is my Note Event solution the best I can achieve, or are there any other ideas?

Re: Fixed length freq per midi-key

Posted: Tue Jul 22, 2014 1:30 am
by Tronic
the length must be different for each midi key?
you can do it in polyphonic, with a simple envelope hold,
it is less easy to manage the length per midi-key,
but you could use a LUT table witch have the hold value per midi-key,
using the midi key value as index to pass the hold value to the envelope.

Re: Fixed length freq per midi-key

Posted: Tue Jul 22, 2014 1:58 am
by KG_is_back
Is this what you are looking for?

I borrowed the bar editor form additive osc - output is in 0-1 range. then I multiply it by general scale factor (samplerate*maxtime in seconds) output is an array with lengths in samples. Then I convert it to mem and read it, using midi pitch as an index. Length is send to counter, which outputs TRUE if length gets exceeded and that kills the voice using envelope primitive.

If you what to prolong the voice on retriggering rather than starting new one, that is a little bit more complicated. You will need to use the "memin hack" Trog and I were working on. Basically what you need to do is create two table mems (I recommend trogs ASM shared mem) one to store boolean whether the key is on and other to store boolean bursts for counter resets. Each voice when triggered first checks key boolean. If false, then plays as normal. If true, kills itself immediately and sets boolean burst true. The playing voice will be checking the boolean burst on start of every sample. If it finds it true, then sets it false and resets the counter to 0.

Re: Fixed length freq per midi-key

Posted: Tue Jul 22, 2014 6:07 am
by tulamide
Thank you both! That gives me a new approach. I didn't think of controlling the time by envelope hold in the poly section.

KG_is_back if you don't mind, I will use your example as a starting base for my (possible) solution. It is very close to what I'm looking for, but not quite, since the 'Wave Read makes the duration still dependant on the played key (higher keys play shorter, lower keys longer). But I think I know how to overcome this issue.