Example #1
0
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();
}
Example #2
0
	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();
	}
Example #3
0
void DemoMainloop()
{
    gSoloud.setFilterParameter(gMusichandle, 0, 0, filter_param0[0]);
    gSoloud.setFilterParameter(gMusichandle, 1, 0, filter_param0[1]);
    gSoloud.setFilterParameter(gMusichandle, 2, 0, filter_param0[2]);
    gSoloud.setFilterParameter(gMusichandle, 3, 0, filter_param0[3]);

    gSoloud.setFilterParameter(gMusichandle, 0, 2, filter_param1[0]);
    gSoloud.setFilterParameter(gMusichandle, 0, 3, filter_param2[0]);
    gSoloud.setFilterParameter(gMusichandle, 1, 1, filter_param1[1]);
    gSoloud.setFilterParameter(gMusichandle, 1, 2, filter_param2[1]);

    DemoUpdateStart();

    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("Music volume     : %d%%", (int)floor(gSoloud.getVolume(gMusichandle) * 100));
    ImGui::Text("Active voices    : %d", gSoloud.getActiveVoiceCount());
    ImGui::End();

    ONCE(ImGui::SetNextWindowPos(ImVec2(20, 20)));

    ImGui::Begin("Control");
    if (ImGui::SliderInt("Channels", &hwchannels, 1, 4))
    {
        gMusic.setParams(hwchannels, waveform);
    }
    if (ImGui::CollapsingHeader("Waveform", (const char*)0, true, false))
    {
        if (ImGui::RadioButton("Square", waveform == SoLoud::Monotone::SQUARE))
        {
            waveform = SoLoud::Monotone::SQUARE;
            gMusic.setParams(hwchannels, waveform);
        }
        if (ImGui::RadioButton("Saw", waveform == SoLoud::Monotone::SAW))
        {
            waveform = SoLoud::Monotone::SAW;
            gMusic.setParams(hwchannels, waveform);
        }
        if (ImGui::RadioButton("Sin", waveform == SoLoud::Monotone::SIN))
        {
            waveform = SoLoud::Monotone::SIN;
            gMusic.setParams(hwchannels, waveform);
        }
        if (ImGui::RadioButton("SawSin", waveform == SoLoud::Monotone::SAWSIN))
        {
            waveform = SoLoud::Monotone::SAWSIN;
            gMusic.setParams(hwchannels, waveform);
        }
    }
    ImGui::Separator();
    ImGui::Text("Biquad filter (lowpass)");
    ImGui::SliderFloat("Wet##4", &filter_param0[0], 0, 1);
    ImGui::SliderFloat("Frequency##4", &filter_param1[0], 0, 8000);
    ImGui::SliderFloat("Resonance##4", &filter_param2[0], 1, 20);
    ImGui::Separator();
    ImGui::Text("Lofi filter");
    ImGui::SliderFloat("Wet##2", &filter_param0[1], 0, 1);
    ImGui::SliderFloat("Rate##2", &filter_param1[1], 1000, 8000);
    ImGui::SliderFloat("Bit depth##2", &filter_param2[1], 0, 8);
    ImGui::Separator();
    ImGui::Text("Echo filter");
    ImGui::SliderFloat("Wet##3", &filter_param0[2], 0, 1);
    ImGui::Separator();
    ImGui::Text("DC removal filter");
    ImGui::SliderFloat("Wet##1", &filter_param0[3], 0, 1);
    ImGui::End();
    DemoUpdateEnd();
}
Example #4
0
// Entry point
int main(int argc, char *argv[])
{
	DemoInit();

	gMusic.load("audio/Jakim - Aboriginal Derivatives.mon");
	gMusic.setParams(10);

	gEcho.setParams(0.2f, 0.5f, 0.05f);
	gBiquad.setParams(SoLoud::BiquadResonantFilter::LOWPASS, 44100, 4000, 2);

	gMusic.setLooping(1);	
	gMusic.setFilter(0, &gBiquad);
	gMusic.setFilter(1, &gLofi);
	gMusic.setFilter(2, &gEcho);
	gMusic.setFilter(3, &gDCRemoval);

	gSoloud.init(SoLoud::Soloud::CLIP_ROUNDOFF | SoLoud::Soloud::ENABLE_VISUALIZATION);

	gMusichandle = gSoloud.play(gMusic);


	float filter_param0[4] = { 0, 0, 0, 0 };
	float filter_param1[4] = { 1000, 8000, 0, 0 };
	float filter_param2[4] = { 2, 3,  0, 0 };
	
	int hwchannels = 4;
	int waveform = 0;

	// Main loop: loop forever.
	while (1)
	{
		gSoloud.setFilterParameter(gMusichandle, 0, 0, filter_param0[0]);
		gSoloud.setFilterParameter(gMusichandle, 1, 0, filter_param0[1]);
		gSoloud.setFilterParameter(gMusichandle, 2, 0, filter_param0[2]);
		gSoloud.setFilterParameter(gMusichandle, 3, 0, filter_param0[3]);

		gSoloud.setFilterParameter(gMusichandle, 0, 2, filter_param1[0]);
		gSoloud.setFilterParameter(gMusichandle, 0, 3, filter_param2[0]);
		gSoloud.setFilterParameter(gMusichandle, 1, 1, filter_param1[1]);
		gSoloud.setFilterParameter(gMusichandle, 1, 2, filter_param2[1]);

		DemoUpdateStart();

		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("Music volume     : %d%%", (int)floor(gSoloud.getVolume(gMusichandle) * 100));
		ImGui::Text("Active voices    : %d", gSoloud.getActiveVoiceCount());
		ImGui::End();

		ONCE(ImGui::SetNextWindowPos(ImVec2(20, 20)));
		
		ImGui::Begin("Control");
		if (ImGui::SliderInt("Channels", &hwchannels, 1, 4))
		{
			gMusic.setParams(hwchannels, waveform);
		}
		if (ImGui::CollapsingHeader("Waveform", (const char*)0, true, false))
		{
			if (ImGui::RadioButton("Square", waveform == SoLoud::Monotone::SQUARE))
			{
				waveform = SoLoud::Monotone::SQUARE;
				gMusic.setParams(hwchannels, waveform);
			}
			if (ImGui::RadioButton("Saw", waveform == SoLoud::Monotone::SAW))
			{
				waveform = SoLoud::Monotone::SAW;
				gMusic.setParams(hwchannels, waveform);
			}
			if (ImGui::RadioButton("Sin", waveform == SoLoud::Monotone::SIN))
			{
				waveform = SoLoud::Monotone::SIN;
				gMusic.setParams(hwchannels, waveform);
			}
			if (ImGui::RadioButton("SawSin", waveform == SoLoud::Monotone::SAWSIN))
			{
				waveform = SoLoud::Monotone::SAWSIN;
				gMusic.setParams(hwchannels, waveform);
			}
		}
		ImGui::Separator();
		ImGui::Text("Biquad filter (lowpass)");
		ImGui::SliderFloat("Wet##4", &filter_param0[0], 0, 1);
		ImGui::SliderFloat("Frequency##4", &filter_param1[0], 0, 8000);
		ImGui::SliderFloat("Resonance##4", &filter_param2[0], 1, 20);
		ImGui::Separator();
		ImGui::Text("Lofi filter");
		ImGui::SliderFloat("Wet##2", &filter_param0[1], 0, 1);
		ImGui::SliderFloat("Rate##2", &filter_param1[1], 1000, 8000);
		ImGui::SliderFloat("Bit depth##2", &filter_param2[1], 0, 8);
		ImGui::Separator();
		ImGui::Text("Echo filter");
		ImGui::SliderFloat("Wet##3", &filter_param0[2], 0, 1);
		ImGui::Separator();
		ImGui::Text("DC removal filter");
		ImGui::SliderFloat("Wet##1", &filter_param0[3], 0, 1);
		ImGui::End();
		DemoUpdateEnd();
	}
	return 0;
}
Example #5
0
void DemoMainloop_megademo()
{
	DemoUpdateStart();

	ONCE(ImGui::SetNextWindowPos(ImVec2(20, 0)));
	ImGui::Begin("Select sub-demo to run");

	if (ImGui::Button("Multimusic"))
	{
		DemoEntry_multimusic(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_multimusic;
	}
	ImGui::Text("Multimusic demo plays multiple music tracks\n"
		        "with interactive options to fade between them.");

	ImGui::Separator();

	if (ImGui::Button("Monotone"))
	{
		DemoEntry_monotone(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_monotone;
	}
	ImGui::Text("Monotone demo plays a \"monotone\" tracker song\n"
		        "with various interative options and filters.");

	ImGui::Separator();

	if (ImGui::Button("Mixbusses"))
	{
		DemoEntry_mixbusses(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_mixbusses;
	}
	ImGui::Text("Mixbusses creates three different mix busses,\n"
				"plays different sounds in each and lets user\n"
				"adjust the volume of the bus interactively.");

	ImGui::Separator();

	if (ImGui::Button("3d test"))
	{
		DemoEntry_test3d(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_test3d;
	}
	ImGui::Text("3d test demo is a test of the 3d sound.");

	ImGui::Separator();

	if (ImGui::Button("pewpew"))
	{
		DemoEntry_pewpew(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_pewpew;
	}
	ImGui::Text("pewpew demo shows the use of play_clocked\n"
				"and how delaying sound makes it feel like\n"
				"it plays earlier.");

	ImGui::Separator();

	if (ImGui::Button("radiogaga"))
	{
		DemoEntry_radiogaga(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_radiogaga;
	}
	ImGui::Text("radiogaga demo demonstrates audio queues\n"
				"to generate endless music by chaining random\n"
				"clips of music.\n");

	ImGui::Separator();

	if (ImGui::Button("space"))
	{
		DemoEntry_space(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_space;
	}
	ImGui::Text("space demo is a mockup of a conversation\n"
				"in a space game, and shows use of the\n"
				"visualization interfaces.");

	ImGui::Separator();

	if (ImGui::Button("speechfilter"))
	{
		DemoEntry_speechfilter(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_speechfilter;
	}
	ImGui::Text("speechfilter demonstrates various\n"
				"DSP effects on speech synthesis.");

	ImGui::Separator();

	if (ImGui::Button("tedsid"))
	{
		DemoEntry_tedsid(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_tedsid;
	}
	ImGui::Text("tedsid demonstrates the MOS TED and SID\n"
	            "synthesis engines.");

	ImGui::Separator();

	if (ImGui::Button("virtualvoices"))
	{
		DemoEntry_virtualvoices(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_virtualvoices;
	}
	ImGui::Text("virtualvoices demonstrates playing way\n"
	            "more sounds than is actually possible,\n"
				"and having the ones active that matter.");

	ImGui::Separator();

	if (ImGui::Button("wavformats"))
	{
		DemoEntry_wavformats(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_wavformats;
	}
	ImGui::Text("wavformats test plays files with\n"
				"all sorts of wave file formats.");

	ImGui::Separator();

	if (ImGui::Button("speakers"))
	{
		DemoEntry_speakers(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_speakers;
	}
	ImGui::Text("speakers test plays single sounds\n"
				"through surround speakers.\n");

	ImGui::Separator();

	if (ImGui::Button("thebutton"))
	{
		DemoEntry_thebutton(gArgc, gArgv);
		DemoMainloopPtr = DemoMainloop_thebutton;
	}
	ImGui::Text("thebutton test shows one way of\n"
		        "avoiding actor speaking on top\n"
		        "of themselves.\n");

	ImGui::End();


	DemoUpdateEnd();
}