This sample use the soLoud engine. It doesn't use any specific function from the vita, appart from the "includes" and "defines" to be executed. However, we think it is useful to have the vitasdk documentation stated here anyways.
SAMPLE "soloud"
soloud
: Plays an audio file and Text To Speech. This sample has a few things new, in reference to the previous ones:
It has an audio file music.ogg, this is obviously the audio file we're going to be reading; and it has a c++ (.cpp) file as main.
Note: there are not enough significant syntax differences between c and c++ to make difficult the understanding of the file, so we are going to keep everything as is (in that matter) for the moment.
// headers and other required files which need to be linked for the homebrew to work
#include <stdint.h>
#include <math.h>
#include <psp2/ctrl.h>
#include <psp2/audioout.h>
#include <psp2/kernel/processmgr.h>
#include "debugScreen.h"
#include "soloud.h"
#include "soloud_wav.h"
#include "soloud_speech.h"
// Part from the soLoud engine to declare variables
SoLoud::Soloud gSoloud; // SoLoud engine
SoLoud::Wav gWave; // One wave file
// definition of some future used functions
#define printf psvDebugScreenPrintf
// main program
int main(void) {
psvDebugScreenInit(); // needed for the prints to show on the vita screen.
printf("soloud demo\n");
gSoloud.init(); // Initialize SoLoud
printf("init\n");
// example from an audio file
gWave.load("app0:/music.ogg"); // Load a wave from the game datapath
// Key note: It is worth to remember this datapath "app0:/" for future uses.
printf("load\n");
gSoloud.play(gWave); // Play the wave
/* example from a text (in this case, the text is harcoded as a variable).
[According to soloud samples, you should be able to read from the console and,
the console reading is a file reading in unix] */
SoLoud::Speech sp; // declares a text soLoud variable
sp.setText("Hello world. You will be assimilated."); // the engine reads the text to
gSoloud.play(sp); // play it as an audio
printf("play\n");
/* this was not in the sample but after seeing it in soLoud examples we think it is a good practice.*/
// clean up soLoud
soloud.deinit();
// back to the sample's code ...
while (1) {
sceKernelDelayThread(1000 * 1000);
}
sceKernelExitProcess(0); // close the vita proccess runing, usually close the app
return 0;
}
-----------
Some screenshots from the sample running on the vita:
And that's all for this sample.
No comments:
Post a Comment