/* * MusicInitialize: Check for a MIDI device, and open it if present. */ void MusicInitialize(void) { if (config.soundLibrary == LIBRARY_NIL) { has_midi = FALSE; return; } #ifdef M59_MSS hDigitalDriver = NULL; hseqBackground = NULL; hseqImmediate = NULL; // it's ok to do this more than once, and we do, // once in SoundInitialize and once here AIL_startup(); // Open first MIDI device, trying the MIDI Mapper first hDigitalDriver = AIL_open_digital_driver(44100, 16, MSS_MC_USE_SYSTEM_CONFIG, 0); if (hDigitalDriver == NULL) { debug(( "MSS digital sound failed to initialize, error = %s.\n", AIL_last_error() )); has_midi = False; return; } hseqBackground = AIL_allocate_sample_handle( hDigitalDriver ); hseqImmediate = AIL_allocate_sample_handle( hDigitalDriver ); if( ( hseqBackground == NULL ) || ( hseqImmediate == NULL ) ) { debug(( "MSS digital sound failed to allocate 2 handles.\n" )); has_midi = False; return; } debug(( "MSS digital sound initialized successfully.\n" )); has_midi = True; #else MCI_SYSINFO_PARMS mciSysinfoParms; DWORD num_devices, retval; mciSysinfoParms.lpstrReturn = (LPSTR) &num_devices; mciSysinfoParms.dwRetSize = sizeof(num_devices); mciSysinfoParms.wDeviceType = MCI_DEVTYPE_SEQUENCER; retval = mciSendCommand(0, MCI_SYSINFO, MCI_SYSINFO_QUANTITY, (DWORD) &mciSysinfoParms); if (retval == 0 && num_devices > 0) { has_midi = True; ResetMusicVolume(); } #endif // M59_MSS }
// // Claim // // Claim and 2D and 3D voices using the given providers // void Claim(HDIGDRIVER *h2D, U32 max2D, HPROVIDER *h3D, U32 max3D) { LOG_DIAG(("Output::Claim:")); // Do we have a 2D digital audio service if (h2D) { // Allocate the 2D voices U32 v = 0; for (; v < max2D && totalVoices < MAX_VOICES; v++) { // Allocate a new voice handle if (HSAMPLE vHandle = AIL_allocate_sample_handle(*h2D)) { // Allocate a new 2D voice voices[totalVoices++] = new Voice(vHandle); } else { // No more voices to allocate break; } } LOG_DIAG((" - Allocated %d 2D voices", v)); } else { LOG_DIAG((" - No 2D digital audio services")); } // Do we have a 3D digital audio service if (h3D) { // Allocate the 3D voices U32 v = 0; for (; v < max3D && totalVoices < MAX_VOICES; v++) { // Allocate a new voice handle H3DSAMPLE vHandle = AIL_allocate_3D_sample_handle(*h3D); if (vHandle) { // Allocate a new 3D voice voices[totalVoices++] = new Voice(vHandle); } else { // No more voices to allocate break; } } LOG_DIAG((" - Allocated %d 3D voices", v)); } else { LOG_DIAG((" - No 3D digital audio services")); } }
bool TForm_Main::OpenFile() { // STOP!!! c_Button_Stop->Click(); // Let go... if (m_hSample) { AIL_release_sample_handle(m_hSample); m_hSample = NULL; } // Get rid of the buffer if it's already been loaded if (m_pFileBuffer) { AIL_mem_free_lock(m_pFileBuffer); m_pFileBuffer = NULL; } // Remember the file name m_CurFile = c_Edit_FileName->Text; // Er, don't load if it doesn't exist... if (!FileExists(m_CurFile)) { m_CurFile = ""; return false; } m_hSample = AIL_allocate_sample_handle(m_hDigDriver); if (!m_hSample) { ChangeStatus("Error allocating sample handle"); m_CurFile = ""; return false; } char *pFileName = m_CurFile.c_str(); // Bind to the file m_pFileBuffer = AIL_file_read(pFileName, NULL); if (!m_pFileBuffer) { ChangeStatus("Error opening " + m_CurFile + " (" + IntToStr(AIL_file_error()) + ")"); m_CurFile = ""; return false; } // Get the file size m_iFileSize = AIL_file_size(pFileName); AIL_init_sample(m_hSample); AIL_set_named_sample_file(m_hSample, pFileName, m_pFileBuffer, m_iFileSize, 0); AIL_set_sample_loop_count(m_hSample, 0); AIL_set_sample_volume(m_hSample, 127); AIL_set_sample_processor(m_hSample, DP_FILTER, m_hCurFilter); ChangeStatus("Loaded " + m_CurFile); return true; }