声音stream 全局指针读取

This commit is contained in:
sin365 2025-01-19 21:26:46 +08:00
parent 703a726953
commit aef97c8eeb
20 changed files with 285 additions and 234 deletions

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class AY8910 public unsafe class AY8910
{ {
public struct _ay_ym_param public struct _ay_ym_param
{ {
@ -383,7 +383,7 @@ namespace MAME.Core
{ {
for (j = 0; j < length; j++) for (j = 0; j < length; j++)
{ {
stream.streamoutput[chan][offset + j] = 0; stream.streamoutput_Ptrs[chan][offset + j] = 0;
} }
} }
} }
@ -453,18 +453,18 @@ namespace MAME.Core
if (TONE_ENVELOPE(chan) != 0) if (TONE_ENVELOPE(chan) != 0)
{ {
int i1 = ay8910info.env_table[chan][ay8910info.vol_enabled[chan] != 0 ? ay8910info.env_volume : 0]; int i1 = ay8910info.env_table[chan][ay8910info.vol_enabled[chan] != 0 ? ay8910info.env_volume : 0];
stream.streamoutput[chan][offset] = ay8910info.env_table[chan][ay8910info.vol_enabled[chan] != 0 ? ay8910info.env_volume : 0]; stream.streamoutput_Ptrs[chan][offset] = ay8910info.env_table[chan][ay8910info.vol_enabled[chan] != 0 ? ay8910info.env_volume : 0];
} }
else else
{ {
int i1 = ay8910info.vol_table[chan][ay8910info.vol_enabled[chan] != 0 ? TONE_VOLUME(chan) : 0]; int i1 = ay8910info.vol_table[chan][ay8910info.vol_enabled[chan] != 0 ? TONE_VOLUME(chan) : 0];
stream.streamoutput[chan][offset] = ay8910info.vol_table[chan][ay8910info.vol_enabled[chan] != 0 ? TONE_VOLUME(chan) : 0]; stream.streamoutput_Ptrs[chan][offset] = ay8910info.vol_table[chan][ay8910info.vol_enabled[chan] != 0 ? TONE_VOLUME(chan) : 0];
} }
} }
} }
else else
{ {
stream.streamoutput[0][offset] = mix_3D(); stream.streamoutput_Ptrs[0][offset] = mix_3D();
} }
offset++; offset++;
} }

View File

@ -12,14 +12,14 @@ namespace MAME.Core
public short[] SignedVolTable; public short[] SignedVolTable;
}; };
public static dac_info dac1; public static dac_info dac1;
public static void DAC_update(int offset, int length) public unsafe static void DAC_update(int offset, int length)
{ {
; ;
short out1 = dac1.output; short out1 = dac1.output;
int i; int i;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.dacstream.streamoutput[0][offset + i] = out1; Sound.dacstream.streamoutput_Ptrs[0][offset + i] = out1;
} }
} }
public static void dac_signed_data_w(int num, byte data) public static void dac_signed_data_w(int num, byte data)

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class FMOpl public unsafe class FMOpl
{ {
public struct OPL_SLOT public struct OPL_SLOT
{ {
@ -1260,7 +1260,7 @@ namespace MAME.Core
} }
lt = output0; lt = output0;
lt = limit(lt, 32767, -32768); lt = limit(lt, 32767, -32768);
Sound.ym3812stream.streamoutput[0][offset + i] = lt; Sound.ym3812stream.streamoutput_Ptrs[0][offset + i] = lt;
YM3812.advance(); YM3812.advance();
} }
} }
@ -1330,7 +1330,7 @@ namespace MAME.Core
} }
lt = output0; lt = output0;
lt = limit(lt, 32767, -32768); lt = limit(lt, 32767, -32768);
Sound.ym3526stream.streamoutput[0][offset + i] = lt; Sound.ym3526stream.streamoutput_Ptrs[0][offset + i] = lt;
YM3526.advance(); YM3526.advance();
} }
} }

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class ICS2115 public unsafe class ICS2115
{ {
public static byte V_ON = 1, V_DONE = 2; public static byte V_ON = 1, V_DONE = 2;
public static voice_struct[] voice2; public static voice_struct[] voice2;
@ -75,8 +75,8 @@ namespace MAME.Core
bool irq_invalid = false; bool irq_invalid = false;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.ics2115stream.streamoutput[0][offset + i] = 0; Sound.ics2115stream.streamoutput_Ptrs[0][offset + i] = 0;
Sound.ics2115stream.streamoutput[1][offset + i] = 0; Sound.ics2115stream.streamoutput_Ptrs[1][offset + i] = 0;
} }
for (osc = 0; osc < 32; osc++) for (osc = 0; osc < 32; osc++)
{ {
@ -106,8 +106,8 @@ namespace MAME.Core
else else
v = ((sbyte)v) << 6; v = ((sbyte)v) << 6;
v = (v * vol) >> (16 + 5); v = (v * vol) >> (16 + 5);
Sound.ics2115stream.streamoutput[0][offset + i] += v; Sound.ics2115stream.streamoutput_Ptrs[0][offset + i] += v;
Sound.ics2115stream.streamoutput[1][offset + i] += v; Sound.ics2115stream.streamoutput_Ptrs[1][offset + i] += v;
adr += delta; adr += delta;
if (adr >= end) if (adr >= end)
{ {

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class Iremga20 public unsafe class Iremga20
{ {
public struct IremGA20_channel_def public struct IremGA20_channel_def
{ {
@ -74,8 +74,8 @@ namespace MAME.Core
play[3] = pos[3] < end[3] ? 1 : 0; play[3] = pos[3] < end[3] ? 1 : 0;
} }
sampleout >>= 2; sampleout >>= 2;
Sound.iremga20stream.streamoutput[0][offset + i] = sampleout; Sound.iremga20stream.streamoutput_Ptrs[0][offset + i] = sampleout;
Sound.iremga20stream.streamoutput[1][offset + i] = sampleout; Sound.iremga20stream.streamoutput_Ptrs[1][offset + i] = sampleout;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class K007232 public unsafe class K007232
{ {
public struct kdacApcm public struct kdacApcm
{ {
@ -39,7 +39,7 @@ namespace MAME.Core
{ {
for (j = 0; j < length; j++) for (j = 0; j < length; j++)
{ {
Sound.k007232stream.streamoutput[i][offset + j] = 0; Sound.k007232stream.streamoutput_Ptrs[i][offset + j] = 0;
} }
} }
for (i = 0; i < 2; i++) for (i = 0; i < 2; i++)
@ -84,8 +84,8 @@ namespace MAME.Core
} }
info.addr[i] += info.step[i]; info.addr[i] += info.step[i];
out1 = (k007232rom[info.pcmbuf_offset[i] + addr] & 0x7f) - 0x40; out1 = (k007232rom[info.pcmbuf_offset[i] + addr] & 0x7f) - 0x40;
Sound.k007232stream.streamoutput[0][offset + j] += out1 * volA; Sound.k007232stream.streamoutput_Ptrs[0][offset + j] += out1 * volA;
Sound.k007232stream.streamoutput[1][offset + j] += out1 * volB; Sound.k007232stream.streamoutput_Ptrs[1][offset + j] += out1 * volB;
} }
} }
} }

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class K053260 public unsafe class K053260
{ {
public struct k053260_channel_def public struct k053260_channel_def
{ {
@ -226,8 +226,8 @@ namespace MAME.Core
{ {
dataR = 32767; dataR = 32767;
} }
Sound.k053260stream.streamoutput[1][offset + j] = dataL; Sound.k053260stream.streamoutput_Ptrs[1][offset + j] = dataL;
Sound.k053260stream.streamoutput[0][offset + j] = dataR; Sound.k053260stream.streamoutput_Ptrs[0][offset + j] = dataR;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {

View File

@ -3,7 +3,7 @@ using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class K054539 public unsafe class K054539
{ {
public struct k054539_channel public struct k054539_channel
{ {
@ -80,7 +80,7 @@ namespace MAME.Core
{ {
for (j = 0; j < length; j++) for (j = 0; j < length; j++)
{ {
Sound.k054539stream.streamoutput[i][offset + j] = 0; Sound.k054539stream.streamoutput_Ptrs[i][offset + j] = 0;
} }
} }
samples = k054539rom;//info.rom; samples = k054539rom;//info.rom;
@ -189,8 +189,8 @@ namespace MAME.Core
goto end_channel_0; goto end_channel_0;
} }
} }
Sound.k054539stream.streamoutput[0][offset1] += (short)(cur_val * lvol); Sound.k054539stream.streamoutput_Ptrs[0][offset1] += (short)(cur_val * lvol);
Sound.k054539stream.streamoutput[1][offset1] += (short)(cur_val * rvol); Sound.k054539stream.streamoutput_Ptrs[1][offset1] += (short)(cur_val * rvol);
offset1++; offset1++;
info.ram[rdelta] += (short)(cur_val * rbvol); info.ram[rdelta] += (short)(cur_val * rbvol);
rdelta++; rdelta++;
@ -226,8 +226,8 @@ namespace MAME.Core
goto end_channel_4; goto end_channel_4;
} }
} }
Sound.k054539stream.streamoutput[0][offset1] += (short)(cur_val * lvol); Sound.k054539stream.streamoutput_Ptrs[0][offset1] += (short)(cur_val * lvol);
Sound.k054539stream.streamoutput[1][offset1] += (short)(cur_val * rvol); Sound.k054539stream.streamoutput_Ptrs[1][offset1] += (short)(cur_val * rvol);
offset1++; offset1++;
info.ram[rdelta] += (short)(cur_val * rbvol); info.ram[rdelta] += (short)(cur_val * rbvol);
rdelta++; rdelta++;
@ -285,8 +285,8 @@ namespace MAME.Core
cur_val = 32767; cur_val = 32767;
} }
} }
Sound.k054539stream.streamoutput[0][offset1] += (short)(cur_val * lvol); Sound.k054539stream.streamoutput_Ptrs[0][offset1] += (short)(cur_val * lvol);
Sound.k054539stream.streamoutput[1][offset1] += (short)(cur_val * rvol); Sound.k054539stream.streamoutput_Ptrs[1][offset1] += (short)(cur_val * rvol);
offset1++; offset1++;
info.ram[rdelta] += (short)(cur_val * rbvol); info.ram[rdelta] += (short)(cur_val * rbvol);
rdelta++; rdelta++;
@ -321,8 +321,8 @@ namespace MAME.Core
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
short val = info.ram[(i + reverb_pos) & 0x3fff]; short val = info.ram[(i + reverb_pos) & 0x3fff];
Sound.k054539stream.streamoutput[0][offset + i] += val; Sound.k054539stream.streamoutput_Ptrs[0][offset + i] += val;
Sound.k054539stream.streamoutput[1][offset + i] += val; Sound.k054539stream.streamoutput_Ptrs[1][offset + i] += val;
} }
} }
if (reverb_pos + length > 0x4000) if (reverb_pos + length > 0x4000)

View File

@ -3,7 +3,7 @@ using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class MSM5205 public unsafe class MSM5205
{ {
public struct MSM5205Voice public struct MSM5205Voice
{ {
@ -58,14 +58,14 @@ namespace MAME.Core
short val = (short)(voice.signal * 16); short val = (short)(voice.signal * 16);
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
voice.stream.streamoutput[0][offset + i] = val; voice.stream.streamoutput_Ptrs[0][offset + i] = val;
} }
} }
else else
{ {
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
voice.stream.streamoutput[0][offset + i] = 0; voice.stream.streamoutput_Ptrs[0][offset + i] = 0;
} }
} }
} }

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class Namco public unsafe class Namco
{ {
public struct sound_channel public struct sound_channel
{ {
@ -82,8 +82,8 @@ namespace MAME.Core
int counter; int counter;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.namcostream.streamoutput[0][offset + i] = 0; Sound.namcostream.streamoutput_Ptrs[0][offset + i] = 0;
Sound.namcostream.streamoutput[1][offset + i] = 0; Sound.namcostream.streamoutput_Ptrs[1][offset + i] = 0;
} }
for (voice = 0; voice < 8; voice++) for (voice = 0; voice < 8; voice++)
{ {
@ -105,13 +105,13 @@ namespace MAME.Core
int cnt; int cnt;
if (nam1.channel_list[voice].noise_state != 0) if (nam1.channel_list[voice].noise_state != 0)
{ {
Sound.namcostream.streamoutput[0][offset + i] += l_noise_data; Sound.namcostream.streamoutput_Ptrs[0][offset + i] += l_noise_data;
Sound.namcostream.streamoutput[1][offset + i] += r_noise_data; Sound.namcostream.streamoutput_Ptrs[1][offset + i] += r_noise_data;
} }
else else
{ {
Sound.namcostream.streamoutput[0][offset + i] += l_noise_data; Sound.namcostream.streamoutput_Ptrs[0][offset + i] += l_noise_data;
Sound.namcostream.streamoutput[1][offset + i] += r_noise_data; Sound.namcostream.streamoutput_Ptrs[1][offset + i] += r_noise_data;
} }
if (hold != 0) if (hold != 0)
{ {
@ -145,7 +145,7 @@ namespace MAME.Core
counter = nam1.channel_list[voice].counter; counter = nam1.channel_list[voice].counter;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.namcostream.streamoutput[0][offset + i] += nam1.waveform[lv][nam1.channel_list[voice].waveform_select * 32 + (counter >> nam1.f_fracbits) & 0x1f]; Sound.namcostream.streamoutput_Ptrs[0][offset + i] += nam1.waveform[lv][nam1.channel_list[voice].waveform_select * 32 + (counter >> nam1.f_fracbits) & 0x1f];
counter += nam1.channel_list[voice].frequency; counter += nam1.channel_list[voice].frequency;
} }
c = counter; c = counter;
@ -155,7 +155,7 @@ namespace MAME.Core
counter = nam1.channel_list[voice].counter; counter = nam1.channel_list[voice].counter;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.namcostream.streamoutput[1][offset + i] += nam1.waveform[rv][nam1.channel_list[voice].waveform_select * 32 + (counter >> nam1.f_fracbits) & 0x1f]; Sound.namcostream.streamoutput_Ptrs[1][offset + i] += nam1.waveform[rv][nam1.channel_list[voice].waveform_select * 32 + (counter >> nam1.f_fracbits) & 0x1f];
counter += nam1.channel_list[voice].frequency; counter += nam1.channel_list[voice].frequency;
} }
c = counter; c = counter;

View File

@ -117,12 +117,12 @@ namespace MAME.Core
} }
//TODO 移动到这里,但是大小,还需要考虑 //TODO 移动到这里,但是大小,还需要考虑
static short[] sample_data = new short[10000]; static short[] sample_data = new short[10000];
public static void okim6295_update(int offset, int length) public unsafe static void okim6295_update(int offset, int length)
{ {
int i; int i;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.okistream.streamoutput[0][offset + i] = 0; Sound.okistream.streamoutput_Ptrs[0][offset + i] = 0;
} }
for (i = 0; i < 4; i++) for (i = 0; i < 4; i++)
{ {
@ -136,7 +136,7 @@ namespace MAME.Core
generate_adpcm(i, sample_data, samples1); generate_adpcm(i, sample_data, samples1);
for (samp = 0; samp < length; samp++) for (samp = 0; samp < length; samp++)
{ {
Sound.okistream.streamoutput[0][offset + samp] += sample_data[samp]; Sound.okistream.streamoutput_Ptrs[0][offset + samp] += sample_data[samp];
} }
remaining -= samples1; remaining -= samples1;
} }

View File

@ -30,7 +30,7 @@ namespace MAME.Core
public int[] pan_table; /* Pan volume table */ public int[] pan_table; /* Pan volume table */
public float frq_ratio; /* Frequency ratio */ public float frq_ratio; /* Frequency ratio */
}; };
public class QSound public unsafe class QSound
{ {
public static sbyte[] qsoundrom; public static sbyte[] qsoundrom;
public static qsound_info QChip; public static qsound_info QChip;
@ -159,8 +159,8 @@ namespace MAME.Core
int rvol, lvol, count; int rvol, lvol, count;
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.qsoundstream.streamoutput[0][offset + i] = 0; Sound.qsoundstream.streamoutput_Ptrs[0][offset + i] = 0;
Sound.qsoundstream.streamoutput[1][offset + i] = 0; Sound.qsoundstream.streamoutput_Ptrs[1][offset + i] = 0;
} }
for (i = 0; i < 16; i++) for (i = 0; i < 16; i++)
{ {
@ -188,8 +188,8 @@ namespace MAME.Core
} }
QChip.channel[i].lastdt = qsoundrom[(QChip.channel[i].bank + QChip.channel[i].address) % (QChip.sample_rom_length)]; QChip.channel[i].lastdt = qsoundrom[(QChip.channel[i].bank + QChip.channel[i].address) % (QChip.sample_rom_length)];
} }
Sound.qsoundstream.streamoutput[0][offset + j] += ((QChip.channel[i].lastdt * lvol) >> 6); Sound.qsoundstream.streamoutput_Ptrs[0][offset + j] += ((QChip.channel[i].lastdt * lvol) >> 6);
Sound.qsoundstream.streamoutput[1][offset + j] += ((QChip.channel[i].lastdt * rvol) >> 6); Sound.qsoundstream.streamoutput_Ptrs[1][offset + j] += ((QChip.channel[i].lastdt * rvol) >> 6);
QChip.channel[i].offset += QChip.channel[i].pitch; QChip.channel[i].offset += QChip.channel[i].pitch;
} }
} }

View File

@ -3,7 +3,7 @@ using System.IO;
namespace MAME.Core namespace MAME.Core
{ {
public class Sample public unsafe class Sample
{ {
public struct sample_channel public struct sample_channel
{ {
@ -86,7 +86,7 @@ namespace MAME.Core
int sample1 = info.channel[0].source[pos]; int sample1 = info.channel[0].source[pos];
int sample2 = info.channel[0].source[(pos + 1) % sample_length]; int sample2 = info.channel[0].source[(pos + 1) % sample_length];
int fracmult = (int)(frac >> (24 - 14)); int fracmult = (int)(frac >> (24 - 14));
Sound.samplestream.streamoutput[0][offset + i] = ((0x4000 - fracmult) * sample1 + fracmult * sample2) >> 14; Sound.samplestream.streamoutput_Ptrs[0][offset + i] = ((0x4000 - fracmult) * sample1 + fracmult * sample2) >> 14;
frac += step; frac += step;
pos += frac >> 24; pos += frac >> 24;
frac = frac & ((1 << 24) - 1); frac = frac & ((1 << 24) - 1);
@ -104,7 +104,7 @@ namespace MAME.Core
{ {
for (j = i + 1; j < length; j++) for (j = i + 1; j < length; j++)
{ {
Sound.samplestream.streamoutput[0][offset + j] = 0; Sound.samplestream.streamoutput_Ptrs[0][offset + j] = 0;
} }
} }
break; break;
@ -118,7 +118,7 @@ namespace MAME.Core
{ {
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.samplestream.streamoutput[0][offset + i] = 0; Sound.samplestream.streamoutput_Ptrs[0][offset + i] = 0;
} }
} }
} }

View File

@ -3,7 +3,7 @@ using System;
namespace MAME.Core namespace MAME.Core
{ {
public partial class Sound public unsafe partial class Sound
{ {
public static EmuTimer.emu_timer sound_update_timer; public static EmuTimer.emu_timer sound_update_timer;
private static int[] leftmix, rightmix; private static int[] leftmix, rightmix;
@ -724,7 +724,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -750,7 +750,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -759,7 +759,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -791,7 +791,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex] + mixerstream.streaminput[5][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex] + mixerstream.streaminput_Ptrs[5][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -821,7 +821,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex] + mixerstream.streaminput[5][sampindex] + mixerstream.streaminput[6][sampindex] + mixerstream.streaminput[7][sampindex] + mixerstream.streaminput[8][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex] + mixerstream.streaminput_Ptrs[5][sampindex] + mixerstream.streaminput_Ptrs[6][sampindex] + mixerstream.streaminput_Ptrs[7][sampindex] + mixerstream.streaminput_Ptrs[8][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -849,7 +849,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -858,7 +858,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampR = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -888,7 +888,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -918,7 +918,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[4][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -927,7 +927,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -955,7 +955,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -981,7 +981,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1009,7 +1009,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1035,7 +1035,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1061,7 +1061,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1089,7 +1089,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1098,7 +1098,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1126,7 +1126,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1135,7 +1135,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1163,7 +1163,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1193,7 +1193,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1223,7 +1223,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1232,7 +1232,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1260,7 +1260,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1286,7 +1286,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1295,7 +1295,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex]; sampR = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1323,7 +1323,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1332,7 +1332,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1364,7 +1364,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex] + mixerstream.streaminput[5][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex] + mixerstream.streaminput_Ptrs[5][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1373,7 +1373,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex] + mixerstream.streaminput[5][sampindex]; sampR = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex] + mixerstream.streaminput_Ptrs[5][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1401,7 +1401,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1410,7 +1410,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1436,7 +1436,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1445,7 +1445,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1473,7 +1473,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1482,7 +1482,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1510,7 +1510,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1519,7 +1519,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1547,7 +1547,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1556,7 +1556,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1582,7 +1582,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1591,7 +1591,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;
@ -1623,7 +1623,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int samp; int samp;
samp = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex] + mixerstream.streaminput[4][sampindex] + mixerstream.streaminput[5][sampindex] + mixerstream.streaminput[6][sampindex] + mixerstream.streaminput[7][sampindex]; samp = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex] + mixerstream.streaminput_Ptrs[4][sampindex] + mixerstream.streaminput_Ptrs[5][sampindex] + mixerstream.streaminput_Ptrs[6][sampindex] + mixerstream.streaminput_Ptrs[7][sampindex];
if (samp < -32768) if (samp < -32768)
{ {
samp = -32768; samp = -32768;
@ -1653,7 +1653,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int sampL, sampR; int sampL, sampR;
sampL = mixerstream.streaminput[0][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; sampL = mixerstream.streaminput_Ptrs[0][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampL < -32768) if (sampL < -32768)
{ {
sampL = -32768; sampL = -32768;
@ -1662,7 +1662,7 @@ namespace MAME.Core
{ {
sampL = 32767; sampL = 32767;
} }
sampR = mixerstream.streaminput[1][sampindex] + mixerstream.streaminput[2][sampindex] + mixerstream.streaminput[3][sampindex]; sampR = mixerstream.streaminput_Ptrs[1][sampindex] + mixerstream.streaminput_Ptrs[2][sampindex] + mixerstream.streaminput_Ptrs[3][sampindex];
if (sampR < -32768) if (sampR < -32768)
{ {
sampR = -32768; sampR = -32768;

View File

@ -1,8 +1,9 @@
using System; using System;
using System.Runtime.InteropServices;
namespace MAME.Core namespace MAME.Core
{ {
public class sound_stream public unsafe class sound_stream
{ {
public int sample_rate; public int sample_rate;
public int new_sample_rate; public int new_sample_rate;
@ -13,7 +14,15 @@ namespace MAME.Core
public int outputs; public int outputs;
public int output_sampindex; public int output_sampindex;
public int output_base_sampindex; public int output_base_sampindex;
public int[][] streaminput, streamoutput; //改成指针读取
private int[][] streaminput;
GCHandle[] streaminput_handles;
public int*[] streaminput_Ptrs;
//改成指针读取
private int[][] streamoutput;
GCHandle[] streamoutput_handles;
public int*[] streamoutput_Ptrs;
private updatedelegate updatecallback; private updatedelegate updatecallback;
public delegate void updatedelegate(int offset, int length); public delegate void updatedelegate(int offset, int length);
public sound_stream(int _sample_rate, int _inputs, int _outputs, updatedelegate callback) public sound_stream(int _sample_rate, int _inputs, int _outputs, updatedelegate callback)
@ -26,17 +35,57 @@ namespace MAME.Core
max_samples_per_update = (int)((Sound.update_attoseconds + attoseconds_per_sample - 1) / attoseconds_per_sample); max_samples_per_update = (int)((Sound.update_attoseconds + attoseconds_per_sample - 1) / attoseconds_per_sample);
output_base_sampindex = -max_samples_per_update; output_base_sampindex = -max_samples_per_update;
streaminput = new int[inputs][]; streaminput = new int[inputs][];
//
streaminput_handles = new GCHandle[inputs];
streaminput_Ptrs = new int*[inputs];
for (i = 0; i < inputs; i++) for (i = 0; i < inputs; i++)
{ {
streaminput[i] = new int[max_samples_per_update]; streaminput[i] = new int[max_samples_per_update];
//
streaminput_handles[i] = GCHandle.Alloc(streaminput[i], GCHandleType.Pinned);
streaminput_Ptrs[i] = (int*)streaminput_handles[i].AddrOfPinnedObject();
} }
streamoutput = new int[outputs][]; streamoutput = new int[outputs][];
//
streamoutput_handles = new GCHandle[outputs];
streamoutput_Ptrs = new int*[outputs];
for (i = 0; i < outputs; i++) for (i = 0; i < outputs; i++)
{ {
streamoutput[i] = new int[5 * max_samples_per_update]; streamoutput[i] = new int[5 * max_samples_per_update];
//
streamoutput_handles[i] = GCHandle.Alloc(streamoutput[i], GCHandleType.Pinned);
streamoutput_Ptrs[i] = (int*)streamoutput_handles[i].AddrOfPinnedObject();
} }
updatecallback = callback; updatecallback = callback;
} }
~sound_stream()
{
// 释放句柄
if (streaminput_handles != null)
{
for (int i = 0; i < streaminput_handles.Length; i++)
{
if (streaminput_handles[i].IsAllocated)
streaminput_handles[i].Free();
}
streaminput_handles = null;
streaminput_Ptrs = null;
}
if (streamoutput_handles != null)
{
for (int i = 0; i < streamoutput_handles.Length; i++)
{
if (streamoutput_handles[i].IsAllocated)
streamoutput_handles[i].Free();
}
streamoutput_handles = null;
streamoutput_Ptrs = null;
}
}
public void stream_update() public void stream_update()
{ {
int update_sampindex = time_to_sampindex(EmuTimer.get_current_time()); int update_sampindex = time_to_sampindex(EmuTimer.get_current_time());
@ -103,7 +152,7 @@ namespace MAME.Core
} }
} }
}; };
public partial class Sound public unsafe partial class Sound
{ {
public static int last_update_second; public static int last_update_second;
public static sound_stream ym2151stream, okistream, mixerstream; public static sound_stream ym2151stream, okistream, mixerstream;
@ -119,7 +168,7 @@ namespace MAME.Core
public static sound_stream samplestream; public static sound_stream samplestream;
public static sound_stream k054539stream; public static sound_stream k054539stream;
public static long update_attoseconds = Attotime.ATTOSECONDS_PER_SECOND / 50; public static long update_attoseconds = Attotime.ATTOSECONDS_PER_SECOND / 50;
private static void generate_resampled_dataY5(int gain) private unsafe static void generate_resampled_dataY5(int gain)
{ {
int offset; int offset;
int sample0, sample1; int sample0, sample1;
@ -145,30 +194,30 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample0 = ym2151stream.streamoutput[0][offset + tpos] * scale; sample0 = ym2151stream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = ym2151stream.streamoutput[1][offset + tpos] * scale; sample1 = ym2151stream.streamoutput_Ptrs[1][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += ym2151stream.streamoutput[0][offset + tpos] * 0x100; sample0 += ym2151stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += ym2151stream.streamoutput[1][offset + tpos] * 0x100; sample1 += ym2151stream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += ym2151stream.streamoutput[0][offset + tpos] * remainder; sample0 += ym2151stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += ym2151stream.streamoutput[1][offset + tpos] * remainder; sample1 += ym2151stream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
mixerstream.streaminput[0][sampindex] = (sample0 * gain) >> 8; mixerstream.streaminput_Ptrs[0][sampindex] = (sample0 * gain) >> 8;
mixerstream.streaminput[1][sampindex] = (sample1 * gain) >> 8; mixerstream.streaminput_Ptrs[1][sampindex] = (sample1 * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
} }
} }
} }
private static void generate_resampled_dataO(int gain, int minput) private unsafe static void generate_resampled_dataO(int gain, int minput)
{ {
int offset; int offset;
int sample; int sample;
@ -190,8 +239,8 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
sample = (okistream.streamoutput[0][offset] * (0x1000 - interp_frac) + okistream.streamoutput[0][offset + 1] * interp_frac) >> 12; sample = (okistream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + okistream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12;
mixerstream.streaminput[minput][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -219,8 +268,8 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
mixerstream.streaminput[0][sampindex] = (qsoundstream.streamoutput[0][offset] * (0x1000 - interp_frac) + qsoundstream.streamoutput[0][offset + 1] * interp_frac) >> 12; mixerstream.streaminput_Ptrs[0][sampindex] = (qsoundstream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + qsoundstream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12;
mixerstream.streaminput[1][sampindex] = (qsoundstream.streamoutput[1][offset] * (0x1000 - interp_frac) + qsoundstream.streamoutput[1][offset + 1] * interp_frac) >> 12; mixerstream.streaminput_Ptrs[1][sampindex] = (qsoundstream.streamoutput_Ptrs[1][offset] * (0x1000 - interp_frac) + qsoundstream.streamoutput_Ptrs[1][offset + 1] * interp_frac) >> 12;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -253,18 +302,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample = AY8910.AA8910[0].stream.streamoutput[0][offset + tpos] * scale; sample = AY8910.AA8910[0].stream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += AY8910.AA8910[0].stream.streamoutput[0][offset + tpos] * 0x100; sample += AY8910.AA8910[0].stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += AY8910.AA8910[0].stream.streamoutput[0][offset + tpos] * remainder; sample += AY8910.AA8910[0].stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[0][sampindex] = (sample * 0x99) >> 8; mixerstream.streaminput_Ptrs[0][sampindex] = (sample * 0x99) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -297,28 +346,28 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample0 = AY8910.AA8910[chip].stream.streamoutput[0][offset + tpos] * scale; sample0 = AY8910.AA8910[chip].stream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = AY8910.AA8910[chip].stream.streamoutput[1][offset + tpos] * scale; sample1 = AY8910.AA8910[chip].stream.streamoutput_Ptrs[1][offset + tpos] * scale;
sample2 = AY8910.AA8910[chip].stream.streamoutput[2][offset + tpos] * scale; sample2 = AY8910.AA8910[chip].stream.streamoutput_Ptrs[2][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += AY8910.AA8910[chip].stream.streamoutput[0][offset + tpos] * 0x100; sample0 += AY8910.AA8910[chip].stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += AY8910.AA8910[chip].stream.streamoutput[1][offset + tpos] * 0x100; sample1 += AY8910.AA8910[chip].stream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
sample2 += AY8910.AA8910[chip].stream.streamoutput[2][offset + tpos] * 0x100; sample2 += AY8910.AA8910[chip].stream.streamoutput_Ptrs[2][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += AY8910.AA8910[chip].stream.streamoutput[0][offset + tpos] * remainder; sample0 += AY8910.AA8910[chip].stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += AY8910.AA8910[chip].stream.streamoutput[1][offset + tpos] * remainder; sample1 += AY8910.AA8910[chip].stream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample2 += AY8910.AA8910[chip].stream.streamoutput[2][offset + tpos] * remainder; sample2 += AY8910.AA8910[chip].stream.streamoutput_Ptrs[2][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
sample2 /= smallstep; sample2 /= smallstep;
mixerstream.streaminput[start][sampindex] = (sample0 * gain) >> 8; mixerstream.streaminput_Ptrs[start][sampindex] = (sample0 * gain) >> 8;
mixerstream.streaminput[start + 1][sampindex] = (sample1 * gain) >> 8; mixerstream.streaminput_Ptrs[start + 1][sampindex] = (sample1 * gain) >> 8;
mixerstream.streaminput[start + 2][sampindex] = (sample2 * gain) >> 8; mixerstream.streaminput_Ptrs[start + 2][sampindex] = (sample2 * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -353,18 +402,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample = AY8910.AA8910[0].stream.streamoutput[0][offset + tpos] * scale; sample = AY8910.AA8910[0].stream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += AY8910.AA8910[0].stream.streamoutput[0][offset + tpos] * 0x100; sample += AY8910.AA8910[0].stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += AY8910.AA8910[0].stream.streamoutput[0][offset + tpos] * remainder; sample += AY8910.AA8910[0].stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[0][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[0][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -392,10 +441,10 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
int i2 = YM2203.FF2203[c].stream.streamoutput[0][offset]; int i2 = YM2203.FF2203[c].stream.streamoutput_Ptrs[0][offset];
int i3 = YM2203.FF2203[c].stream.streamoutput[0][offset + 1]; int i3 = YM2203.FF2203[c].stream.streamoutput_Ptrs[0][offset + 1];
int i4 = (((YM2203.FF2203[c].stream.streamoutput[0][offset] * (0x1000 - interp_frac) + YM2203.FF2203[c].stream.streamoutput[0][offset + 1] * interp_frac) >> 12) * gain) >> 8; int i4 = (((YM2203.FF2203[c].stream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + YM2203.FF2203[c].stream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12) * gain) >> 8;
mixerstream.streaminput[minput][sampindex] = (((YM2203.FF2203[c].stream.streamoutput[0][offset] * (0x1000 - interp_frac) + YM2203.FF2203[c].stream.streamoutput[0][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (((YM2203.FF2203[c].stream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + YM2203.FF2203[c].stream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12) * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -423,7 +472,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
mixerstream.streaminput[minput][sampindex] = (((ym3526stream.streamoutput[0][offset] * (0x1000 - interp_frac) + ym3526stream.streamoutput[0][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (((ym3526stream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + ym3526stream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12) * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -456,23 +505,23 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample0 = ym2610stream.streamoutput[0][offset + tpos] * scale; sample0 = ym2610stream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = ym2610stream.streamoutput[1][offset + tpos] * scale; sample1 = ym2610stream.streamoutput_Ptrs[1][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += ym2610stream.streamoutput[0][offset + tpos] * 0x100; sample0 += ym2610stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += ym2610stream.streamoutput[1][offset + tpos] * 0x100; sample1 += ym2610stream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += ym2610stream.streamoutput[0][offset + tpos] * remainder; sample0 += ym2610stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += ym2610stream.streamoutput[1][offset + tpos] * remainder; sample1 += ym2610stream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
mixerstream.streaminput[1][sampindex] = sample0; mixerstream.streaminput_Ptrs[1][sampindex] = sample0;
mixerstream.streaminput[2][sampindex] = sample1; mixerstream.streaminput_Ptrs[2][sampindex] = sample1;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -507,23 +556,23 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> (14)); scale = (int)((0x400000 - basefrac) >> (14));
sample0 = namcostream.streamoutput[0][offset + tpos] * scale; sample0 = namcostream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = namcostream.streamoutput[1][offset + tpos] * scale; sample1 = namcostream.streamoutput_Ptrs[1][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += namcostream.streamoutput[0][offset + tpos] * 0x100; sample0 += namcostream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += namcostream.streamoutput[1][offset + tpos] * 0x100; sample1 += namcostream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += namcostream.streamoutput[0][offset + tpos] * remainder; sample0 += namcostream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += namcostream.streamoutput[1][offset + tpos] * remainder; sample1 += namcostream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
mixerstream.streaminput[2][sampindex] = (sample0 * gain) >> 8; mixerstream.streaminput_Ptrs[2][sampindex] = (sample0 * gain) >> 8;
mixerstream.streaminput[3][sampindex] = (sample1 * gain) >> 8; mixerstream.streaminput_Ptrs[3][sampindex] = (sample1 * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -556,18 +605,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> (14)); scale = (int)((0x400000 - basefrac) >> (14));
sample = dacstream.streamoutput[0][offset + tpos] * scale; sample = dacstream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += dacstream.streamoutput[0][offset + tpos] * 0x100; sample += dacstream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += dacstream.streamoutput[0][offset + tpos] * remainder; sample += dacstream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[minput][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -600,23 +649,23 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample0 = ym2413stream.streamoutput[0][offset + tpos] * scale; sample0 = ym2413stream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = ym2413stream.streamoutput[1][offset + tpos] * scale; sample1 = ym2413stream.streamoutput_Ptrs[1][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += ym2413stream.streamoutput[0][offset + tpos] * 0x100; sample0 += ym2413stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += ym2413stream.streamoutput[1][offset + tpos] * 0x100; sample1 += ym2413stream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += ym2413stream.streamoutput[0][offset + tpos] * remainder; sample0 += ym2413stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += ym2413stream.streamoutput[1][offset + tpos] * remainder; sample1 += ym2413stream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
mixerstream.streaminput[minput][sampindex] = (sample0 * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (sample0 * gain) >> 8;
mixerstream.streaminput[minput + 1][sampindex] = (sample1 * gain) >> 8; mixerstream.streaminput_Ptrs[minput + 1][sampindex] = (sample1 * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -649,18 +698,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample = ym3812stream.streamoutput[0][offset + tpos] * scale; sample = ym3812stream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += ym3812stream.streamoutput[0][offset + tpos] * 0x100; sample += ym3812stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += ym3812stream.streamoutput[0][offset + tpos] * remainder; sample += ym3812stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[minput][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -671,7 +720,7 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
mixerstream.streaminput[minput][sampindex] = (((ym3812stream.streamoutput[0][offset] * (0x1000 - interp_frac) + ym3812stream.streamoutput[0][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (((ym3812stream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + ym3812stream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12) * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -699,8 +748,8 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
mixerstream.streaminput[0][sampindex] = (((ics2115stream.streamoutput[0][offset] * (0x1000 - interp_frac) + ics2115stream.streamoutput[0][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[0][sampindex] = (((ics2115stream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + ics2115stream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12) * gain) >> 8;
mixerstream.streaminput[1][sampindex] = (((ics2115stream.streamoutput[1][offset] * (0x1000 - interp_frac) + ics2115stream.streamoutput[1][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[1][sampindex] = (((ics2115stream.streamoutput_Ptrs[1][offset] * (0x1000 - interp_frac) + ics2115stream.streamoutput_Ptrs[1][offset + 1] * interp_frac) >> 12) * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -733,23 +782,23 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample0 = iremga20stream.streamoutput[0][offset + tpos] * scale; sample0 = iremga20stream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = iremga20stream.streamoutput[1][offset + tpos] * scale; sample1 = iremga20stream.streamoutput_Ptrs[1][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += iremga20stream.streamoutput[0][offset + tpos] * 0x100; sample0 += iremga20stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += iremga20stream.streamoutput[1][offset + tpos] * 0x100; sample1 += iremga20stream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += iremga20stream.streamoutput[0][offset + tpos] * remainder; sample0 += iremga20stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += iremga20stream.streamoutput[1][offset + tpos] * remainder; sample1 += iremga20stream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
mixerstream.streaminput[2][sampindex] = (sample0 * gain) >> 8; mixerstream.streaminput_Ptrs[2][sampindex] = (sample0 * gain) >> 8;
mixerstream.streaminput[3][sampindex] = (sample1 * gain) >> 8; mixerstream.streaminput_Ptrs[3][sampindex] = (sample1 * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -782,23 +831,23 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample0 = k053260stream.streamoutput[0][offset + tpos] * scale; sample0 = k053260stream.streamoutput_Ptrs[0][offset + tpos] * scale;
sample1 = k053260stream.streamoutput[1][offset + tpos] * scale; sample1 = k053260stream.streamoutput_Ptrs[1][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample0 += k053260stream.streamoutput[0][offset + tpos] * 0x100; sample0 += k053260stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
sample1 += k053260stream.streamoutput[1][offset + tpos] * 0x100; sample1 += k053260stream.streamoutput_Ptrs[1][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample0 += k053260stream.streamoutput[0][offset + tpos] * remainder; sample0 += k053260stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample1 += k053260stream.streamoutput[1][offset + tpos] * remainder; sample1 += k053260stream.streamoutput_Ptrs[1][offset + tpos] * remainder;
sample0 /= smallstep; sample0 /= smallstep;
sample1 /= smallstep; sample1 /= smallstep;
mixerstream.streaminput[minput1][sampindex] = (sample0 * gain) >> 8; mixerstream.streaminput_Ptrs[minput1][sampindex] = (sample0 * gain) >> 8;
mixerstream.streaminput[minput2][sampindex] = (sample1 * gain) >> 8; mixerstream.streaminput_Ptrs[minput2][sampindex] = (sample1 * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -826,8 +875,8 @@ namespace MAME.Core
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
int interp_frac = (int)(basefrac >> 10); int interp_frac = (int)(basefrac >> 10);
mixerstream.streaminput[2][sampindex] = (((k007232stream.streamoutput[0][offset] * (0x1000 - interp_frac) + k007232stream.streamoutput[0][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[2][sampindex] = (((k007232stream.streamoutput_Ptrs[0][offset] * (0x1000 - interp_frac) + k007232stream.streamoutput_Ptrs[0][offset + 1] * interp_frac) >> 12) * gain) >> 8;
mixerstream.streaminput[3][sampindex] = (((k007232stream.streamoutput[1][offset] * (0x1000 - interp_frac) + k007232stream.streamoutput[1][offset + 1] * interp_frac) >> 12) * gain) >> 8; mixerstream.streaminput_Ptrs[3][sampindex] = (((k007232stream.streamoutput_Ptrs[1][offset] * (0x1000 - interp_frac) + k007232stream.streamoutput_Ptrs[1][offset + 1] * interp_frac) >> 12) * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -860,18 +909,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample = upd7759stream.streamoutput[0][offset + tpos] * scale; sample = upd7759stream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += upd7759stream.streamoutput[0][offset + tpos] * 0x100; sample += upd7759stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += upd7759stream.streamoutput[0][offset + tpos] * remainder; sample += upd7759stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[4][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[4][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -898,7 +947,7 @@ namespace MAME.Core
{ {
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
mixerstream.streaminput[minput][sampindex] = (samplestream.streamoutput[0][offset + sampindex] * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (samplestream.streamoutput_Ptrs[0][offset + sampindex] * gain) >> 8;
} }
} }
} }
@ -922,8 +971,8 @@ namespace MAME.Core
{ {
for (sampindex = 0; sampindex < 0x3c0; sampindex++) for (sampindex = 0; sampindex < 0x3c0; sampindex++)
{ {
mixerstream.streaminput[0][sampindex] = (k054539stream.streamoutput[0][offset + sampindex] * gain) >> 8; mixerstream.streaminput_Ptrs[0][sampindex] = (k054539stream.streamoutput_Ptrs[0][offset + sampindex] * gain) >> 8;
mixerstream.streaminput[1][sampindex] = (k054539stream.streamoutput[1][offset + sampindex] * gain) >> 8; mixerstream.streaminput_Ptrs[1][sampindex] = (k054539stream.streamoutput_Ptrs[1][offset + sampindex] * gain) >> 8;
} }
} }
} }
@ -953,18 +1002,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample = MSM5205.mm1[0].voice.stream.streamoutput[0][offset + tpos] * scale; sample = MSM5205.mm1[0].voice.stream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += MSM5205.mm1[0].voice.stream.streamoutput[0][offset + tpos] * 0x100; sample += MSM5205.mm1[0].voice.stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += MSM5205.mm1[0].voice.stream.streamoutput[0][offset + tpos] * remainder; sample += MSM5205.mm1[0].voice.stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[minput][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;
@ -997,18 +1046,18 @@ namespace MAME.Core
int tpos = 0; int tpos = 0;
int scale; int scale;
scale = (int)((0x400000 - basefrac) >> 14); scale = (int)((0x400000 - basefrac) >> 14);
sample = MSM5205.mm1[1].voice.stream.streamoutput[0][offset + tpos] * scale; sample = MSM5205.mm1[1].voice.stream.streamoutput_Ptrs[0][offset + tpos] * scale;
tpos++; tpos++;
remainder -= scale; remainder -= scale;
while (remainder > 0x100) while (remainder > 0x100)
{ {
sample += MSM5205.mm1[1].voice.stream.streamoutput[0][offset + tpos] * 0x100; sample += MSM5205.mm1[1].voice.stream.streamoutput_Ptrs[0][offset + tpos] * 0x100;
tpos++; tpos++;
remainder -= 0x100; remainder -= 0x100;
} }
sample += MSM5205.mm1[1].voice.stream.streamoutput[0][offset + tpos] * remainder; sample += MSM5205.mm1[1].voice.stream.streamoutput_Ptrs[0][offset + tpos] * remainder;
sample /= smallstep; sample /= smallstep;
mixerstream.streaminput[minput][sampindex] = (sample * gain) >> 8; mixerstream.streaminput_Ptrs[minput][sampindex] = (sample * gain) >> 8;
basefrac += step; basefrac += step;
offset += (int)(basefrac >> 22); offset += (int)(basefrac >> 22);
basefrac &= 0x3fffff; basefrac &= 0x3fffff;

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class Upd7759 public unsafe class Upd7759
{ {
public struct upd7759_chip public struct upd7759_chip
{ {
@ -219,7 +219,7 @@ namespace MAME.Core
{ {
for (i = 0; i < length; i++) for (i = 0; i < length; i++)
{ {
Sound.upd7759stream.streamoutput[0][offset + i] = sample << 7; Sound.upd7759stream.streamoutput_Ptrs[0][offset + i] = sample << 7;
pos += step; pos += step;
while (updrom != null && pos >= 0x100000) while (updrom != null && pos >= 0x100000)
{ {
@ -247,7 +247,7 @@ namespace MAME.Core
{ {
for (j = i; j < length; j++) for (j = i; j < length; j++)
{ {
Sound.upd7759stream.streamoutput[0][offset + j] = 0; Sound.upd7759stream.streamoutput_Ptrs[0][offset + j] = 0;
} }
} }
chip.clocks_left = clocks_left; chip.clocks_left = clocks_left;

View File

@ -1785,16 +1785,18 @@ namespace MAME.Core
fixed (uint* PSGfreqPtr = &PSG.freq[0]) fixed (uint* PSGfreqPtr = &PSG.freq[0])
fixed (YM2151Operator* PSGoperPtr = &PSG.oper[0]) fixed (YM2151Operator* PSGoperPtr = &PSG.oper[0])
fixed (int* chanoutPtr = &chanout[0]) fixed (int* chanoutPtr = &chanout[0])
fixed (int* streamoutput0Ptr = &Sound.ym2151stream.streamoutput[0][0]) //fixed (int* streamoutput0Ptr = &Sound.ym2151stream.streamoutput_Ptrs[0][0])
fixed (int* streamoutput1Ptr = &Sound.ym2151stream.streamoutput[0][1]) //fixed (int* streamoutput1Ptr = &Sound.ym2151stream.streamoutput_Ptrs[0][1])
fixed (int* imemPtr = &imem[0]) fixed (int* imemPtr = &imem[0])
{ {
YM2151Operator* PSGoper = PSGoperPtr; YM2151Operator* PSGoper = PSGoperPtr;
uint* PSGpan = PSGpanPtr; uint* PSGpan = PSGpanPtr;
uint* PSGfreq = PSGfreqPtr; uint* PSGfreq = PSGfreqPtr;
int* chanout = chanoutPtr; int* chanout = chanoutPtr;
int* streamoutput0 = streamoutput0Ptr; //int* streamoutput0 = streamoutput0Ptr;
int* streamoutput1 = streamoutput1Ptr; //int* streamoutput1 = streamoutput1Ptr;
int* streamoutput0 = &Sound.ym2151stream.streamoutput_Ptrs[0][0];
int* streamoutput1 = &Sound.ym2151stream.streamoutput_Ptrs[0][1];
int* imem = imemPtr; int* imem = imemPtr;
int i; int i;
@ -1911,8 +1913,8 @@ namespace MAME.Core
// { // {
// outr = -32768; // outr = -32768;
// } // }
// Sound.ym2151stream.streamoutput[0][offset + i] = outl; // Sound.ym2151stream.streamoutput_Ptrs[0][offset + i] = outl;
// Sound.ym2151stream.streamoutput[1][offset + i] = outr; // Sound.ym2151stream.streamoutput_Ptrs[1][offset + i] = outr;
// advance(); // advance();
// } // }
//} //}

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class YM2203 public unsafe class YM2203
{ {
public byte[] REGS; public byte[] REGS;
public FM.FM_OPN OPN; public FM.FM_OPN OPN;
@ -273,7 +273,7 @@ namespace MAME.Core
lt = FM.out_fm[0] + FM.out_fm[1] + FM.out_fm[2]; lt = FM.out_fm[0] + FM.out_fm[1] + FM.out_fm[2];
lt >>= 0; lt >>= 0;
lt = FM.Limit(lt, 32767, -32768); lt = FM.Limit(lt, 32767, -32768);
stream.streamoutput[0][offset + i] = lt; stream.streamoutput_Ptrs[0][offset + i] = lt;
} }
} }
} }

View File

@ -1158,7 +1158,7 @@ namespace MAME.Core
{ {
OPLLSetUpdateHandler(UpdateHandler, param); OPLLSetUpdateHandler(UpdateHandler, param);
}*/ }*/
public static void ym2413_update_one(int offset, int length) public unsafe static void ym2413_update_one(int offset, int length)
{ {
byte rhythm = (byte)(OPLL.rhythm & 0x20); byte rhythm = (byte)(OPLL.rhythm & 0x20);
int i; int i;
@ -1188,8 +1188,8 @@ namespace MAME.Core
ro = output[1]; ro = output[1];
mo = limit(mo, 32767, -32768); mo = limit(mo, 32767, -32768);
ro = limit(ro, 32767, -32768); ro = limit(ro, 32767, -32768);
Sound.ym2413stream.streamoutput[0][offset + i] = mo; Sound.ym2413stream.streamoutput_Ptrs[0][offset + i] = mo;
Sound.ym2413stream.streamoutput[1][offset + i] = ro; Sound.ym2413stream.streamoutput_Ptrs[1][offset + i] = ro;
advance(); advance();
} }
} }

View File

@ -2,7 +2,7 @@
namespace MAME.Core namespace MAME.Core
{ {
public class YM2610 public unsafe class YM2610
{ {
public byte[] REGS; public byte[] REGS;
public FM.FM_OPN OPN; public FM.FM_OPN OPN;
@ -522,8 +522,8 @@ namespace MAME.Core
rt += (int)((FM.out_fm[5] >> 1) & OPN.pan[11]); rt += (int)((FM.out_fm[5] >> 1) & OPN.pan[11]);
lt = FM.Limit(lt, 32767, -32768); lt = FM.Limit(lt, 32767, -32768);
rt = FM.Limit(rt, 32767, -32768); rt = FM.Limit(rt, 32767, -32768);
Sound.ym2610stream.streamoutput[0][offset + i] = lt; Sound.ym2610stream.streamoutput_Ptrs[0][offset + i] = lt;
Sound.ym2610stream.streamoutput[1][offset + i] = rt; Sound.ym2610stream.streamoutput_Ptrs[1][offset + i] = rt;
} }
} }
public void ym2610b_update_one(int offset, int length) public void ym2610b_update_one(int offset, int length)
@ -607,8 +607,8 @@ namespace MAME.Core
rt += (int)((FM.out_fm[5] >> 1) & OPN.pan[11]); rt += (int)((FM.out_fm[5] >> 1) & OPN.pan[11]);
lt = FM.Limit(lt, 32767, -32768); lt = FM.Limit(lt, 32767, -32768);
rt = FM.Limit(rt, 32767, -32768); rt = FM.Limit(rt, 32767, -32768);
Sound.ym2610stream.streamoutput[0][offset + i] = lt; Sound.ym2610stream.streamoutput_Ptrs[0][offset + i] = lt;
Sound.ym2610stream.streamoutput[1][offset + i] = rt; Sound.ym2610stream.streamoutput_Ptrs[1][offset + i] = rt;
} }
} }
public void ym2610_postload() public void ym2610_postload()