Previous 199869 Revisions Next

r23993 Friday 28th June, 2013 at 13:53:49 UTC by hap
moved tables to classroom
[src/emu/sound]ymf271.c ymf271.h

trunk/src/emu/sound/ymf271.c
r23992r23993
2020    - ch2/ch3 (4 speakers)
2121    - PFM (FM using external PCM waveform)
2222    - detune
23    - Acc On bit
23    - Acc On bit (some sound effects in viprp1?)
2424    - Is memory handling 100% correct? At the moment, seibuspi.c is the only
2525      hardware currently emulated that uses external handlers.
2626*/
r23992r23993
2828#include "emu.h"
2929#include "ymf271.h"
3030
31#define STD_CLOCK       (16934400)
32
3133#define MAXOUT          (+32767)
3234#define MINOUT          (-32768)
3335
r23992r23993
4244#define ALFO_MAX        (+65536)
4345#define ALFO_MIN        (0)
4446
45// slot mapping assists
46static const int fm_tab[16] = { 0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1 };
47static const int pcm_tab[16] = { 0, 4, 8, -1, 12, 16, 20, -1, 24, 28, 32, -1, 36, 40, 44, -1 };
48
49static INT16 wavetable[8][SIN_LEN];
50static double plfo_table[4][8][LFO_LENGTH];
51static int alfo_table[4][LFO_LENGTH];
52
5347#define ENV_ATTACK      0
5448#define ENV_DECAY1      1
5549#define ENV_DECAY2      2
r23992r23993
185179   {  0,  3,  7, 15, 31, 31, 31, 31 },
186180};
187181
182static const double multiple_table[16] = { 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
183
184static const double pow_table[16] = { 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 0.5, 1, 2, 4, 8, 16, 32, 64 };
185
186static const double fs_frequency[4] = { 1.0/1.0, 1.0/2.0, 1.0/4.0, 1.0/8.0 };
187
188188static const double channel_attenuation_table[16] =
189189{
190190   0.0, 2.5, 6.0, 8.5, 12.0, 14.5, 18.1, 20.6, 24.1, 26.6, 30.1, 32.6, 36.1, 96.1, 96.1, 96.1
r23992r23993
195195// feedback_level * 16
196196static const int feedback_level[8] = { 0, 1, 2, 4, 8, 16, 32, 64 };
197197
198static int channel_attenuation[16];
199static int total_level[128];
200static int env_volume_table[256];
198// slot mapping assists
199static const int fm_tab[16] = { 0, 1, 2, -1, 3, 4, 5, -1, 6, 7, 8, -1, 9, 10, 11, -1 };
200static const int pcm_tab[16] = { 0, 4, 8, -1, 12, 16, 20, -1, 24, 28, 32, -1, 36, 40, 44, -1 };
201201
202202
203/*****************************************************************************/
204
203205INLINE int GET_KEYSCALED_RATE(int rate, int keycode, int keyscale)
204206{
205207   int newrate = rate + RKS_Table[keycode][keyscale];
r23992r23993
261263   return ((block & 7) * 4) + n43;
262264}
263265
264static const double multiple_table[16] = { 0.5, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15 };
265
266static const double pow_table[16] = { 128, 256, 512, 1024, 2048, 4096, 8192, 16384, 0.5, 1, 2, 4, 8, 16, 32, 64 };
267
268static const double fs_frequency[4] = { 1.0/1.0, 1.0/2.0, 1.0/4.0, 1.0/8.0 };
269
270266void ymf271_device::calculate_step(YMF271Slot *slot)
271267{
272268   double st;
r23992r23993
356352   int keycode, rate;
357353   int decay_level = 255 - (slot->decay1lvl << 4);
358354
359   double time;
360
361355   if (slot->waveform != 7)
362356   {
363357      keycode = GET_INTERNAL_KEYCODE(slot->block, slot->fns);
r23992r23993
370364
371365   // init attack state
372366   rate = GET_KEYSCALED_RATE(slot->ar * 2, keycode, slot->keyscale);
373   time = (ARTime[rate] * 44100.0) / 1000.0;        // attack end time in samples
374   slot->env_attack_step = time < 0 ? 0 : (int)(((double)(255-0) / time) * 65536.0);
367   slot->env_attack_step = (rate < 4) ? 0 : (int)(((double)(255-0) / m_lut_ar[rate]) * 65536.0);
375368
376369   // init decay1 state
377370   rate = GET_KEYSCALED_RATE(slot->decay1rate * 2, keycode, slot->keyscale);
378   time = (DCTime[rate] * 44100.0) / 1000.0;
379   slot->env_decay1_step = time < 0 ? 0 : (int)(((double)(255-decay_level) / time) * 65536.0);
371   slot->env_decay1_step = (rate < 4) ? 0 : (int)(((double)(255-decay_level) / m_lut_dc[rate]) * 65536.0);
380372
381373   // init decay2 state
382374   rate = GET_KEYSCALED_RATE(slot->decay2rate * 2, keycode, slot->keyscale);
383   time = (DCTime[rate] * 44100.0) / 1000.0;
384   slot->env_decay2_step = time < 0 ? 0 : (int)(((double)(255-0) / time) * 65536.0);
375   slot->env_decay2_step = (rate < 4) ? 0 : (int)(((double)(255-0) / m_lut_dc[rate]) * 65536.0);
385376
386377   // init release state
387378   rate = GET_KEYSCALED_RATE(slot->relrate * 4, keycode, slot->keyscale);
388   time = (ARTime[rate] * 44100.0) / 1000.0;
389   slot->env_release_step = time < 0 ? 0 : (int)(((double)(255-0) / time) * 65536.0);
379   slot->env_release_step = (rate < 4) ? 0 : (int)(((double)(255-0) / m_lut_ar[rate]) * 65536.0);
390380
391381   slot->volume = (255-160) << ENV_VOLUME_SHIFT;       // -60db
392382   slot->env_state = ENV_ATTACK;
r23992r23993
398388   slot->lfo_amplitude = 0;
399389   slot->lfo_phasemod = 0;
400390
401   slot->lfo_step = (int)((((double)LFO_LENGTH * LFO_frequency_table[slot->lfoFreq]) / 44100.0) * 256.0);
391   slot->lfo_step = (int)((((double)LFO_LENGTH * m_lut_lfo[slot->lfoFreq]) / 44100.0) * 256.0);
402392}
403393
404394void ymf271_device::update_lfo(YMF271Slot *slot)
405395{
406396   slot->lfo_phase += slot->lfo_step;
407397
408   slot->lfo_amplitude = alfo_table[slot->lfowave][(slot->lfo_phase >> LFO_SHIFT) & (LFO_LENGTH-1)];
409   slot->lfo_phasemod = plfo_table[slot->lfowave][slot->pms][(slot->lfo_phase >> LFO_SHIFT) & (LFO_LENGTH-1)];
398   slot->lfo_amplitude = m_lut_alfo[slot->lfowave][(slot->lfo_phase >> LFO_SHIFT) & (LFO_LENGTH-1)];
399   slot->lfo_phasemod = m_lut_plfo[slot->lfowave][slot->pms][(slot->lfo_phase >> LFO_SHIFT) & (LFO_LENGTH-1)];
410400
411401   calculate_step(slot);
412402}
r23992r23993
425415      case 3: lfo_volume = 65536 - ((slot->lfo_amplitude * 4277) >> 16); break;   // 23.625dB
426416   }
427417
428   env_volume = (env_volume_table[255 - (slot->volume >> ENV_VOLUME_SHIFT)] * lfo_volume) >> 16;
418   env_volume = (m_lut_env_volume[255 - (slot->volume >> ENV_VOLUME_SHIFT)] * lfo_volume) >> 16;
429419
430   volume = (env_volume * total_level[slot->tl]) >> 16;
420   volume = (env_volume * m_lut_total_level[slot->tl]) >> 16;
431421
432422   return volume;
433423}
r23992r23993
472462
473463      final_volume = calculate_slot_volume(slot);
474464
475      ch0_vol = (final_volume * channel_attenuation[slot->ch0_level]) >> 16;
476      ch1_vol = (final_volume * channel_attenuation[slot->ch1_level]) >> 16;
477//      ch2_vol = (final_volume * channel_attenuation[slot->ch2_level]) >> 16;
478//      ch3_vol = (final_volume * channel_attenuation[slot->ch3_level]) >> 16;
465      ch0_vol = (final_volume * m_lut_attenuation[slot->ch0_level]) >> 16;
466      ch1_vol = (final_volume * m_lut_attenuation[slot->ch1_level]) >> 16;
467//      ch2_vol = (final_volume * m_lut_attenuation[slot->ch2_level]) >> 16;
468//      ch3_vol = (final_volume * m_lut_attenuation[slot->ch3_level]) >> 16;
479469
480470      if (ch0_vol > 65536) ch0_vol = 65536;
481471      if (ch1_vol > 65536) ch1_vol = 65536;
r23992r23993
515505   feedback = (slot1->feedback_modulation0 + slot1->feedback_modulation1) / 2;
516506   slot1->feedback_modulation0 = slot1->feedback_modulation1;
517507
518   slot1_output = wavetable[slot1->waveform][((slot1->stepptr + feedback) >> 16) & SIN_MASK];
508   slot1_output = m_lut_waves[slot1->waveform][((slot1->stepptr + feedback) >> 16) & SIN_MASK];
519509   slot1_output = (slot1_output * env1) >> 16;
520510
521511   phase_mod = ((slot1_output << (SIN_BITS-2)) * modulation_level[slot2->feedback]);
522   slot2_output = wavetable[slot2->waveform][((slot2->stepptr + phase_mod) >> 16) & SIN_MASK];
512   slot2_output = m_lut_waves[slot2->waveform][((slot2->stepptr + phase_mod) >> 16) & SIN_MASK];
523513   slot2_output = (slot2_output * env2) >> 16;
524514
525515   slot1->feedback_modulation1 = (((slot1_output << (SIN_BITS-2)) * feedback_level[slot1->feedback]) / 16);
r23992r23993
552542   feedback = (slot1->feedback_modulation0 + slot1->feedback_modulation1) / 2;
553543   slot1->feedback_modulation0 = slot1->feedback_modulation1;
554544
555   slot1_output = wavetable[slot1->waveform][((slot1->stepptr + feedback) >> 16) & SIN_MASK];
545   slot1_output = m_lut_waves[slot1->waveform][((slot1->stepptr + feedback) >> 16) & SIN_MASK];
556546   slot1_output = (slot1_output * env1) >> 16;
557547
558548   phase_mod = ((slot1_output << (SIN_BITS-2)) * modulation_level[slot2->feedback]);
559   slot2_output = wavetable[slot2->waveform][((slot2->stepptr + phase_mod) >> 16) & SIN_MASK];
549   slot2_output = m_lut_waves[slot2->waveform][((slot2->stepptr + phase_mod) >> 16) & SIN_MASK];
560550   slot2_output = (slot2_output * env2) >> 16;
561551
562552   slot1->feedback_modulation1 = (((slot2_output << (SIN_BITS-2)) * feedback_level[slot1->feedback]) / 16);
r23992r23993
581571
582572   phase_mod = ((phase_mod << (SIN_BITS-2)) * modulation_level[slot->feedback]);
583573
584   slot_output = wavetable[slot->waveform][((slot->stepptr + phase_mod) >> 16) & SIN_MASK];
574   slot_output = m_lut_waves[slot->waveform][((slot->stepptr + phase_mod) >> 16) & SIN_MASK];
585575   slot->stepptr += slot->step;
586576
587577   slot_output = (slot_output * env) >> 16;
r23992r23993
606596   feedback = slot->feedback_modulation0 + slot->feedback_modulation1;
607597   slot->feedback_modulation0 = slot->feedback_modulation1;
608598
609   slot_output = wavetable[slot->waveform][((slot->stepptr + feedback) >> 16) & SIN_MASK];
599   slot_output = m_lut_waves[slot->waveform][((slot->stepptr + feedback) >> 16) & SIN_MASK];
610600   slot_output = (slot_output * env) >> 16;
611601
612602   slot->feedback_modulation1 = (((slot_output << (SIN_BITS-2)) * feedback_level[slot->feedback]) / 16);
r23992r23993
813803                        break;
814804                  }
815805
816                  *mixp++ += ((output1 * channel_attenuation[m_slots[slot1].ch0_level]) +
817                           (output2 * channel_attenuation[m_slots[slot2].ch0_level]) +
818                           (output3 * channel_attenuation[m_slots[slot3].ch0_level]) +
819                           (output4 * channel_attenuation[m_slots[slot4].ch0_level])) >> 16;
820                  *mixp++ += ((output1 * channel_attenuation[m_slots[slot1].ch1_level]) +
821                           (output2 * channel_attenuation[m_slots[slot2].ch1_level]) +
822                           (output3 * channel_attenuation[m_slots[slot3].ch1_level]) +
823                           (output4 * channel_attenuation[m_slots[slot4].ch1_level])) >> 16;
806                  *mixp++ += ((output1 * m_lut_attenuation[m_slots[slot1].ch0_level]) +
807                           (output2 * m_lut_attenuation[m_slots[slot2].ch0_level]) +
808                           (output3 * m_lut_attenuation[m_slots[slot3].ch0_level]) +
809                           (output4 * m_lut_attenuation[m_slots[slot4].ch0_level])) >> 16;
810                  *mixp++ += ((output1 * m_lut_attenuation[m_slots[slot1].ch1_level]) +
811                           (output2 * m_lut_attenuation[m_slots[slot2].ch1_level]) +
812                           (output3 * m_lut_attenuation[m_slots[slot3].ch1_level]) +
813                           (output4 * m_lut_attenuation[m_slots[slot4].ch1_level])) >> 16;
824814               }
825815            }
826816            break;
r23992r23993
870860                           break;
871861                     }
872862
873                     *mixp++ += ((output1 * channel_attenuation[m_slots[slot1].ch0_level]) +
874                              (output2 * channel_attenuation[m_slots[slot2].ch0_level])) >> 16;
875                     *mixp++ += ((output1 * channel_attenuation[m_slots[slot1].ch1_level]) +
876                              (output2 * channel_attenuation[m_slots[slot2].ch1_level])) >> 16;
863                     *mixp++ += ((output1 * m_lut_attenuation[m_slots[slot1].ch0_level]) +
864                              (output2 * m_lut_attenuation[m_slots[slot2].ch0_level])) >> 16;
865                     *mixp++ += ((output1 * m_lut_attenuation[m_slots[slot1].ch1_level]) +
866                              (output2 * m_lut_attenuation[m_slots[slot2].ch1_level])) >> 16;
877867                  }
878868               }
879869            }
r23992r23993
962952                        break;
963953                  }
964954
965                  *mixp++ += ((output1 * channel_attenuation[m_slots[slot1].ch0_level]) +
966                           (output2 * channel_attenuation[m_slots[slot2].ch0_level]) +
967                           (output3 * channel_attenuation[m_slots[slot3].ch0_level])) >> 16;
968                  *mixp++ += ((output1 * channel_attenuation[m_slots[slot1].ch1_level]) +
969                           (output2 * channel_attenuation[m_slots[slot2].ch1_level]) +
970                           (output3 * channel_attenuation[m_slots[slot3].ch1_level])) >> 16;
955                  *mixp++ += ((output1 * m_lut_attenuation[m_slots[slot1].ch0_level]) +
956                           (output2 * m_lut_attenuation[m_slots[slot2].ch0_level]) +
957                           (output3 * m_lut_attenuation[m_slots[slot3].ch0_level])) >> 16;
958                  *mixp++ += ((output1 * m_lut_attenuation[m_slots[slot1].ch1_level]) +
959                           (output2 * m_lut_attenuation[m_slots[slot2].ch1_level]) +
960                           (output3 * m_lut_attenuation[m_slots[slot3].ch1_level])) >> 16;
971961               }
972962            }
973963
r23992r23993
15151505   return 0;
15161506}
15171507
1518static void init_tables(running_machine &machine)
1508void ymf271_device::init_tables()
15191509{
1520   int i,j;
1510   int i, j;
1511   
1512   for (i = 0; i < 8; i++)
1513      m_lut_waves[i] = auto_alloc_array(machine(), INT16, SIN_LEN);
1514   
1515   for (i = 0; i < 4*8; i++)
1516      m_lut_plfo[i>>3][i&7] = auto_alloc_array(machine(), double, LFO_LENGTH);
15211517
1522   for (i=0; i < SIN_LEN; i++)
1518   for (i = 0; i < 4; i++)
1519      m_lut_alfo[i] = auto_alloc_array(machine(), int, LFO_LENGTH);
1520
1521   for (i = 0; i < SIN_LEN; i++)
15231522   {
15241523      double m = sin( ((i*2)+1) * M_PI / SIN_LEN );
15251524      double m2 = sin( ((i*4)+1) * M_PI / SIN_LEN );
15261525
15271526      // Waveform 0: sin(wt)    (0 <= wt <= 2PI)
1528      wavetable[0][i] = (INT16)(m * MAXOUT);
1527      m_lut_waves[0][i] = (INT16)(m * MAXOUT);
15291528
15301529      // Waveform 1: sin?(wt)   (0 <= wt <= PI)     -sin?(wt)  (PI <= wt <= 2PI)
1531      wavetable[1][i] = (i < (SIN_LEN/2)) ? (INT16)((m * m) * MAXOUT) : (INT16)((m * m) * MINOUT);
1530      m_lut_waves[1][i] = (i < (SIN_LEN/2)) ? (INT16)((m * m) * MAXOUT) : (INT16)((m * m) * MINOUT);
15321531
15331532      // Waveform 2: sin(wt)    (0 <= wt <= PI)     -sin(wt)   (PI <= wt <= 2PI)
1534      wavetable[2][i] = (i < (SIN_LEN/2)) ? (INT16)(m * MAXOUT) : (INT16)(-m * MAXOUT);
1533      m_lut_waves[2][i] = (i < (SIN_LEN/2)) ? (INT16)(m * MAXOUT) : (INT16)(-m * MAXOUT);
15351534
15361535      // Waveform 3: sin(wt)    (0 <= wt <= PI)     0
1537      wavetable[3][i] = (i < (SIN_LEN/2)) ? (INT16)(m * MAXOUT) : 0;
1536      m_lut_waves[3][i] = (i < (SIN_LEN/2)) ? (INT16)(m * MAXOUT) : 0;
15381537
15391538      // Waveform 4: sin(2wt)   (0 <= wt <= PI)     0
1540      wavetable[4][i] = (i < (SIN_LEN/2)) ? (INT16)(m2 * MAXOUT) : 0;
1539      m_lut_waves[4][i] = (i < (SIN_LEN/2)) ? (INT16)(m2 * MAXOUT) : 0;
15411540
15421541      // Waveform 5: |sin(2wt)| (0 <= wt <= PI)     0
1543      wavetable[5][i] = (i < (SIN_LEN/2)) ? (INT16)(fabs(m2) * MAXOUT) : 0;
1542      m_lut_waves[5][i] = (i < (SIN_LEN/2)) ? (INT16)(fabs(m2) * MAXOUT) : 0;
15441543
15451544      // Waveform 6:     1      (0 <= wt <= 2PI)
1546      wavetable[6][i] = (INT16)(1 * MAXOUT);
1545      m_lut_waves[6][i] = (INT16)(1 * MAXOUT);
15471546
1548      wavetable[7][i] = 0;
1547      m_lut_waves[7][i] = 0;
15491548   }
15501549
1551   for (i=0; i < LFO_LENGTH; i++)
1550   for (i = 0; i < LFO_LENGTH; i++)
15521551   {
15531552      int tri_wave;
15541553      double ftri_wave, fsaw_wave;
r23992r23993
15691568         case 1: plfo[3] = PLFO_MAX - ftri_wave; break;
15701569         case 2: plfo[3] = 0 - ftri_wave; break;
15711570         case 3: plfo[3] = 0 - (PLFO_MAX - ftri_wave); break;
1572         default: plfo[3]=0; assert(0); break;
1571         default: plfo[3] = 0; assert(0); break;
15731572      }
15741573
1575      for (j=0; j < 4; j++)
1574      for (j = 0; j < 4; j++)
15761575      {
1577         plfo_table[j][0][i] = pow(2.0, 0.0);
1578         plfo_table[j][1][i] = pow(2.0, (3.378 * plfo[j]) / 1200.0);
1579         plfo_table[j][2][i] = pow(2.0, (5.0646 * plfo[j]) / 1200.0);
1580         plfo_table[j][3][i] = pow(2.0, (6.7495 * plfo[j]) / 1200.0);
1581         plfo_table[j][4][i] = pow(2.0, (10.1143 * plfo[j]) / 1200.0);
1582         plfo_table[j][5][i] = pow(2.0, (20.1699 * plfo[j]) / 1200.0);
1583         plfo_table[j][6][i] = pow(2.0, (40.1076 * plfo[j]) / 1200.0);
1584         plfo_table[j][7][i] = pow(2.0, (79.307 * plfo[j]) / 1200.0);
1576         m_lut_plfo[j][0][i] = pow(2.0, 0.0);
1577         m_lut_plfo[j][1][i] = pow(2.0, (3.378 * plfo[j]) / 1200.0);
1578         m_lut_plfo[j][2][i] = pow(2.0, (5.0646 * plfo[j]) / 1200.0);
1579         m_lut_plfo[j][3][i] = pow(2.0, (6.7495 * plfo[j]) / 1200.0);
1580         m_lut_plfo[j][4][i] = pow(2.0, (10.1143 * plfo[j]) / 1200.0);
1581         m_lut_plfo[j][5][i] = pow(2.0, (20.1699 * plfo[j]) / 1200.0);
1582         m_lut_plfo[j][6][i] = pow(2.0, (40.1076 * plfo[j]) / 1200.0);
1583         m_lut_plfo[j][7][i] = pow(2.0, (79.307 * plfo[j]) / 1200.0);
15851584      }
15861585
15871586      // LFO amplitude modulation
1588      alfo_table[0][i] = 0;
1587      m_lut_alfo[0][i] = 0;
15891588
1590      alfo_table[1][i] = ALFO_MAX - ((i * ALFO_MAX) / LFO_LENGTH);
1589      m_lut_alfo[1][i] = ALFO_MAX - ((i * ALFO_MAX) / LFO_LENGTH);
15911590
1592      alfo_table[2][i] = (i < (LFO_LENGTH/2)) ? ALFO_MAX : ALFO_MIN;
1591      m_lut_alfo[2][i] = (i < (LFO_LENGTH/2)) ? ALFO_MAX : ALFO_MIN;
15931592
15941593      tri_wave = ((i % (LFO_LENGTH/2)) * ALFO_MAX) / (LFO_LENGTH/2);
1595      alfo_table[3][i] = (i < (LFO_LENGTH/2)) ? ALFO_MAX-tri_wave : tri_wave;
1594      m_lut_alfo[3][i] = (i < (LFO_LENGTH/2)) ? ALFO_MAX-tri_wave : tri_wave;
15961595   }
1596
1597   for (i = 0; i < 256; i++)
1598   {
1599      m_lut_env_volume[i] = (int)(65536.0 / pow(10.0, ((double)i / (256.0 / 96.0)) / 20.0));
1600   }
1601
1602   for (i = 0; i < 16; i++)
1603   {
1604      m_lut_attenuation[i] = (int)(65536.0 / pow(10.0, channel_attenuation_table[i] / 20.0));
1605   }
1606   for (i = 0; i < 128; i++)
1607   {
1608      double db = 0.75 * (double)i;
1609      m_lut_total_level[i] = (int)(65536.0 / pow(10.0, db / 20.0));
1610   }
1611   
1612   // timing may use a non-standard XTAL
1613   double clock_correction = (double)(STD_CLOCK) / (double)(m_clock);
1614   for (i = 0; i < 256; i++)
1615   {
1616      m_lut_lfo[i] = LFO_frequency_table[i] * clock_correction;
1617   }
1618
1619   for (i = 0; i < 64; i++)
1620   {
1621      // attack/release rate in number of samples
1622      m_lut_ar[i] = (ARTime[i] * clock_correction * 44100.0) / 1000.0;
1623   }
1624   for (i = 0; i < 64; i++)
1625   {
1626      // decay rate in number of samples
1627      m_lut_dc[i] = (DCTime[i] * clock_correction * 44100.0) / 1000.0;
1628   }
15971629}
15981630
15991631void ymf271_device::init_state()
r23992r23993
16781710
16791711void ymf271_device::device_start()
16801712{
1681   int i;
1682
16831713   m_clock = clock();
16841714
16851715   m_timA = timer_alloc(0);
r23992r23993
16921722   m_ext_read_handler.resolve();
16931723   m_ext_write_handler.resolve();
16941724
1695   init_tables(machine());
1725   init_tables();
16961726   init_state();
16971727
16981728   m_stream = machine().sound().stream_alloc(*this, 0, 2, clock()/384);
16991729   m_mix_buffer = auto_alloc_array(machine(), INT32, 44100*2);
1700
1701   for (i = 0; i < 256; i++)
1702   {
1703      env_volume_table[i] = (int)(65536.0 / pow(10.0, ((double)i / (256.0 / 96.0)) / 20.0));
1704   }
1705
1706   for (i = 0; i < 16; i++)
1707   {
1708      channel_attenuation[i] = (int)(65536.0 / pow(10.0, channel_attenuation_table[i] / 20.0));
1709   }
1710   for (i = 0; i < 128; i++)
1711   {
1712      double db = 0.75 * (double)i;
1713      total_level[i] = (int)(65536.0 / pow(10.0, db / 20.0));
1714   }
17151730}
17161731
17171732//-------------------------------------------------
trunk/src/emu/sound/ymf271.h
r23992r23993
9696   };
9797
9898   void init_state();
99   void init_tables();
99100   void calculate_step(YMF271Slot *slot);
100101   void update_envelope(YMF271Slot *slot);
101102   void init_envelope(YMF271Slot *slot);
r23992r23993
112113   void ymf271_write_pcm(UINT8 data);
113114   UINT8 ymf271_read_memory(UINT32 offset);
114115   void ymf271_write_timer(UINT8 data);
115
116   
117   // lookup tables
118   INT16 *m_lut_waves[8];
119   double *m_lut_plfo[4][8];
120   int *m_lut_alfo[4];
121   double m_lut_ar[64];
122   double m_lut_dc[64];
123   double m_lut_lfo[256];
124   int m_lut_attenuation[16];
125   int m_lut_total_level[128];
126   int m_lut_env_volume[256];
127   
116128   // internal state
117129   YMF271Slot m_slots[48];
118130   YMF271Group m_groups[12];

Previous 199869 Revisions Next


© 1997-2024 The MAME Team