Ejemplo n.º 1
0
/* Returns 1 if envelope runs out */
int recompute_envelope(int v)
{
  int stage;

  stage = voice[v].envelope_stage;

  if (stage>5)
    {
      /* Envelope ran out. */
      int tmp=(voice[v].status == VOICE_DIE); /* Already displayed as dead */
      voice[v].status = VOICE_FREE;
      if(!tmp)
	ctl->note(v);
      return 1;
    }

  if (voice[v].sample->modes & MODES_ENVELOPE)
    {
      if (voice[v].status==VOICE_ON || voice[v].status==VOICE_SUSTAINED)
	{
	  if (stage>2)
	    {
	      /* Freeze envelope until note turns off. Trumpets want this. */
	      voice[v].envelope_increment=0;
	      return 0;
	    }
	}
    }
  voice[v].envelope_stage=stage+1;

  if (voice[v].envelope_volume==voice[v].sample->envelope_offset[stage])
    return recompute_envelope(v);
  voice[v].envelope_target=voice[v].sample->envelope_offset[stage];
  voice[v].envelope_increment = voice[v].sample->envelope_rate[stage];
  if (voice[v].envelope_target<voice[v].envelope_volume)
    voice[v].envelope_increment = -voice[v].envelope_increment;
  return 0;
}
Ejemplo n.º 2
0
/* Returns 1 if envelope runs out */
int recompute_envelope(PMIDI_DECODEC hMidi,int v)
{
	int stage;
	
	stage = hMidi->voice[v].envelope_stage;
	
	if (stage>5)
    {
		/* Envelope ran out. */
		int tmp;
		tmp = (hMidi->voice[v].status == VOICE_DIE); /* Already displayed as dead */
		hMidi->voice[v].status = VOICE_FREE;
		return 1;
    }
	
	if (hMidi->voice[v].sample->modes & MODES_ENVELOPE)
    {
		if (hMidi->voice[v].status==VOICE_ON || hMidi->voice[v].status==VOICE_SUSTAINED)
		{
			if (stage>2)
			{
				/* Freeze envelope until note turns off. Trumpets want this. */
				hMidi->voice[v].envelope_increment=0;
				return 0;
			}
		}
    }
	hMidi->voice[v].envelope_stage=stage+1;
	
	if (hMidi->voice[v].envelope_volume==hMidi->voice[v].sample->envelope_offset[stage])
		return recompute_envelope(hMidi,v);
	hMidi->voice[v].envelope_target=hMidi->voice[v].sample->envelope_offset[stage];
	hMidi->voice[v].envelope_increment = hMidi->voice[v].sample->envelope_rate[stage];
	if (hMidi->voice[v].envelope_target<hMidi->voice[v].envelope_volume)
		hMidi->voice[v].envelope_increment = -hMidi->voice[v].envelope_increment;
	return 0;
}