Login / Register 0 items | $0.00 New @ KVR
Borogove
KVRAF
 
2456 posts since 3 Oct, 2002, from SF CA USA NA Earth

Postby Borogove; Tue Jun 14, 2005 11:22 am

upsidedown wrote::hug: Borogove and me.


useruseruser wrote:At least your charcter is shown very clearly this way again.

Idiot.
f**k off.
Image
Don't do it my way.
blümchen
Banned

Postby blümchen; Tue Jun 14, 2005 12:08 pm

That's really not a fine character, to post a PM inside the public forum. Don't you see it yourselfes now? Hmmm? :tantrum:

By the way, posting that without any corelations to the theme makes absolutely no sense.
blümchen
Banned

Postby blümchen; Tue Jun 14, 2005 12:13 pm

But I love you never the less. :oops:
User avatar
WilliamK
KVRAF
 
17523 posts since 11 Jun, 2001, from Wusik Dot Com

Postby WilliamK; Tue Jun 14, 2005 12:22 pm

jtxx000 wrote:What is the best way to implement voice stealing? Right now my idea is to have two linked lists - one for currently playing notes and one for notes that are free. When a note is played you an entry note from the free linked list and insert it at the beginnig of the playing linked list. If all the free notes are taken, then use the last entry in the playing list. To prevent clicking, add 1 ms latency to the synth and when a voice needs to be stolen start fading out the note. Is this a good approach, or is there an easier/better way of doing it?


What I do is to keep a list of played notes, when a new note is added, I see if the number of voices > number of playing notes and I check the most oldest holded note. That's that one I "steal" ;-)

I also do the 1ms fade to avoid clicking, specialy for the mono-mode.

Wk
Borogove
KVRAF
 
2456 posts since 3 Oct, 2002, from SF CA USA NA Earth

Postby Borogove; Tue Jun 14, 2005 12:32 pm

upsidedown wrote:That's really not a fine character, to post a PM inside the public forum. Don't you see it yourselfes now? Hmmm? :tantrum:


:smack:
Image
Don't do it my way.
pj geerlings
KVRian
 
909 posts since 30 Nov, 2003, from tejas

Postby pj geerlings; Tue Jun 14, 2005 1:23 pm

upsidedown wrote:That's really not a fine character, to post a PM inside the public forum. Don't you see it yourselfes now? Hmmm? :tantrum:

By the way, posting that without any corelations to the theme makes absolutely no sense.


I was on your side a while back - now I think you need years of therapy (as well as a refresher course on "English as a second language")

Get a grip (on reality) man!!
blümchen
Banned

Postby blümchen; Wed Jun 15, 2005 1:36 am

pj geerlings wrote:I was on your side a while back - now I think you need years of therapy (as well as a refresher course on "English as a second language")

Get a grip (on reality) man!!


Ah yes?

Hi,
Just wanted you to know that I was sad to see you go - I wish I would have said something on your behalf earlier.
Sorry,
pj geerlings


Do you know that from anywhere?
Maybe it's you, who needs therapy.

(I posted this private e-mail, because you seem to find posting private messages inside public fora just "normal".) And please excuse, that I am not perfect in *your* mother language...
pj geerlings
KVRian
 
909 posts since 30 Nov, 2003, from tejas

Postby pj geerlings; Wed Jun 15, 2005 9:02 am

You're it, I quit

(To the more mature individuals who may be passing by this pathetic thread: please forgive this brief moment of supreme childishness)

peace,
pj
james0tucson
KVRAF
 
4315 posts since 23 Feb, 2004, from Tucson Arizona USA

Postby james0tucson; Wed Jun 15, 2005 9:09 am

WilliamK wrote:What I do is to keep a list of played notes, when a new note is added, I see if the number of voices > number of playing notes and I check the most oldest holded note. That's that one I "steal" ;-)
Wk


I wonder if that will ever be a problem for me with a pedal note. Of all the notes that can go away, a bass pedal note is the worst possible choice, but it's also quite likely to be the one that's been held the longest.

This sounds like a candidate for some intelligent harmonic algorithim, not just FIFO.
Fuzzpilz
KVRist
 
250 posts since 17 Jun, 2004, from Magdeburg

Postby Fuzzpilz; Wed Jun 15, 2005 9:18 am

That's precisely the sort of problem I try to avoid by going after notes in their release phase first - as I said, it seems to be working fine. I guess it's possible to refine it by using not the oldest note that's releasing, but the note that's been releasing the longest.
User avatar
WilliamK
KVRAF
 
17523 posts since 11 Jun, 2001, from Wusik Dot Com

Postby WilliamK; Wed Jun 15, 2005 9:46 am

Here's a partial code that I use to track notes, it takes care of "steal" and sustain-pedal too. Is a bit messy, an older code, but works without much problems.

Code: Select all
void reset( void )
{
  for (int i=0; i<128; i++)
  {     array_notes_I[i] = 0;
     array_notes_P[i] = 0;
      array_notes_V[i] = 0;
     array_notes_LastP[i] = 0;
      array_notes_LastV[i] = 0;
     array_notes_Count[i] = 0;
     array_notes_S[i] = false;
  }
  number_of_keys = -1;
  number_of_number_of_active_voices = 0;
  number_of_active_voices = 1;
  NoteIsOn = false;
  SustainOn = false;
  Counter = 0;
}


int Midi_note_on(int note_n, int note_v)
{
   Counter++;
   if (Counter > 60000)
   {
      Counter = 128;
      for (int i=0; i<128; i++) array_notes_Count[i] -= (60000-128);
   }

   if (number_of_active_voices == 1)
   {
      number_of_keys++;
      array_notes_P[number_of_keys] = note_N;
      array_notes_V[number_of_keys] = note_v;
      array_notes_LastP[number_of_keys] = note_N;
      array_notes_LastV[number_of_keys] = note_v;
      array_notes_Count[number_of_keys] = Counter;
      array_notes_S[number_of_keys] = false;
      NoteIsOn = true;
      if (number_of_keys == 0) return 0; else return -1;

   }
   else
   {
      for (int xi = 0; xi < number_of_active_voices; xi++)
      {
         if (note_N == array_notes_P[xi])
         {
            array_notes_S[xi] = false;
            array_notes_V[xi] = note_v;
            array_notes_LastV[xi] = note_v;
            return xi;
         }
      }
      number_of_number_of_active_voices++;
      if (number_of_number_of_active_voices > number_of_active_voices) {number_of_number_of_active_voices = number_of_active_voices;}
      bool array_notes_et = false;
      int r_note = 0;
      for (xi = 0; xi < number_of_active_voices; xi++)
      {
         if (freevoice) // Check for free voice
         {
            r_note = xi;
            array_notes_et = true;
            break;
         }
      }
      if (!array_notes_et)
      {
         // "steal"
         r_note = array_notes_I[0];
         int xcnt = 60000;
         for (xi = 0; xi < number_of_active_voices; xi++)
         {
            if (array_notes_Count[xi] < xcnt)
            {
               xcnt = array_notes_Count[xi];
               r_note = xi;
            }
         }
      }

      if (r_note > (number_of_active_voices - 1)) {r_note = 0;}
      if (r_note < 0) {r_note = 0;}
      array_notes_P[r_note] = note_N;
      array_notes_V[r_note] = note_v;
      array_notes_LastP[r_note] = note_N;
      array_notes_LastV[r_note] = note_v;
      array_notes_Count[r_note] = Counter;
      array_notes_I[r_note] = number_of_keys++;
      array_notes_S[r_note] = false;
       return r_note;
   }
}


Wk
User avatar
Urs
u-he
 
22119 posts since 7 Aug, 2002, from Berlin

Postby Urs; Wed Jun 15, 2005 10:07 am

If it helps, there's source code for a NoteScheduler in the VST Source Code Archive. It can handle any sort of polyphony and steals oldest voices.

I use several techniques to prevent clicks. If the voice to steal is sounding very low (say -100dB) I don't do anything about it. If it's below -50dB, I do the DC-offset-fade-to-zero thing. If it's pretty audible, the next note has to wait for 5-10 ms. I don't think this latency hurts at all, because it's already a lot of stuff going on there (at least 15 more vocies playing in my current synths).

In Zebra 1.0 I had the concept of "ghost voices". These were a couple of additional voices that would play while stolen voices would fade out quickly. But I dropped that concept because of the potential performance peaks.

At any rate, I would avoid anything that involves too much computation.

Cheers,

;) Urs
scooby1999a
KVRer
 
11 posts since 26 Mar, 2004

Postby scooby1999a; Fri Jun 17, 2005 6:04 pm

IMHO

'Note stealing' is a prime example of how (we) developers like to over engineer solutions.

Why bother?

There are two clear solutions:-

1. Just create more voices.
2. Ignore extra voices (poosibly show a warning light on the gui)

Okay so lets look at these.

If we choose (1) then at some point the users computer will run out of CPU. The user can then make the decision as to what to do next.

If we choose (2) then we (possibly) preserve CPU but the sound coming from our module is not exactly what the user expects. However, the user sees the warning light and is then able to make a decision as to what to do.

The key to this is that it is the user who makes the decision - NOT the developer. The user is the only one in a position to make this decision and should be allowed to do so.

Any form of note stealing is a compromise based on unknown criteria (how many voices CAN the users machine run? - do you know this for a fact), and I hope I have shown it to be unnecessary.

Just my foolish way of looking at things
blümchen
Banned

Postby blümchen; Sat Jun 18, 2005 1:21 am

scooby1999a wrote:IMHO

'Note stealing' is a prime example of how (we) developers like to over engineer solutions.

Why bother?

There are two clear solutions:-

1. Just create more voices.
2. Ignore extra voices (poosibly show a warning light on the gui)

Okay so lets look at these.

If we choose (1) then at some point the users computer will run out of CPU. The user can then make the decision as to what to do next.

If we choose (2) then we (possibly) preserve CPU but the sound coming from our module is not exactly what the user expects. However, the user sees the warning light and is then able to make a decision as to what to do.

The key to this is that it is the user who makes the decision - NOT the developer. The user is the only one in a position to make this decision and should be allowed to do so.

Any form of note stealing is a compromise based on unknown criteria (how many voices CAN the users machine run? - do you know this for a fact), and I hope I have shown it to be unnecessary.

Just my foolish way of looking at things


Sorry, but that is absolute nonsense.

The only acceptable "enineering solution" is to implement a decent note stealing algorithm (including dynamic voice limiting/allocation).

The things you suggested are unprofessional and unmusical like hell. That's actually a beginners solution, not situable for any finished software, nor hardware synthesizers.

With your questionable opinion, you probably wouldn't able to sell one piece of your work. So this wasn't helpfull at all, merely misinformative.

.
User avatar
Urs
u-he
 
22119 posts since 7 Aug, 2002, from Berlin

Postby Urs; Sat Jun 18, 2005 1:55 am

Dynamic voice allocation is a really bad thing. Both the render thread and the midi thread are typically interrupt level threads where any sort of malloc() or new() are not exactly a good idea.

I have that vision of someone who's got a hanging note... he hits the keyboard with his forearm to get rid of it... but he doesn't... no vocie limit... instead, 100MB of his RAM are now used for voices he'll never play... :hihi:

Also, reasonable optimzation might require to *know* how the memory is layed out. My plugins do a single malloc to allocate all resources required for realtime operation. This allows me to do cache friendly memory accesses which IMHO brings a huge speed boost...

Cheers,

;) Urs
PreviousNext

Moderator: Moderators (Main)

Return to DSP and Plug-in Development