Diff for /np2/sound/opngenc.c between versions 1.5 and 1.7

version 1.5, 2003/10/23 15:38:13 version 1.7, 2003/11/28 08:01:33
Line 18 Line 18
   
   
         OPNCFG  opncfg;          OPNCFG  opncfg;
         SINT32  env_curve[EVC_ENT*2 + 1];  
         SINT32  envtable[EVC_ENT];  
         SINT32  sintable[SIN_ENT];  
 #ifdef OPNGENX86  #ifdef OPNGENX86
         char    envshift[EVC_ENT];          char    envshift[EVC_ENT];
         char    sinshift[SIN_ENT];          char    sinshift[SIN_ENT];
Line 71  void opngen_initialize(UINT rate) { Line 68  void opngen_initialize(UINT rate) {
                 sft = ENVTBL_BIT;                  sft = ENVTBL_BIT;
                 while(sft < (ENVTBL_BIT + 8)) {                  while(sft < (ENVTBL_BIT + 8)) {
                         pom = (double)(1 << sft) / pow(10.0, EG_STEP*(EVC_ENT-i)/20.0);                          pom = (double)(1 << sft) / pow(10.0, EG_STEP*(EVC_ENT-i)/20.0);
                         envtable[i] = (long)pom;                          opncfg.envtable[i] = (long)pom;
                         envshift[i] = sft - TL_BITS;                          envshift[i] = sft - TL_BITS;
                         if (envtable[i] >= (1 << (ENVTBL_BIT - 1))) {                          if (opncfg.envtable[i] >= (1 << (ENVTBL_BIT - 1))) {
                                 break;                                  break;
                         }                          }
                         sft++;                          sft++;
                 }                  }
 #else  #else
                 pom = (double)(1 << ENVTBL_BIT) / pow(10.0, EG_STEP*(EVC_ENT-i)/20.0);                  pom = (double)(1 << ENVTBL_BIT) / pow(10.0, EG_STEP*(EVC_ENT-i)/20.0);
                 envtable[i] = (long)pom;                  opncfg.envtable[i] = (long)pom;
 #endif  #endif
         }          }
         for (i=0; i<SIN_ENT; i++) {          for (i=0; i<SIN_ENT; i++) {
Line 89  void opngen_initialize(UINT rate) { Line 86  void opngen_initialize(UINT rate) {
                 sft = SINTBL_BIT;                  sft = SINTBL_BIT;
                 while(sft < (SINTBL_BIT + 8)) {                  while(sft < (SINTBL_BIT + 8)) {
                         pom = (double)(1 << sft) * sin(2*PI*i/SIN_ENT);                          pom = (double)(1 << sft) * sin(2*PI*i/SIN_ENT);
                         sintable[i] = (long)pom;                          opncfg.sintable[i] = (long)pom;
                         sinshift[i] = sft;                          sinshift[i] = sft;
                         if (sintable[i] >= (1 << (SINTBL_BIT - 1))) {                          if (opncfg.sintable[i] >= (1 << (SINTBL_BIT - 1))) {
                                 break;                                  break;
                         }                          }
                         if (sintable[i] <= -1 * (1 << (SINTBL_BIT - 1))) {                          if (opncfg.sintable[i] <= -1 * (1 << (SINTBL_BIT - 1))) {
                                 break;                                  break;
                         }                          }
                         sft++;                          sft++;
                 }                  }
 #else  #else
                 pom = (double)((1 << SINTBL_BIT) - 1) * sin(2*PI*i/SIN_ENT);                  pom = (double)((1 << SINTBL_BIT) - 1) * sin(2*PI*i/SIN_ENT);
                 sintable[i] = (long)pom;                                                        // ver0.27                  opncfg.sintable[i] = (long)pom;
 #endif  #endif
         }          }
         for (i=0; i<EVC_ENT; i++) {          for (i=0; i<EVC_ENT; i++) {
                 pom = pow(((double)(EVC_ENT-1-i)/EVC_ENT), 8) * EVC_ENT;                  pom = pow(((double)(EVC_ENT-1-i)/EVC_ENT), 8) * EVC_ENT;
                 env_curve[i] = (long)pom;                                                       // ver0.27                  opncfg.envcurve[i] = (long)pom;
                 env_curve[EVC_ENT + i] = i;                  opncfg.envcurve[EVC_ENT + i] = i;
         }          }
         env_curve[EVC_ENT*2] = EVC_ENT;          opncfg.envcurve[EVC_ENT*2] = EVC_ENT;
   
 //      opmbaserate = (1L << FREQ_BITS) / (rate * x / 44100) * 55466;  //      opmbaserate = (1L << FREQ_BITS) / (rate * x / 44100) * 55466;
 //      でも今は x == 55466だから…  //      でも今は x == 55466だから…
Line 150  void opngen_initialize(UINT rate) { Line 147  void opngen_initialize(UINT rate) {
                         freq *= 1.0 + (i & 3) * 0.25;                          freq *= 1.0 + (i & 3) * 0.25;
                 }                  }
                 freq *= (double)(1 << ((i >> 2) - 1));                  freq *= (double)(1 << ((i >> 2) - 1));
   #if 0
                   attacktable[i] = (long)((freq + OPM_ARRATE - 1) / OPM_ARRATE);
                   decaytable[i] = (long)((freq + OPM_DRRATE - 1) / OPM_DRRATE);
   #else
                 attacktable[i] = (long)(freq / OPM_ARRATE);                  attacktable[i] = (long)(freq / OPM_ARRATE);
                 decaytable[i] = (long)(freq / OPM_DRRATE);                  decaytable[i] = (long)(freq / OPM_DRRATE);
   #endif
                   if (attacktable[i] >= EC_DECAY) {
                           TRACEOUT(("attacktable %d %d %d", i, attacktable[i], EC_DECAY));
                   }
                   if (decaytable[i] >= EC_DECAY) {
                           TRACEOUT(("decaytable %d %d %d", i, decaytable[i], EC_DECAY));
                   }
         }          }
         attacktable[62] = EC_DECAY - 1;          attacktable[62] = EC_DECAY - 1;
         attacktable[63] = EC_DECAY - 1;          attacktable[63] = EC_DECAY - 1;
Line 187  void opngen_setVR(BYTE channel, BYTE val Line 195  void opngen_setVR(BYTE channel, BYTE val
 static void set_algorithm(OPNCH *ch) {  static void set_algorithm(OPNCH *ch) {
   
         SINT32  *outd;          SINT32  *outd;
           BYTE    outslot;
   
         outd = &opngen.outdc;          outd = &opngen.outdc;
         if (ch->stereo) {          if (ch->stereo) {
Line 205  static void set_algorithm(OPNCH *ch) { Line 214  static void set_algorithm(OPNCH *ch) {
                         ch->connect1 = &opngen.feedback2;                          ch->connect1 = &opngen.feedback2;
                         ch->connect2 = &opngen.feedback3;                          ch->connect2 = &opngen.feedback3;
                         ch->connect3 = &opngen.feedback4;                          ch->connect3 = &opngen.feedback4;
                           outslot = 0x08;
                         break;                          break;
   
                 case 1:                  case 1:
                         ch->connect1 = &opngen.feedback3;                          ch->connect1 = &opngen.feedback3;
                         ch->connect2 = &opngen.feedback3;                          ch->connect2 = &opngen.feedback3;
                         ch->connect3 = &opngen.feedback4;                          ch->connect3 = &opngen.feedback4;
                           outslot = 0x08;
                         break;                          break;
   
                 case 2:                  case 2:
                         ch->connect1 = &opngen.feedback4;                          ch->connect1 = &opngen.feedback4;
                         ch->connect2 = &opngen.feedback3;                          ch->connect2 = &opngen.feedback3;
                         ch->connect3 = &opngen.feedback4;                          ch->connect3 = &opngen.feedback4;
                           outslot = 0x08;
                         break;                          break;
   
                 case 3:                  case 3:
                         ch->connect1 = &opngen.feedback2;                          ch->connect1 = &opngen.feedback2;
                         ch->connect2 = &opngen.feedback4;                          ch->connect2 = &opngen.feedback4;
                         ch->connect3 = &opngen.feedback4;                          ch->connect3 = &opngen.feedback4;
                           outslot = 0x08;
                         break;                          break;
   
                 case 4:                  case 4:
                         ch->connect1 = &opngen.feedback2;                          ch->connect1 = &opngen.feedback2;
                         ch->connect2 = outd;                          ch->connect2 = outd;
                         ch->connect3 = &opngen.feedback4;                          ch->connect3 = &opngen.feedback4;
                           outslot = 0x0a;
                         break;                          break;
   
                 case 5:                  case 5:
                         ch->connect1 = 0;                          ch->connect1 = 0;
                         ch->connect2 = outd;                          ch->connect2 = outd;
                         ch->connect3 = outd;                          ch->connect3 = outd;
                           outslot = 0x0e;
                         break;                          break;
   
                 case 6:                  case 6:
                         ch->connect1 = &opngen.feedback2;                          ch->connect1 = &opngen.feedback2;
                         ch->connect2 = outd;                          ch->connect2 = outd;
                         ch->connect3 = outd;                          ch->connect3 = outd;
                           outslot = 0x0e;
                         break;                          break;
   
                 case 7:                  case 7:
Line 248  static void set_algorithm(OPNCH *ch) { Line 264  static void set_algorithm(OPNCH *ch) {
                         ch->connect1 = outd;                          ch->connect1 = outd;
                         ch->connect2 = outd;                          ch->connect2 = outd;
                         ch->connect3 = outd;                          ch->connect3 = outd;
                           outslot = 0x0f;
         }          }
         ch->connect4 = outd;          ch->connect4 = outd;
           ch->outslot = outslot;
 }  }
   
 static void set_dt1_mul(OPNSLOT *slot, BYTE value) {  static void set_dt1_mul(OPNSLOT *slot, BYTE value) {
Line 260  static void set_dt1_mul(OPNSLOT *slot, B Line 278  static void set_dt1_mul(OPNSLOT *slot, B
   
 static void set_tl(OPNSLOT *slot, BYTE value) {  static void set_tl(OPNSLOT *slot, BYTE value) {
   
   #if (EVC_BITS >= 7)
         slot->totallevel = ((~value) & 0x007f) << (EVC_BITS - 7);          slot->totallevel = ((~value) & 0x007f) << (EVC_BITS - 7);
   #else
           slot->totallevel = ((~value) & 0x007f) >> (7 - EVC_BITS);
   #endif
 }  }
   
 static void set_ks_ar(OPNSLOT *slot, BYTE value) {  static void set_ks_ar(OPNSLOT *slot, BYTE value) {
Line 309  static void set_d1l_rr(OPNSLOT *slot, BY Line 331  static void set_d1l_rr(OPNSLOT *slot, BY
                 if (value == 0xff) {                  if (value == 0xff) {
                         slot->env_mode = EM_OFF;                          slot->env_mode = EM_OFF;
                         slot->env_cnt = EC_OFF;                          slot->env_cnt = EC_OFF;
                         slot->env_end = EC_OFF+1;                          slot->env_end = EC_OFF + 1;
                         slot->env_inc = 0;                          slot->env_inc = 0;
                 }                  }
         }          }
Line 577  void opngen_keyon(UINT chnum, BYTE value Line 599  void opngen_keyon(UINT chnum, BYTE value
                         if (slot->env_mode > EM_RELEASE) {                          if (slot->env_mode > EM_RELEASE) {
                                 slot->env_mode = EM_RELEASE;                                  slot->env_mode = EM_RELEASE;
                                 if (!(slot->env_cnt & EC_DECAY)) {                                  if (!(slot->env_cnt & EC_DECAY)) {
                                         slot->env_cnt = (env_curve[slot->env_cnt >> ENV_BITS]                                          slot->env_cnt = (opncfg.envcurve[slot->env_cnt
                                                                                                         << ENV_BITS) + EC_DECAY;                                                                                  >> ENV_BITS] << ENV_BITS) + EC_DECAY;
                                 }                                  }
                                 slot->env_end = EC_OFF;                                  slot->env_end = EC_OFF;
                                 slot->env_inc = slot->env_inc_release;                                  slot->env_inc = slot->env_inc_release;

Removed from v.1.5  
changed lines
  Added in v.1.7


RetroPC.NET-CVS <cvs@retropc.net>