int DemoEntry(int argc, char *argv[]) { gSoloud.init(SoLoud::Soloud::CLIP_ROUNDOFF | SoLoud::Soloud::ENABLE_VISUALIZATION); gSoloud.setGlobalVolume(0.75); gSoloud.setPostClipScaler(0.75); gSpeechbusHandle = gSoloud.play(gSpeechbus); gSfxbusHandle = gSoloud.play(gSfxbus); gMusicbusHandle = gSoloud.play(gMusicbus); gSpeech[0].setText("There is flaky pastry in my volkswagon."); gSpeech[1].setText("The fragmentation of empiricism is hardly influential in its interdependence."); gSpeech[2].setText("Sorry, my albatros is not inflatable."); gSpeech[3].setText("The clairvoyance of omnipotence is in fact quite closed-minded in its ecology."); gSpeech[4].setText("Cheese is quite nice."); gSpeech[5].setText("Pineapple Scones with Squash and Pastrami Sandwich"); gSpeech[6].setText("The smart trader nowadays will be sure not to prorate OTC special-purpose entities."); gSpeech[7].setText("The penguins are in the toilets."); gSpeech[8].setText("Don't look, but there is a mountain lion stalking your children"); gSpeech[9].setText("The train has already gone, would you like to hire a bicycle?"); gSfxloop.load("audio/war_loop.ogg"); gSfxloop.setLooping(1); gMusicloop.load("audio/algebra_loop.ogg"); gMusicloop.setLooping(1); gSfxbus.play(gSfxloop); gMusicbus.play(gMusicloop); return 0; }
void Sound_Inspect(Asset& asset, bool deselected) { static int handle; static SoLoud::Bus bus; if (deselected) { soloud.stopAll(); return; } bus.setVisualizationEnable(true); SoLoud::AudioSource *src = (SoLoud::AudioSource*) asset.resource; ImGui::Text("Channels: %i", src->mChannels); ImGui::Text("Sample Rate: %0.f", src->mBaseSamplerate); int voice = soloud.getVoiceFromHandle(handle); if (ImGui::Button(voice == -1 ? "Play" : "Stop")) { if (voice != -1) { bus.stop(); } else { soloud.stopAll(); soloud.play(bus); handle = bus.play(*src); } } float *fft = bus.calcFFT(); ImGui::PlotHistogram("##FFT", fft, 256 / 2, 0, nullptr, 0, 20, ImVec2(0, 160), 8); }
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(); }