blargg_err_t Nes_Vrc7_Apu::init() { CHECK_ALLOC( opll = ym2413_init( 3579545, 3579545 / 72, 1 ) ); set_output( 0 ); volume( 1.0 ); reset(); return 0; }
blargg_err_t Opl_Apu::init( long clock, long rate, blip_time_t period, type_t type ) { type_ = type; clock_ = clock; rate_ = rate; period_ = period; set_output( 0, 0 ); volume( 1.0 ); switch (type) { case type_opll: case type_msxmusic: case type_smsfmunit: opl = ym2413_init( clock, rate, 0 ); break; case type_vrc7: opl = ym2413_init( clock, rate, 1 ); break; case type_opl: opl = ym3526_init( clock, rate ); break; case type_msxaudio: //logfile = fopen("c:\\temp\\msxaudio.log", "wb"); opl = y8950_init( clock, rate ); opl_memory = malloc( 32768 ); y8950_set_delta_t_memory( opl, opl_memory, 32768 ); break; case type_opl2: opl = ym3812_init( clock, rate ); break; } reset(); return 0; }
static DEVICE_START( ym2413 ) { ym2413_state *info = get_safe_token(device); int rate = device->clock()/72; /* emulator create */ info->chip = ym2413_init(device, device->clock(), rate); assert_always(info->chip != NULL, "Error creating YM2413 chip"); /* stream system initialize */ info->stream = device->machine().sound().stream_alloc(*device,0,2,rate,info,ym2413_stream_update); ym2413_set_update_handler(info->chip, _stream_update, info); #if 0 int i, tst; char name[40]; num = intf->num; tst = YM3812_sh_start (msound); if (tst) return 1; for (i=0;i<num;i++) { ym2413_reset (i); ym2413[i].DAC_stream = device->machine().sound().stream_alloc(*device, 0, 1, device->clock()/72, i, YM2413DAC_update); if (ym2413[i].DAC_stream == -1) return 1; } return 0; #endif }
//static DEVICE_START( ym2413 ) int device_start_ym2413(void **_info, int EMU_CORE, int clock, int CHIP_SAMPLING_MODE, int CHIP_SAMPLE_RATE) { //ym2413_state *info = get_safe_token(device); ym2413_state *info; int rate; #ifdef ENABLE_ALL_CORES if (EMU_CORE >= 0x02) EMU_CORE = EC_EMU2413; #else EMU_CORE = EC_EMU2413; #endif info = (ym2413_state *) calloc(1, sizeof(ym2413_state)); *_info = (void*) info; info->EMU_CORE = EMU_CORE; info->Mode = (clock & 0x80000000) >> 31; clock &= 0x7FFFFFFF; rate = clock/72; if ((CHIP_SAMPLING_MODE == 0x01 && rate < CHIP_SAMPLE_RATE) || CHIP_SAMPLING_MODE == 0x02) rate = CHIP_SAMPLE_RATE; /* emulator create */ switch(EMU_CORE) { #ifdef ENABLE_ALL_CORES case EC_MAME: info->chip = ym2413_init(clock, rate); if (info->chip == NULL) return 0; //assert_always(info->chip != NULL, "Error creating YM2413 chip"); ym2413_set_chip_mode(info->chip, info->Mode); /* stream system initialize */ //info->stream = stream_create(device,0,2,rate,info,ym2413_stream_update); ym2413_set_update_handler(info->chip, _stream_update, info); break; #endif case EC_EMU2413: info->chip = OPLL_new(clock, rate); if (info->chip == NULL) return 0; OPLL_SetChipMode(info->chip, info->Mode); if (info->Mode) OPLL_setPatch(info->chip, vrc7_inst); break; } // Note: VRC7 instruments are set in device_reset if necessary. /*#if 0 int i, tst; char name[40]; num = intf->num; tst = YM3812_sh_start (msound); if (tst) return 1; for (i=0;i<num;i++) { ym2413_reset (i); ym2413[i].DAC_stream = stream_create(device, 0, 1, device->clock/72, i, YM2413DAC_update); if (ym2413[i].DAC_stream == -1) return 1; } return 0; #endif*/ return rate; }