void CALLBACK SPU2close() { LOG_CALLBACK("SPU2close()\n"); g_nSpuInit = 0; if ( g_bPlaySound && !s_bThreadExit ) { s_bThreadExit = true; printf("ZeroSPU2: Waiting for thread... "); #ifdef _WIN32 WaitForSingleObject(s_threadSPU2, INFINITE); CloseHandle(s_threadSPU2); s_threadSPU2 = NULL; #else pthread_join(s_threadSPU2, NULL); #endif printf("done\n"); } RemoveSound(); delete g_pWavRecord; g_pWavRecord = NULL; delete pSoundTouch; pSoundTouch = NULL; for (u32 i = 0; i < ArraySize(s_pAudioBuffers); ++i) { _aligned_free(s_pAudioBuffers[i].pbuf); } memset(s_pAudioBuffers, 0, sizeof(s_pAudioBuffers)); }
static void ConfigureSound(void) { Widget sound_widgets[] = { { WIDGET_TEXT, ALIGN_CENTER, 213, 20, 0, 0, "Sound", 0, 0, 0, 0, NULL, NULL, NULL, 0 }, { WIDGET_TEXT, ALIGN_LEFT, 20, 60, 0, 0, "Audio Device:", -1, 0, 0, 0, NULL, NULL, NULL, 0 }, { WIDGET_OPTION, ALIGN_LEFT, 119, 60, 0, 0, NULL, 0, 0, 0, 0, (void *)digi_getter, NULL, NULL, 0 }, { WIDGET_TEXT, ALIGN_LEFT, 20, 85, 0, 0, "Music Device:", -1, 0, 0, 0, NULL, NULL, NULL, 0 }, { WIDGET_OPTION, ALIGN_LEFT, 119, 85, 0, 0, NULL, 0, 0, 0, 0, (void *)midi_getter, NULL, NULL, 0 }, { WIDGET_TEXT, ALIGN_LEFT, 20, 110, 0, 0, "Audio volume:", -1, 0, 0, 0, NULL, NULL, NULL, 0 }, { WIDGET_SLIDER, ALIGN_LEFT, 119, 110, 255, 0, 0, 0, 1, 10, 0, NULL, NULL, NULL, 0 }, { WIDGET_TEXT, ALIGN_LEFT, 20, 135, 0, 0, "Music volume:", -1, 0, 0, 0, NULL, NULL, NULL, 0 }, { WIDGET_SLIDER, ALIGN_LEFT, 119, 135, 255, 0, 0, 0, 1, 10, 0, NULL, NULL, NULL, 0 }, { WIDGET_BUTTON, ALIGN_CENTER, 213, 165, -1, 0, "OK", 8, 9, 0, 0, NULL, NULL, NULL, 0 }, { WIDGET_END, } }; sound_widgets[0].d1 = makecol(255, 255, 0); sound_widgets[2].d1 = 0; for (int i = 0; i < num_digi_drivers; i++) if (digi_drivers[i].driver == configuration.sound_driver) { sound_widgets[2].d1 = i; break; } sound_widgets[4].d1 = 0; for (int i = 0; i < num_midi_drivers; i++) if (midi_drivers[i].driver == configuration.midi_driver) { sound_widgets[4].d1 = i; break; } sound_widgets[6].d1 = configuration.sound_volume; sound_widgets[8].d1 = configuration.music_volume; GUI_Go(400-213, 300-110, 427, 220, sound_widgets, 2, 0); rest(200); // allow sample to finish playing configuration.sound_driver = digi_drivers[sound_widgets[2].d1].driver; configuration.midi_driver = midi_drivers[sound_widgets[4].d1].driver; configuration.sound_volume = sound_widgets[6].d1; configuration.music_volume = sound_widgets[8].d1; for (;;) { RemoveSound(); try { InstallSound(); } catch (BadInstall) { if (GUI_Prompt("|255000000Error setting up sound... Try again?", "Yes", "No") == 1) continue; } break; } PlayIntroMusic(); }
void SoundAndHaptics(void) { if (space_pressed) { if (acted <= 1) waveOutSetVolume(NULL, 1); else if (acted >= 180000) { if (GetSoundStage()) { waveOutSetVolume(NULL, 180000); } } else { if (GetSoundStage()) { waveOutSetVolume(NULL, acted*1000); } } if (!GetSoundStage()) RemoveSound(); if (hapticsConnected) { if (!GetHapticsStage()) { RemoveHaptics(); } } if (acted) { if (!hand_is_on) { if (GetHapticsStage() && hapticsConnected) system("C:/Python33/python.exe gloves.py on"); else { if (hapticsConnected) RemoveHaptics(); } if (!GetSoundStage()) RemoveSound(); hand_is_on = true; } } else { if (hand_is_on) { if (GetHapticsStage() && hapticsConnected) system("C:/Python33/python.exe gloves.py off"); else { if (hapticsConnected) RemoveHaptics(); } if (GetSoundStage()) waveOutSetVolume(NULL, 100); else RemoveSound(); hand_is_on = false; } } } else { RemoveSound(); if (hapticsConnected) RemoveHaptics(); } }
int main( int argc, char** argv) { /* Intilising the stage */ printf("Initilising stage... \n"); new Stage(); /* Initates the screen and its context */ SDLContext* cntx = new SDLContext();//Window+render /* Initilaizes the input */ Input* inp = new Input();//Input system. cntx->SetInput( inp );//Context redirects mouse+keyb to Input /* Initializes the model */ unsigned int power = 7; GridModel* model = new GridModel(power);//power of 2 float modelSide = 0.5f; // meters /* Data exporter */ DataExporter exporter (power); inp->SetDataExporter(&exporter); inp->SetModel( model ); inp->SetModelSide(modelSide); inp->SetModelPosition(glm::vec3(0.0f, 0.0f, 1.0f)); float side = inp->GetModelSide(); std::cout << "Model side is " << side << std::endl; std::cout << "Model initialized" << std::endl; model->UpdateGrid(&exporter);// update visual representation of model std::cout << "Grid updated" << std::endl; /* Initilizes the tool */ KinectTool* tool = new KinectTool( (side*0.75f), (side*0.75f), side*0.75f + 100, -(side*.75f)); /* Initializes head tracking */ StereoKinectHeadTracking* headTracking = new StereoKinectHeadTracking(); tool->_reader->Init(headTracking); cntx->SetHeadTracking(headTracking); /* Initilizes the the font and text */ int fontSize = 20; int dif = 5; TextureMappedFont* font1 = new TextureMappedFont("font1.bmp", fontSize); TextureMappedFont* font2 = new TextureMappedFont("font1.bmp", fontSize + dif); TextureMappedFont* font3 = new TextureMappedFont("font1.bmp", fontSize + 2*dif); /* Initilizes Windows socket */ //WSADATA wsaData; //WSAStartup(0x0202, &wsaData); void** speech_thread_args = (void**)malloc(2 * sizeof(void*)); speech_thread_args[0] = (void*)tool; speech_thread_args[1] = (void*)inp; pthread_t speechThread; pthread_create(&speechThread, NULL, SpeechThreed, speech_thread_args); PlaySound(TEXT("VS-midle-sound.wav"), NULL, SND_LOOP | SND_ASYNC); std::cout << "Starting main loop" << std::endl; clock_t start = clock() - 1; while (cntx->alive()) { clock_t end = clock(); float deltaTime = (float)(end - start) / CLOCKS_PER_SEC; cntx->doMessage(); //Win message loop tool->DoToolUpdate(); //update tool state - like depthmap headTracking->Update(deltaTime); inp->UpdateHandPosition(headTracking->GetHandPosition(true), headTracking->GetHandPosition(false)); inp->UpdateFrame(deltaTime); //Update frame variables. if ( GetPressedStage() ) tool->StartInteractModel( model, inp->GetObjectQ(), inp->GetObjectM(), inp->GetModelSide()); cntx->renderScene(model, tool, inp->GetViewM(), inp->GetObjectM(), font1, font2, font3);// do actual rendering. if ( GetPressedStage() ) acted = tool->StopInteractModel( );//obvious model->UpdateGrid(&exporter); // update visual representation of model exporter.update(inp->GetObjectQ(), headTracking); SoundAndHaptics(); start = end; } RemoveSound(); if (hapticsConnected) RemoveHaptics(); delete model; delete inp; delete tool; delete cntx; delete headTracking; return 0; }