void DemoMainloop() { DemoUpdateStart(); if (speechtick < DemoTick()) { int h = gSpeechbus.play(gSpeech[speechcount % 10], (rand() % 200) / 50.0f + 2, (rand() % 20) / 10.0f - 1); speechcount++; gSoloud.setRelativePlaySpeed(h, (rand() % 100) / 200.0f + 0.75f); gSoloud.fadePan(h, (rand() % 20) / 10.0f - 1, 2); speechtick = DemoTick() + 4000; } float *buf = gSoloud.getWave(); float *fft = gSoloud.calcFFT(); ONCE(ImGui::SetNextWindowPos(ImVec2(500, 20))); ImGui::Begin("Output"); ImGui::PlotLines("##Wave", buf, 256, 0, "Wave", -1, 1, ImVec2(264, 80)); ImGui::PlotHistogram("##FFT", fft, 256 / 2, 0, "FFT", 0, 10, ImVec2(264, 80), 8); ImGui::Text("Speech bus volume : %d%%", (int)floor(gSoloud.getVolume(gSpeechbusHandle) * 100)); ImGui::Text("Music bus volume : %d%%", (int)floor(gSoloud.getVolume(gMusicbusHandle) * 100)); ImGui::Text("Sfx bus volume : %d%%", (int)floor(gSoloud.getVolume(gSfxbusHandle) * 100)); ImGui::Text("Active voices : %d", gSoloud.getActiveVoiceCount()); ImGui::End(); ONCE(ImGui::SetNextWindowPos(ImVec2(20, 20))); ImGui::Begin("Control"); if (ImGui::SliderFloat("Speech bus volume", &gSpeechvol, 0, 2)) { gSoloud.setVolume(gSpeechbusHandle, gSpeechvol); } if (ImGui::SliderFloat("Music bus volume", &gMusicvol, 0, 2)) { gSoloud.setVolume(gMusicbusHandle, gMusicvol); } if (ImGui::SliderFloat("Sfx bus volume", &gSfxvol, 0, 2)) { gSoloud.setVolume(gSfxbusHandle, gSfxvol); } ImGui::End(); DemoUpdateEnd(); }
void DemoMainloop() { int i, j; DemoUpdateStart(); float tick = DemoTick() / 1000.0f; gSoloud.set3dListenerParameters( (float)gMouseX, 0, (float)gMouseY, 0, 0, 0, 0, 1, 0); gSoloud.update3dAudio(); for (i = 0; i < VOICEGRID; i++) { for (j = 0; j < VOICEGRID; j++) { float v = gSoloud.getOverallVolume(gSndHandle[i * VOICEGRID + j]); DemoTriangle( i * 15 + 20.0f, j * 15 + 20.0f, i * 15 + 20.0f - 5, j * 15 + 20.0f + 5, i * 15 + 20.0f + 5, j * 15 + 20.0f + 5, 0xff000000 | (int)(v * 0xff) * 0x010101); DemoTriangle( i * 15 + 20.0f, j * 15 + 20.0f + 10, i * 15 + 20.0f - 5, j * 15 + 20.0f + 5, i * 15 + 20.0f + 5, j * 15 + 20.0f + 5, 0xff000000 | (int)(v * 0xff) * 0x010101); } } float *buf = gSoloud.getWave(); float *fft = gSoloud.calcFFT(); ONCE(ImGui::SetNextWindowPos(ImVec2(500, 20))); ImGui::Begin("Output"); ImGui::PlotLines("##Wave", buf, 256, 0, "Wave", -1, 1, ImVec2(264, 80)); ImGui::PlotHistogram("##FFT", fft, 256 / 2, 0, "FFT", 0, 10, ImVec2(264, 80), 8); ImGui::Text("Active voices : %d", gSoloud.getActiveVoiceCount()); ImGui::Text("Total voices : %d", gSoloud.getVoiceCount()); ImGui::Text("Maximum voices : %d", VOICE_COUNT); ImGui::End(); DemoUpdateEnd(); }