Exemple #1
0
void audio_stop(void) {
    csndExecCmds(true);
    CSND_SetPlayState(0x8, 0);
    memset(buffer, 0, size);
    GSPGPU_FlushDataCache(buffer, size);
    linearFree(buffer);
}
Exemple #2
0
void pm_3ds_sound_pause(void)
{
	if (soundstate) {
		CSND_SetPlayState(0x8, 0);//Stop audio playback.
		csndExecCmds(0);
		
		soundstate=0;
	}
}
Exemple #3
0
void pm_3ds_sound_quit(void)
{
		CSND_SetPlayState(0x8, 0);//Stop audio playback.
		csndExecCmds(0);

   if (stream) {
		linearFree(stream);
    }
	csndExit();
}
Exemple #4
0
void Audio_DeInit()
{
	if (Audio_Type == 1)
	{
		CSND_SetPlayState(8, 0);
		CSND_SetPlayState(9, 0);

		csndExecCmds(0);
		csndExit();
	}
	isPlaying = false;
}
Exemple #5
0
void S_Exit() {
	Result ret;
	if (!audio_initialized) {
		return;
	}

	S_StopMusic();
	S_Stop();
	MIX_exit();
	mus_exit();
	//flush csnd command buffers
	csndExecCmds(true);
	csndExit();
	//svcSleepThread(5000000000LL);
}
Exemple #6
0
void Audio_Pause()
{
	if(isPlaying)
	{
		// stop
		if (Audio_Type == 1)
		{
			CSND_SetPlayState(8, 0);
			CSND_SetPlayState(9, 0);

			csndExecCmds(0);
		}
	
		memset(Audio_Buffer, 0, MIXBUFSIZE*4*2);
		GSPGPU_FlushDataCache(NULL, Audio_Buffer, MIXBUFSIZE*4*2);
		isPlaying = false;
	}
}
Exemple #7
0
static void _postAudioBuffer(struct GBAAVStream* stream, struct GBAAudio* audio) {
	UNUSED(stream);
	memset(audioLeft, 0, AUDIO_SAMPLES * sizeof(int16_t));
	memset(audioRight, 0, AUDIO_SAMPLES * sizeof(int16_t));
#if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF
	blip_read_samples(audio->left, audioLeft, AUDIO_SAMPLES, false);
	blip_read_samples(audio->right, audioRight, AUDIO_SAMPLES, false);
#elif RESAMPLE_LIBRARY == RESAMPLE_NN
	GBAAudioCopy(audio, audioLeft, audioRight, AUDIO_SAMPLES);
#endif
	GSPGPU_FlushDataCache(0, (void*) audioLeft, AUDIO_SAMPLES * sizeof(int16_t));
	GSPGPU_FlushDataCache(0, (void*) audioRight, AUDIO_SAMPLES * sizeof(int16_t));
	csndPlaySound(0x8, SOUND_ONE_SHOT | SOUND_FORMAT_16BIT, 0x8000, 1.0, -1.0, audioLeft, audioLeft, AUDIO_SAMPLES * sizeof(int16_t));
	csndPlaySound(0x9, SOUND_ONE_SHOT | SOUND_FORMAT_16BIT, 0x8000, 1.0, 1.0, audioRight, audioRight, AUDIO_SAMPLES * sizeof(int16_t));
	CSND_SetPlayState(0x8, 1);
	CSND_SetPlayState(0x9, 1);
	csndExecCmds(false);
}
Exemple #8
0
bool Audio_Begin()
{
	if(isPlaying)
	    return 0;
 
	memset(Audio_Buffer, 0, MIXBUFSIZE*4*2);
	GSPGPU_FlushDataCache(NULL, Audio_Buffer, MIXBUFSIZE*4*2);
 
	if (Audio_Type == 1)
	{
		myCSND_SetSound(8, SOUND_FORMAT_16BIT | SOUND_REPEAT, 32000, &Audio_Buffer[0],            &Audio_Buffer[0],            MIXBUFSIZE*4, 0xFFFF, 0);
		myCSND_SetSound(9, SOUND_FORMAT_16BIT | SOUND_REPEAT, 32000, &Audio_Buffer[MIXBUFSIZE*2], &Audio_Buffer[MIXBUFSIZE*2], MIXBUFSIZE*4, 0, 0xFFFF);

		csndExecCmds(0);
	}
 
	cursample = MIXBUFSIZE;//(MIXBUFSIZE * 3) >> 1;
	isPlaying = true;
	return 1;
}
Exemple #9
0
static void _setup(struct GBAGUIRunner* runner) {
	struct GBAOptions opts = {
		.useBios = true,
		.logLevel = 0,
		.idleOptimization = IDLE_LOOP_DETECT
	};
	GBAConfigLoadDefaults(&runner->context.config, &opts);
	runner->context.gba->logHandler = GBA3DSLog;
	runner->context.gba->rotationSource = &rotation.d;
	if (hasSound) {
		runner->context.gba->stream = &stream;
	}

	GBAVideoSoftwareRendererCreate(&renderer);
	renderer.outputBuffer = linearAlloc(256 * VIDEO_VERTICAL_PIXELS * 2);
	renderer.outputBufferStride = 256;
	runner->context.renderer = &renderer.d;

	GBAAudioResizeBuffer(&runner->context.gba->audio, AUDIO_SAMPLES);
}

static void _gameLoaded(struct GBAGUIRunner* runner) {
	if (runner->context.gba->memory.hw.devices & HW_TILT) {
		HIDUSER_EnableAccelerometer();
	}
	if (runner->context.gba->memory.hw.devices & HW_GYRO) {
		HIDUSER_EnableGyroscope();
	}

#if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF
	double ratio = GBAAudioCalculateRatio(1, 60, 1);
	blip_set_rates(runner->context.gba->audio.left,  GBA_ARM7TDMI_FREQUENCY, 0x8000 * ratio);
	blip_set_rates(runner->context.gba->audio.right, GBA_ARM7TDMI_FREQUENCY, 0x8000 * ratio);
#endif
	if (hasSound) {
		memset(audioLeft, 0, AUDIO_SAMPLES * sizeof(int16_t));
		memset(audioRight, 0, AUDIO_SAMPLES * sizeof(int16_t));
	}
}

static void _gameUnloaded(struct GBAGUIRunner* runner) {
	if (hasSound) {
		CSND_SetPlayState(8, 0);
		CSND_SetPlayState(9, 0);
		csndExecCmds(false);
	}

	if (runner->context.gba->memory.hw.devices & HW_TILT) {
		HIDUSER_DisableAccelerometer();
	}
	if (runner->context.gba->memory.hw.devices & HW_GYRO) {
		HIDUSER_DisableGyroscope();
	}
}

static void _drawFrame(struct GBAGUIRunner* runner, bool faded) {
	GX_SetDisplayTransfer(0, renderer.outputBuffer, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), tex->data, GX_BUFFER_DIM(256, VIDEO_VERTICAL_PIXELS), 0x000002202);
	GSPGPU_FlushDataCache(0, tex->data, 256 * VIDEO_VERTICAL_PIXELS * 2);
#if RESAMPLE_LIBRARY == RESAMPLE_BLIP_BUF
	if (!hasSound) {
		blip_clear(runner->context.gba->audio.left);
		blip_clear(runner->context.gba->audio.right);
	}
#endif
	gspWaitForPPF();
	_drawStart();
	sf2d_draw_texture_scale_blend(tex, 40, 296, 1, -1, 0xFFFFFF3F | (faded ? 0 : 0xC0));
	_drawEnd();
}