Beispiel #1
0
int main(void)
{
    gfxInitDefault();

	if(R_FAILED(ndspInit()))
		return 0;

#ifdef DEBUG
    LightLock_Init(&debug_lock);
    consoleInit(GFX_BOTTOM, &bottomScreen);
    consoleDebugInit(debugDevice_CONSOLE);
#endif

    consoleInit(GFX_TOP, &topScreen);
    //aptHook(&hookCookie, AptEventHook, NULL);

    svcCreateEvent(&bufferReadyConsumeRequest, RESET_STICKY);
    svcCreateEvent(&bufferReadyProduceRequest, RESET_STICKY);
    getFiles();

    bool exit = false;
    while (!exit)
    {
        std::string filename = select_file();
        exit = stream_file(filename);
    }

    ndspExit();
    gfxExit();

    return 0;
}
Beispiel #2
0
void OSystem_3DS::initAudio() {
	_mixer = new Audio::MixerImpl(this, 22050);

	hasAudio = R_SUCCEEDED(ndspInit());
	_mixer->setReady(false);

	if (hasAudio) {
		s32 prio = 0;
		svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
		audioThread = threadCreate(&audioThreadFunc, _mixer, 32 * 1048, prio - 1, -2, false);
	}
}
Beispiel #3
0
int initLoveAudio(lua_State *L) {

	soundEnabled = !ndspInit();

	luaL_Reg reg[] = {
		{ "stop",		audioStop	},
		{ "newSource",	sourceNew	},
		{ 0, 0 },
	};

	luaL_newlib(L, reg);

	return 1;

}
Beispiel #4
0
int PLATFORM_SoundSetup(Sound_setup_t *setup)
{
	setup->buffer_frames = (setup->buffer_frames + 7) & (~0x07);

	if (setup->buffer_frames == 0)
	{
		setup->buffer_frames = 4096;
	}

	N3DS_bufferSize = setup->buffer_frames;
	N3DS_sampleSize = setup->sample_size * setup->channels;

	N3DS_audioData = (u8*) linearAlloc(N3DS_bufferSize * 2 * N3DS_sampleSize);
	N3DS_ClearAudioData();

	ndspInit();

	N3DS_sound = setup;
	PLATFORM_SoundContinue();

	return TRUE;
}
Beispiel #5
0
//----------------------------------------------------------------------------
int main(int argc, char **argv) {
//----------------------------------------------------------------------------

	PrintConsole topScreen;
	ndspWaveBuf waveBuf[2];

	gfxInitDefault();

	consoleInit(GFX_TOP, &topScreen);

	consoleSelect(&topScreen);

	printf("libctru streaming audio\n");
	
	
	
	stb_vorbis_info info;
	int error;


      vorbisFile = stb_vorbis_open_filename("/mau5.ogg", &error, NULL);
      info = stb_vorbis_get_info(vorbisFile);
      Samples = info.sample_rate;
   
	

	u32 *audioBuffer = (u32*)linearAlloc(Samples*sizeof(s16)*2);

	bool fillBlock = false;

	ndspInit();

	ndspSetOutputMode(NDSP_OUTPUT_STEREO);

	ndspChnSetInterp(0, NDSP_INTERP_LINEAR);
	ndspChnSetRate(0, Samples);
	ndspChnSetFormat(0, NDSP_FORMAT_STEREO_PCM16);

	float mix[12];
	memset(mix, 0, sizeof(mix));
	mix[0] = 1.0;
	mix[1] = 1.0;
	ndspChnSetMix(0, mix);

	int note = 4;

	memset(waveBuf,0,sizeof(waveBuf));
	waveBuf[0].data_vaddr = &audioBuffer[0];
	waveBuf[0].nsamples = Samples;
	waveBuf[1].data_vaddr = &audioBuffer[Samples];
	waveBuf[1].nsamples = Samples;

	ndspChnWaveBufAdd(0, &waveBuf[0]);
	ndspChnWaveBufAdd(0, &waveBuf[1]);

	printf("Press up/down to change tone\n");

	
	
	
	
	
	
	while(aptMainLoop()) {

		gfxSwapBuffers();
		gfxFlushBuffers();
		gspWaitForVBlank();

		hidScanInput();
		u32 kDown = hidKeysDown();

		if (kDown & KEY_START)
			break; // break in order to return to hbmenu


		if (waveBuf[fillBlock].status == NDSP_WBUF_DONE) {

			fill_buffer(waveBuf[fillBlock].data_pcm16, waveBuf[fillBlock].nsamples);

			ndspChnWaveBufAdd(0, &waveBuf[fillBlock]);

			fillBlock = !fillBlock;
		}
	}

	ndspExit();

	linearFree(audioBuffer);

	gfxExit();
	return 0;
}