Skip to content

Commit

Permalink
switched back to csnd
Browse files Browse the repository at this point in the history
  • Loading branch information
elhobbs committed Feb 14, 2016
1 parent d6b3568 commit d0171af
Show file tree
Hide file tree
Showing 12 changed files with 674 additions and 32 deletions.
2 changes: 1 addition & 1 deletion arm11/source/3ds_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -76,7 +76,7 @@ typedef struct
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];

static int snd_scaletable[32][256];
int audio_initialized = 0;
extern int audio_initialized;


static u64 sound_start;
Expand Down
10 changes: 1 addition & 9 deletions arm11/source/3ds_sound.c
Original file line number Diff line number Diff line change
Expand Up @@ -200,15 +200,8 @@ extern u32 csndChannels;
void S_Init(int sfxVolume, int musicVolume) {
nosfxparm = 0;
nomusicparm = 0;
audio_initialized = 0;
//return;

if (csndInit() == 0) {
printf("csndInit ok!\n");
audio_initialized = 1;
}
else {
printf("csndInit failed!\n");
if (!audio_initialized) {
nosfxparm = 1;
nomusicparm = 1;
return;
Expand All @@ -229,6 +222,5 @@ void S_Exit() {
mus_exit();
//flush csnd command buffers
csndExecCmds(true);
csndExit();
//svcSleepThread(5000000000LL);
}
25 changes: 15 additions & 10 deletions arm11/source/Mixer_3ds.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3,9 +3,11 @@
#include <stdio.h>
#include <string.h>

void MixerHardware3DS::init() {
#define MIXER_CHANNEL_NUM 31

int MixerHardware3DS::init() {
Result ret = 0;
m_bufferSize = 4096;
m_bufferSize = (1L<<16);

m_soundBuffer = (byte *)linearAlloc(m_bufferSize);
m_soundBufferPHY = osConvertVirtToPhys(m_soundBuffer);
Expand All @@ -14,19 +16,21 @@ void MixerHardware3DS::init() {
m_lastPos = 0;
clear();

ret = csndPlaySound(0x10, SOUND_REPEAT | SOUND_FORMAT_8BIT, m_speed, 1.0f, 0.0f, (u32*)m_soundBuffer, (u32*)m_soundBuffer, m_bufferSize);
ret = csndPlaySound(MIXER_CHANNEL_NUM, SOUND_REPEAT | SOUND_FORMAT_8BIT, m_speed, 1.0f, 0.0f, (u32*)m_soundBuffer, (u32*)m_soundBuffer, m_bufferSize);
if (ret != 0) {
printf("mus init failed\n");
}
//try to start stalled channels
u8 playing = 0;
csndIsPlaying(0x10, &playing);
csndIsPlaying(MIXER_CHANNEL_NUM, &playing);
if (playing == 0) {
CSND_SetPlayState(0x10, 1);
CSND_SetPlayState(MIXER_CHANNEL_NUM, 1);
}
//flush csnd command buffers
csndExecCmds(true);
m_start = svcGetSystemTick();

return 0;
}

void MixerHardware3DS::clear() {
Expand All @@ -36,7 +40,8 @@ void MixerHardware3DS::clear() {

void MixerHardware3DS::shutdown() {
flush();
CSND_SetPlayState(0x10, 0);
CSND_SetPlayState(MIXER_CHANNEL_NUM, 0);
csndExecCmds(true);
}

void MixerHardware3DS::flush() {
Expand Down Expand Up @@ -90,8 +95,8 @@ void MixerHardware3DS::update(short *pAudioData, int count)
GSPGPU_FlushDataCache(m_soundBuffer, m_bufferSize);
}

#if 0
MixerHardware3DS g_mixer(32728, 2);
#if 1
MixerHardware3DS g_mixer(32728, 1);

extern "C" void mixer_update(short *pAudioData, int count) {
g_mixer.update(pAudioData, count);
Expand All @@ -101,8 +106,8 @@ extern "C" int mixer_pos() {
return g_mixer.samplepos();
}

extern "C" void mixer_init() {
g_mixer.init();
extern "C" int mixer_init() {
return g_mixer.init();
}

extern "C" void mixer_exit() {
Expand Down
2 changes: 1 addition & 1 deletion arm11/source/Mixer_3ds.h
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ class MixerHardware3DS : public MixerHardware {
MixerHardware3DS(int speed, int channels);
~MixerHardware3DS();

void init();
int init();
void shutdown();
void flush();
void update(int *pAudioData, int count);
Expand Down
8 changes: 5 additions & 3 deletions arm11/source/Mixer_dsp.cpp
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
#if 0
#include "Mixer_dsp.h"
#include <3ds.h>
#include <stdio.h>
#include <string.h>

static int audio_initialized = 0;
extern int audio_initialized;

extern "C" void Pause(u32 ms);

Expand Down Expand Up @@ -315,7 +316,7 @@ extern "C" void ndspMix_flush(void *pmix) {
mix->flush();
}

#if 1
#if 0
MixerHardwareDSP g_mixer(16, 32728, 2);

extern "C" void mixer_update(short *pAudioData, int count) {
Expand All @@ -338,4 +339,5 @@ extern "C" void mixer_clear() {
g_mixer.clear();
}

#endif
#endif
#endif
2 changes: 1 addition & 1 deletion arm11/source/dsp_mix.c
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ typedef struct
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];

static int snd_scaletable[32][256];
int audio_initialized = 0;
extern int audio_initialized;


static u64 sound_start;
Expand Down
8 changes: 4 additions & 4 deletions arm11/source/hw_mix.c
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
#if 1
#if 0
#include "doomstat.h"
#include "sounds.h"
#include "s_sound.h"
Expand Down Expand Up @@ -52,7 +52,7 @@ typedef struct
portable_samplepair_t paintbuffer[PAINTBUFFER_SIZE];

static int snd_scaletable[32][256];
int audio_initialized = 0;
extern int audio_initialized;

void MIX_InitScaletable(void)
{
Expand Down Expand Up @@ -116,7 +116,7 @@ void I_StopSound(channel_t *c) {
}
i++;
svcSleepThread(500000);
//printf("-----: %2d %8s %d %08x %d\n", c-channel, c->sfxinfo->name, (int)(c->wavebuf.status), c->wavebuf.data_vaddr, i);
printf("-----: %2d %8s %lld %lld\n", c-channel, c->sfxinfo->name, c->end, soundpos());
}

if (c->wavebuf.data_vaddr) {
Expand Down Expand Up @@ -436,7 +436,7 @@ int I_StartSound(sfxinfo_t *sfx, int cnum, int vol, int sep, int pitch, int prio
ch->left = ((256 - sep) * vol) / 15;
ch->right = ((sep)* vol) / 15;
ch->pos = 0;
//printf("start: %2d %8s %d %d\n",cnum, sfx->name,ch->left, ch->right);
printf("start: %2d %8s %d %d\n",cnum, sfx->name,ch->left, ch->right);

ldata = (byte *)linearAlloc(len);

Expand Down
Loading

0 comments on commit d0171af

Please sign in to comment.