WIP: Script-Creator!

This commit is contained in:
StackZ
2020-06-21 16:41:48 +02:00
parent 984d363533
commit 91615d7891
8 changed files with 131 additions and 155 deletions
+7 -14
View File
@@ -24,8 +24,7 @@ typedef struct _WavHeader {
} WavHeader;
static_assert(sizeof(WavHeader) == 44, "WavHeader size is not 44 bytes.");
sound::sound(const string& path, int channel, bool toloop)
{
sound::sound(const string& path, int channel, bool toloop) {
ndspSetOutputMode(NDSP_OUTPUT_STEREO);
ndspSetOutputCount(2); // Num of buffers
@@ -58,8 +57,7 @@ sound::sound(const string& path, int channel, bool toloop)
if (wavHeader.totallength == 0 ||
(wavHeader.channels != 1 && wavHeader.channels != 2) ||
(wavHeader.bits_per_sample != 8 && wavHeader.bits_per_sample != 16))
{
(wavHeader.bits_per_sample != 8 && wavHeader.bits_per_sample != 16)) {
// Unsupported WAV file.
printf("Corrupted wav file.\n");
fclose(fp);
@@ -104,8 +102,7 @@ sound::sound(const string& path, int channel, bool toloop)
chnl = channel;
}
sound::~sound()
{
sound::~sound() {
waveBuf.data_vaddr = 0;
waveBuf.nsamples = 0;
waveBuf.looping = false;
@@ -117,17 +114,13 @@ sound::~sound()
}
}
void sound::play()
{
if (!data)
return;
void sound::play() {
if (!data) return;
DSP_FlushDataCache(data, dataSize);
ndspChnWaveBufAdd(chnl, &waveBuf);
}
void sound::stop()
{
if (!data)
return;
void sound::stop() {
if (!data) return;
ndspChnWaveBufClear(chnl);
}