void draw() { background(gray(122)); if (Soloud_getActiveVoiceCount(soloud) > 0) { float * v = Soloud_calcFFT(soloud); int p = (int)(v[10] * 30); rect(10, 10, p * 10, 30); } if (keyReleased) { char sentence[20]; sprintf(sentence, "%c", key); destroyAudio(keySound); keySound = loadSpeech(sentence); playAudio(keySound); } textFont(font); textAlign(NVG_ALIGN_LEFT); textSize(30); textLeading(5); text(sentence, 10, 100); }
void draw() { background(gray(122)); while (Soloud_getActiveVoiceCount(soloud) > 0) { float * v = Soloud_calcFFT(soloud); int p = (int)(v[10] * 30); if (p > 59) p = 59; for (i = 0; i < p; i++) printf("="); for (i = p; i < 60; i++) printf(" "); printf("\r"); printf("%c\r", "|\\-/"[i&3]); i++; } }
int main(int parc, char ** pars) { int i = 0; Soloud *soloud = Soloud_create(); Speech *speech = Speech_create(); Speech_setText(speech, "1 2 3 A B C Doooooo Reeeeee Miiiiii Faaaaaa Soooooo Laaaaaa Tiiiiii Doooooo!"); #ifdef _WIN32 Soloud_winmm_initEx(soloud, SOLOUD_CLIP_ROUNDOFF | SOLOUD_ENABLE_VISUALIZATION, 44100, 4096); #else Soloud_portaudio_initEx(soloud, SOLOUD_CLIP_ROUNDOFF | SOLOUD_ENABLE_VISUALIZATION, 44100, 4096); #endif Soloud_setGlobalVolume(soloud, 4); Soloud_play(soloud, speech); printf("Playing..\n"); while (Soloud_getActiveVoiceCount(soloud) > 0) { float * v = Soloud_calcFFT(soloud); int p = (int)(v[10] * 30); if (p > 59) p = 59; for (i = 0; i < p; i++) printf("="); for (i = p; i < 60; i++) printf(" "); printf("\r"); printf("%c\r", "|\\-/"[i&3]); i++; } printf("\nFinished.\n"); Soloud_deinit(soloud); Speech_destroy(speech); Soloud_destroy(soloud); printf("Cleanup done.\n"); return 0; }