int OPL_Init(unsigned int rate) { opl_sample_rate = rate; opl_paused = 0; pause_offset = 0; // Queue structure of callbacks to invoke. callback_queue = OPL_Queue_Create(); current_time = 0; mix_buffer = malloc(opl_sample_rate * sizeof(uint32_t)); // Create the emulator structure: DBOPL_InitTables(); Chip__Chip(&opl_chip); Chip__Setup(&opl_chip, opl_sample_rate); OPL_InitRegisters(); init_stage_reg_writes = 0; return 1; }
void COPLEmulator::init() { DBOPL_InitTables(); Chip__Chip(&m_opl_chip); Chip__Setup(&m_opl_chip, m_AudioDevSpec.freq); StartOPLforAdlibSound(); }
static int OPL_SDL_Init(unsigned int port_base) { // Check if SDL_mixer has been opened already // If not, we must initialize it now if (!SDLIsInitialized()) { if (SDL_Init(SDL_INIT_AUDIO) < 0) { fprintf(stderr, "Unable to set up sound.\n"); return 0; } if (Mix_OpenAudio(opl_sample_rate, AUDIO_S16SYS, 2, GetSliceSize()) < 0) { fprintf(stderr, "Error initialising SDL_mixer: %s\n", Mix_GetError()); SDL_QuitSubSystem(SDL_INIT_AUDIO); return 0; } SDL_PauseAudio(0); // When this module shuts down, it has the responsibility to // shut down SDL. sdl_was_initialized = 1; } else { sdl_was_initialized = 0; } opl_sdl_paused = 0; pause_offset = 0; // Queue structure of callbacks to invoke. callback_queue = OPL_Queue_Create(); current_time = 0; // Get the mixer frequency, format and number of channels. Mix_QuerySpec(&mixing_freq, &mixing_format, &mixing_channels); // Only supports AUDIO_S16SYS if (mixing_format != AUDIO_S16SYS || mixing_channels != 2) { fprintf(stderr, "OPL_SDL only supports native signed 16-bit LSB, " "stereo format!\n"); OPL_SDL_Shutdown(); return 0; } // Mix buffer: mix_buffer = malloc(mixing_freq * sizeof(uint32_t)); // Create the emulator structure: DBOPL_InitTables(); Chip__Chip(&opl_chip); Chip__Setup(&opl_chip, mixing_freq); callback_mutex = SDL_CreateMutex(); callback_queue_mutex = SDL_CreateMutex(); // TODO: This should be music callback? or-? Mix_HookMusic(OPL_Mix_Callback, NULL); return 1; }
static inline void YM3812Init(int numChips, int clock, int rate) { DBOPL_InitTables(); Chip__Chip(&oplChip); Chip__Setup(&oplChip, rate); }