/* * 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 }
/******************************************************************************************** Begin vrpn_Sound_Server_Miles *******************************************************************************************/ vrpn_Sound_Server_Miles::vrpn_Sound_Server_Miles(const char * name, vrpn_Connection * c) : vrpn_Sound_Server(name, c) { AIL_startup(); //initialize the Miles SDK stuff //load a digital driver if (!AIL_quick_startup(1,0,44100,16,2)) { MessageBox(0,"Couldn't open a digital output device.","Error",MB_OK); } AIL_quick_handles(&DIG,0,0); // No sound played yet LastSoundId = -1; provider = 0; //Set variables to control size and growing of Audio handle array H_Max = vrpn_Sound_START; H_Cur = 0; //Allocate space for Audio Handle array samples = new H3DSAMPLE[H_Max]; //Set variables to control size and growing of providers array P_Max = vrpn_Sound_START; P_Cur = 0; //Allocate space for Audio Handle array providers = new HPROVIDER[P_Max]; // init eye from sensor matrix eye_f_sensor_m[0] = 1.0; eye_f_sensor_m[1] = 0.0; eye_f_sensor_m[2] = 0.0; eye_f_sensor_m[3] = 0.0; eye_f_sensor_m[4] = 0.0; eye_f_sensor_m[5] = 1.0; eye_f_sensor_m[6] = 0.0; eye_f_sensor_m[7] = 0.0; eye_f_sensor_m[8] = 0.0; eye_f_sensor_m[9] = 0.0; eye_f_sensor_m[10] = 1.0; eye_f_sensor_m[11] = 0.0; eye_f_sensor_m[12] = 0.0; eye_f_sensor_m[13] = 0.0; eye_f_sensor_m[14] = 0.0; eye_f_sensor_m[15] = 1.0; }
bool TForm_Main::InitMiles() { AIL_startup(); PCMWAVEFORMAT format; format.wf.wFormatTag = WAVE_FORMAT_PCM; format.wf.nChannels = 2; format.wf.nSamplesPerSec = 44100; format.wf.nBlockAlign = 4; format.wf.nAvgBytesPerSec = 44100 * format.wf.nBlockAlign; format.wBitsPerSample = 16; if (AIL_waveOutOpen(&m_hDigDriver, NULL, WAVE_MAPPER, (LPWAVEFORMAT) &format) != 0) return false; return true; }
int PASCAL WinMain( HINSTANCE instance, HINSTANCE previous_instance, LPSTR cmd_line, int cmd_show ) { // // Win32 locals. // HWND window = 0; MSG msg; // // Miles locals // HDIGDRIVER digital=0; // // Try to create our window. // window = Build_window_handle( instance, previous_instance ); if ( !window ) { MessageBox( 0, "Error creating window.", "Windows", MB_OK | MB_ICONSTOP ); return( 1 ); } // // Open the Miles Sound System. AIL_startup(); #ifdef BINK51 digital = AIL_open_digital_driver( 44100, 16, MSS_MC_51_DISCRETE, 0 ); #else digital = AIL_open_digital_driver( 44100, 16, 2, 0 ); #endif if ( !digital ) { MessageBox( 0, AIL_last_error( ), "Error opening Miles", MB_OK | MB_ICONSTOP ); return( 2 ); } // // // Tell Bink to use the Miles Sound System (must be before BinkOpen)! // BinkSoundUseMiles( digital ); // // Try to open the Bink file. // #ifdef BINK51 { // // Tell Bink to play all of the 5.1 tracks // S32 volumes[ 6 ]; U32 TrackIDsToPlay[ 4 ] = { 0, 1, 2, 3 }; BinkSetSoundTrack( 4, TrackIDsToPlay ); // // Try to open the Bink file. // Bink = BinkOpen( cmd_line, BINKSNDTRACK ); // // Now route the sound tracks to the correct speaker // volumes[ 0 ] = 32768; volumes[ 1 ] = 32768; volumes[ 2 ] = 0; volumes[ 3 ] = 0; volumes[ 4 ] = 0; volumes[ 5 ] = 0; BinkSetMixBinVolumes( Bink, 0, 0, volumes, 6 ); volumes[ 0 ] = 0; volumes[ 1 ] = 0; volumes[ 2 ] = 32768; BinkSetMixBinVolumes( Bink, 1, 0, volumes, 6 ); volumes[ 2 ] = 0; volumes[ 3 ] = 32768; BinkSetMixBinVolumes( Bink, 2, 0, volumes, 6 ); volumes[ 3 ] = 0; volumes[ 4 ] = 32768; volumes[ 5 ] = 32768; BinkSetMixBinVolumes( Bink, 3, 0, volumes, 6 ); } #else Bink = BinkOpen( cmd_line, 0 ); #endif if ( !Bink ) { MessageBox( 0, BinkGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); return( 3 ); } // // Try to open the Bink buffer. // Bink_buffer = BinkBufferOpen( window, Bink->Width, Bink->Height, 0 ); if ( !Bink_buffer ) { MessageBox( 0, BinkBufferGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); BinkClose( Bink ); return( 4 ); } // // Size the window such that its client area exactly fits our Bink movie. // SetWindowPos( window, 0, 0, 0, Bink_buffer->WindowWidth, Bink_buffer->WindowHeight, SWP_NOMOVE ); // // Now display the window and start the message loop. // ShowWindow( window, cmd_show ); for ( ; ; ) { // // Are there any messages to handle? // if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { // // Yup, handle them. // if ( msg.message == WM_QUIT ) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } else { // // Is it time for a new Bink frame? // if ( !BinkWait( Bink ) ) { // // Yup, draw the next frame. // Show_next_frame( Bink, Bink_buffer, window ); } else { // // Nope, give the rest of the system a chance to run (1 ms). // Sleep( 1 ); } } } // // Close the Bink file. // if ( Bink ) { BinkClose( Bink ); Bink = 0; } // // Close the Bink buffer. // if ( Bink_buffer ) { BinkBufferClose( Bink_buffer ); Bink_buffer = 0; } // // Close Miles. // if ( digital ) { AIL_close_digital_driver( digital ); digital = 0; } AIL_shutdown( ); // // And exit. // return( 0 ); }
int PASCAL WinMain( HINSTANCE instance, HINSTANCE previous_instance, LPSTR cmd_line, int cmd_show ) { // // Win32 locals. // HWND window = 0; MSG msg; // // Miles locals // HDIGDRIVER digital=0; // // Try to create our window. // window = Build_window_handle( instance, previous_instance ); if ( !window ) { MessageBox( 0, "Error creating window.", "Windows", MB_OK | MB_ICONSTOP ); return( 1 ); } // // Open the Miles Sound System. AIL_startup(); digital = AIL_open_digital_driver( 44100, 16, 2, 0 ); if ( !digital ) { MessageBox( 0, AIL_last_error( ), "Error opening Miles", MB_OK | MB_ICONSTOP ); return( 2 ); } // // // Tell Bink to use the Miles Sound System (must be before BinkOpen)! // BinkSoundUseMiles( digital ); // // Try to open the Bink file. // Bink = BinkOpen( cmd_line, 0 ); if ( !Bink ) { MessageBox( 0, BinkGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); return( 3 ); } // // Try to open the Bink buffer. // Bink_buffer = BinkBufferOpen( window, Bink->Width, Bink->Height, 0 ); if ( !Bink_buffer ) { MessageBox( 0, BinkBufferGetError( ), "Bink Error", MB_OK | MB_ICONSTOP ); DestroyWindow( window ); BinkClose( Bink ); return( 4 ); } // // Size the window such that its client area exactly fits our Bink movie. // SetWindowPos( window, 0, 0, 0, Bink_buffer->WindowWidth, Bink_buffer->WindowHeight, SWP_NOMOVE ); // // Now display the window and start the message loop. // ShowWindow( window, cmd_show ); for ( ; ; ) { // // Are there any messages to handle? // if ( PeekMessage( &msg, 0, 0, 0, PM_REMOVE ) ) { // // Yup, handle them. // if ( msg.message == WM_QUIT ) break; TranslateMessage( &msg ); DispatchMessage( &msg ); } else { // // Is it time for a new Bink frame? // if ( !BinkWait( Bink ) ) { // // Yup, draw the next frame. // Show_next_frame( Bink, Bink_buffer, window ); } else { // // Nope, give the rest of the system a chance to run (500 MICROseconds). // Good_sleep_us( 500 ); } } } // // Close the Bink file. // if ( Bink ) { BinkClose( Bink ); Bink = 0; } // // Close the Bink buffer. // if ( Bink_buffer ) { BinkBufferClose( Bink_buffer ); Bink_buffer = 0; } // // Close Miles. // if ( digital ) { AIL_close_digital_driver( digital ); digital = 0; } AIL_shutdown( ); // // And exit. // return( 0 ); }