jdk/src/share/classes/com/sun/media/sound/SoftVoice.java
changeset 6502 13b20559a04a
parent 5506 202f599c92aa
child 7668 d4a77089c587
equal deleted inserted replaced
6501:684810d882b3 6502:13b20559a04a
   277         connections_last[ix] = value;
   277         connections_last[ix] = value;
   278         // co_mixer_gain[0] = 0;
   278         // co_mixer_gain[0] = 0;
   279     }
   279     }
   280 
   280 
   281     protected void updateTuning(SoftTuning newtuning) {
   281     protected void updateTuning(SoftTuning newtuning) {
       
   282         tuning = newtuning;
   282         tunedKey = tuning.getTuning(note) / 100.0;
   283         tunedKey = tuning.getTuning(note) / 100.0;
   283         if (!portamento) {
   284         if (!portamento) {
   284             co_noteon_keynumber[0] = tunedKey * (1.0 / 128.0);
   285             co_noteon_keynumber[0] = tunedKey * (1.0 / 128.0);
       
   286             if(performer == null)
       
   287                 return;
   285             int[] c = performer.midi_connections[4];
   288             int[] c = performer.midi_connections[4];
   286             if (c == null)
   289             if (c == null)
   287                 return;
   290                 return;
   288             for (int i = 0; i < c.length; i++)
   291             for (int i = 0; i < c.length; i++)
   289                 processConnection(c[i]);
   292                 processConnection(c[i]);
   431         lfo.init(synthesizer);
   434         lfo.init(synthesizer);
   432 
   435 
   433     }
   436     }
   434 
   437 
   435     protected void setPolyPressure(int pressure) {
   438     protected void setPolyPressure(int pressure) {
       
   439         if(performer == null)
       
   440             return;
   436         int[] c = performer.midi_connections[2];
   441         int[] c = performer.midi_connections[2];
   437         if (c == null)
   442         if (c == null)
   438             return;
   443             return;
   439         for (int i = 0; i < c.length; i++)
   444         for (int i = 0; i < c.length; i++)
   440             processConnection(c[i]);
   445             processConnection(c[i]);
   441     }
   446     }
   442 
   447 
   443     protected void setChannelPressure(int pressure) {
   448     protected void setChannelPressure(int pressure) {
       
   449         if(performer == null)
       
   450             return;
   444         int[] c = performer.midi_connections[1];
   451         int[] c = performer.midi_connections[1];
   445         if (c == null)
   452         if (c == null)
   446             return;
   453             return;
   447         for (int i = 0; i < c.length; i++)
   454         for (int i = 0; i < c.length; i++)
   448             processConnection(c[i]);
   455             processConnection(c[i]);
   449     }
   456     }
   450 
   457 
   451     protected void controlChange(int controller, int value) {
   458     protected void controlChange(int controller, int value) {
       
   459         if(performer == null)
       
   460             return;
   452         int[] c = performer.midi_ctrl_connections[controller];
   461         int[] c = performer.midi_ctrl_connections[controller];
   453         if (c == null)
   462         if (c == null)
   454             return;
   463             return;
   455         for (int i = 0; i < c.length; i++)
   464         for (int i = 0; i < c.length; i++)
   456             processConnection(c[i]);
   465             processConnection(c[i]);
   457     }
   466     }
   458 
   467 
   459     protected void nrpnChange(int controller, int value) {
   468     protected void nrpnChange(int controller, int value) {
       
   469         if(performer == null)
       
   470             return;
   460         int[] c = performer.midi_nrpn_connections.get(controller);
   471         int[] c = performer.midi_nrpn_connections.get(controller);
   461         if (c == null)
   472         if (c == null)
   462             return;
   473             return;
   463         for (int i = 0; i < c.length; i++)
   474         for (int i = 0; i < c.length; i++)
   464             processConnection(c[i]);
   475             processConnection(c[i]);
   465     }
   476     }
   466 
   477 
   467     protected void rpnChange(int controller, int value) {
   478     protected void rpnChange(int controller, int value) {
       
   479         if(performer == null)
       
   480             return;
   468         int[] c = performer.midi_rpn_connections.get(controller);
   481         int[] c = performer.midi_rpn_connections.get(controller);
   469         if (c == null)
   482         if (c == null)
   470             return;
   483             return;
   471         for (int i = 0; i < c.length; i++)
   484         for (int i = 0; i < c.length; i++)
   472             processConnection(c[i]);
   485             processConnection(c[i]);
   473     }
   486     }
   474 
   487 
   475     protected void setPitchBend(int bend) {
   488     protected void setPitchBend(int bend) {
       
   489         if(performer == null)
       
   490             return;
   476         int[] c = performer.midi_connections[0];
   491         int[] c = performer.midi_connections[0];
   477         if (c == null)
   492         if (c == null)
   478             return;
   493             return;
   479         for (int i = 0; i < c.length; i++)
   494         for (int i = 0; i < c.length; i++)
   480             processConnection(c[i]);
   495             processConnection(c[i]);
   497             return;
   512             return;
   498         on = false;
   513         on = false;
   499 
   514 
   500         co_noteon_on[0] = -1;
   515         co_noteon_on[0] = -1;
   501 
   516 
       
   517         if(performer == null)
       
   518             return;
   502         int[] c = performer.midi_connections[3];
   519         int[] c = performer.midi_connections[3];
   503         if (c == null)
   520         if (c == null)
   504             return;
   521             return;
   505         for (int i = 0; i < c.length; i++)
   522         for (int i = 0; i < c.length; i++)
   506             processConnection(c[i]);
   523             processConnection(c[i]);
   525         if (sostenuto)
   542         if (sostenuto)
   526             return;
   543             return;
   527 
   544 
   528         co_noteon_on[0] = 0;
   545         co_noteon_on[0] = 0;
   529 
   546 
       
   547         if(performer == null)
       
   548             return;
   530         int[] c = performer.midi_connections[3];
   549         int[] c = performer.midi_connections[3];
   531         if (c == null)
   550         if (c == null)
   532             return;
   551             return;
   533         for (int i = 0; i < c.length; i++)
   552         for (int i = 0; i < c.length; i++)
   534             processConnection(c[i]);
   553             processConnection(c[i]);
   541             return; // don't redamp notes in shutdown stage
   560             return; // don't redamp notes in shutdown stage
   542 
   561 
   543         sustain = true;
   562         sustain = true;
   544         co_noteon_on[0] = 1;
   563         co_noteon_on[0] = 1;
   545 
   564 
       
   565         if(performer == null)
       
   566             return;
   546         int[] c = performer.midi_connections[3];
   567         int[] c = performer.midi_connections[3];
   547         if (c == null)
   568         if (c == null)
   548             return;
   569             return;
   549         for (int i = 0; i < c.length; i++)
   570         for (int i = 0; i < c.length; i++)
   550             processConnection(c[i]);
   571             processConnection(c[i]);
   553     protected void processControlLogic() {
   574     protected void processControlLogic() {
   554         if (stopping) {
   575         if (stopping) {
   555             active = false;
   576             active = false;
   556             stopping = false;
   577             stopping = false;
   557             audiostarted = false;
   578             audiostarted = false;
       
   579             instrument = null;
       
   580             performer = null;
       
   581             connections = null;
       
   582             extendedConnectionBlocks = null;
       
   583             channelmixer = null;
   558             if (osc_stream != null)
   584             if (osc_stream != null)
   559                 try {
   585                 try {
   560                     osc_stream.close();
   586                     osc_stream.close();
   561                 } catch (IOException e) {
   587                 } catch (IOException e) {
   562                     //e.printStackTrace();
   588                     //e.printStackTrace();