Exemple #1
0
 public dx7_voice()
 {
     this.status = dx7_voice_status.DX7_VOICE_OFF;
     for (int i = 0; i < Constants.MAX_DX7_OPERATORS; i++)
     {
         this.op[i] = new dx7_op();
     }
 }
Exemple #2
0
 /*
  * dx7_voice_off
  *
  * turn off a voice immediately
  */
 public void dx7_voice_off()
 {
     this.status = dx7_voice_status.DX7_VOICE_OFF;
     if (this.instance.monophonic != 0)
     {
         this.instance.mono_voice = null;
     }
     this.instance.current_voices--;
 }
Exemple #3
0
 /*
  * dx7_voice_release_note
  */
 public void dx7_voice_release_note(hexter_instance instance)
 {
     //DEBUG_MESSAGE(DB_NOTE, " dx7_voice_release_note: turning off voice %p\n", voice);
     if (_ON)
     {
         /* dummy up a release velocity */
         this.rvelocity = 64;
     }
     dx7_voice_set_release_phase(instance);
     this.status = dx7_voice_status.DX7_VOICE_RELEASED;
 }
Exemple #4
0
 public void dx7_voice_start_voice()
 {
     this.status = dx7_voice_status.DX7_VOICE_ON;
     this.instance.current_voices++;
 }
Exemple #5
0
        /*
         * dx7_voice_note_off
         */
        public void dx7_voice_note_off(hexter_instance instance, byte key, byte rvelocity)
        {
            //DEBUG_MESSAGE(DB_NOTE, " dx7_voice_note_off: called for voice %p, key %d\n", voice, key);

            /* save release velocity */
            this.rvelocity = rvelocity;

            if (instance.monophonic != 0)
            {     /* monophonic mode */
                if (instance.held_keys[0] >= 0)
                { /* still some keys held */
                    if (this.key != instance.held_keys[0])
                    {
                        /* most-recently-played key has changed */
                        this.key = (byte)instance.held_keys[0];
                        //DEBUG_MESSAGE(DB_NOTE, " note-off in monophonic section: changing pitch to %d\n", this.key);
                        this.mods_serial = instance.mods_serial - 1;
                        /* -FIX- dx7_portamento_prepare(instance, voice); */
                        dx7_voice_recalculate_freq_and_inc(instance);

                        /* if mono mode is 'both', re-trigger EGs */
                        if (instance.monophonic == Constants.DSSP_MONO_MODE_BOTH && !_RELEASED)
                        {
                            dx7_voice_set_phase(instance, 0);
                        }
                    }
                }
                else
                {  /* no keys still held */
                    if (instance.HEXTER_INSTANCE_SUSTAINED)
                    {
                        /* no more keys in list, but we're sustained */
                        //DEBUG_MESSAGE(DB_NOTE, " note-off in monophonic section: sustained with no held keys\n");
                        if (!_RELEASED)
                        {
                            this.status = dx7_voice_status.DX7_VOICE_SUSTAINED;
                        }
                    }
                    else
                    {  /* not sustained */
                        /* no more keys in list, so turn off note */
                        //DEBUG_MESSAGE(DB_NOTE, " note-off in monophonic section: turning off voice %p\n", voice);
                        dx7_voice_set_release_phase(instance);
                        this.status = dx7_voice_status.DX7_VOICE_RELEASED;
                    }
                }
            }
            else
            {  /* polyphonic mode */
                if (instance.HEXTER_INSTANCE_SUSTAINED)
                {
                    if (!_RELEASED)
                    {
                        this.status = dx7_voice_status.DX7_VOICE_SUSTAINED;
                    }
                }
                else
                {  /* not sustained */
                    dx7_voice_set_release_phase(instance);
                    this.status = dx7_voice_status.DX7_VOICE_RELEASED;
                }
            }
        }
Exemple #6
0
        public void dx7_voice_note_on(hexter_instance instance, byte key, byte velocity)
        {
            int i;

            this.key      = key;
            this.velocity = velocity;

            if (!(instance.monophonic != 0) || !(_ON || _SUSTAINED))
            {
                /* brand-new voice, or monophonic voice in release phase; set
                 * everything up */
                //DEBUG_MESSAGE(DB_NOTE, " dx7_voice_note_on in polyphonic/new section: key %d, mono %d, old status %d\n", key, instance.monophonic, voice.status);
                dx7_voice_setup_note(instance);
            }
            else
            {
                /* synth is monophonic, and we're modifying a playing voice */
                //DEBUG_MESSAGE(DB_NOTE, " dx7_voice_note_on in monophonic section: old key %d => new key %d\n", instance.held_keys[0], key);

                /* retrigger LFO if needed */
                dx7_lfo_set(instance);

                /* set new pitch */
                this.mods_serial = instance.mods_serial - 1;
                /* -FIX- dx7_portamento_prepare(instance, voice); */
                dx7_voice_recalculate_freq_and_inc(instance);

                /* if in 'on' or 'both' modes, and key has changed, then re-trigger EGs */
                if ((instance.monophonic == Constants.DSSP_MONO_MODE_ON ||
                     instance.monophonic == Constants.DSSP_MONO_MODE_BOTH) &&
                    (instance.held_keys[0] < 0 || instance.held_keys[0] != key))
                {
                    dx7_voice_set_phase(instance, 0);
                }

                /* all other variables stay what they are */
            }

            instance.last_key = key;

            if (instance.monophonic != 0)
            {
                /* add new key to the list of held keys */

                /* check if new key is already in the list; if so, move it to the
                 * top of the list, otherwise shift the other keys down and add it
                 * to the top of the list. */
                // DEBUG_MESSAGE(DB_NOTE, " note-on key list before: %d %d %d %d %d %d %d %d\n", instance.held_keys[0], instance.held_keys[1], instance.held_keys[2], instance.held_keys[3], instance.held_keys[4], instance.held_keys[5], instance.held_keys[6], instance.held_keys[7]);
                for (i = 0; i < 7; i++)
                {
                    if (instance.held_keys[i] == key)
                    {
                        break;
                    }
                }
                for (; i > 0; i--)
                {
                    instance.held_keys[i] = instance.held_keys[i - 1];
                }
                instance.held_keys[0] = key;
                // DEBUG_MESSAGE(DB_NOTE, " note-on key list after: %d %d %d %d %d %d %d %d\n", instance.held_keys[0], instance.held_keys[1], instance.held_keys[2], instance.held_keys[3], instance.held_keys[4], instance.held_keys[5], instance.held_keys[6], instance.held_keys[7]);
            }

            if (!_PLAYING)
            {
                dx7_voice_start_voice();
            }
            else if (!_ON)
            {  /* must be DX7_VOICE_SUSTAINED or DX7_VOICE_RELEASED */
                this.status = dx7_voice_status.DX7_VOICE_ON;
            }
        }