public override int start(Mame.MachineSound msound) { OKIM6295interface intf = (OKIM6295interface)msound.sound_interface; string stream_name; int i; /* reset the ADPCM system */ num_voices = (byte)(intf.num * MAX_OKIM6295_VOICES); compute_tables(); sample_list = null; /* initialize the voices */ for (i = 0; i < num_voices; i++) { int chip = i / MAX_OKIM6295_VOICES; int voice = i % MAX_OKIM6295_VOICES; /* reset the OKI-specific parameters */ okim6295_command[chip] = -1; okim6295_base[chip][voice] = 0; /* generate the name and create the stream */ stream_name = Mame.sprintf("%s #%d (voice %d)", Mame.sound_name(msound), chip, voice); _adpcm[i].stream = Mame.stream_init(stream_name, intf.mixing_level[chip], Mame.Machine.sample_rate, i, adpcm_update); if (_adpcm[i].stream == -1) return 1; /* initialize the rest of the structure */ _adpcm[i].region_base = Mame.memory_region(intf.region[chip]); _adpcm[i].volume = 255; _adpcm[i].signal = unchecked((uint)-2); if (Mame.Machine.sample_rate != 0) _adpcm[i].source_step = (uint)((double)intf.frequency[chip] * (double)FRAC_ONE / (double)Mame.Machine.sample_rate); } /* success */ return 0; }
public override void stop() { sample_list = null; throw new NotImplementedException(); }
public override int start(Mame.MachineSound msound) { ADPCMinterface intf = (ADPCMinterface)msound.sound_interface; string stream_name; /* reset the ADPCM system */ num_voices = (byte)intf.num; compute_tables(); sample_list = null; /* generate the sample table, if one is needed */ if (intf.init != null) { /* allocate memory for it */ sample_list = new ADPCMsample[257]; if (sample_list == null) return 1; for (int i = 0; i < 257; i++) sample_list[i] = new ADPCMsample(); /* callback to initialize */ intf.init(intf, sample_list, 256); } /* initialize the voices */ //memset(adpcm, 0, sizeof(adpcm)); for (int i = 0; i < num_voices; i++) { /* generate the name and create the stream */ stream_name = Mame.sprintf("%s #%d", Mame.sound_name(msound), i); adpcm[i].stream = Mame.stream_init(stream_name, intf.mixing_level[i], Mame.Machine.sample_rate, i, okim6295.adpcm_update); if (adpcm[i].stream == -1) return 1; /* initialize the rest of the structure */ adpcm[i].region_base = Mame.memory_region(intf.region); adpcm[i].volume = 255; adpcm[i].signal = unchecked((uint)-2); if (Mame.Machine.sample_rate != 0) adpcm[i].source_step = (uint)((double)intf.frequency * (double)FRAC_ONE / (double)Mame.Machine.sample_rate); } /* success */ return 0; }