Beispiel #1
0
int __stdcall XMP_CheckFile(char *filename, BYTE *buf, DWORD length) {
    VGMSTREAM* fakevgmstream = init_vgmstream(filename);
    int ret;

	if (!fakevgmstream) ret = 0;
	else { ret = 1; close_vgmstream(fakevgmstream); }

	return ret;
}
Beispiel #2
0
  long __declspec(dllexport) DLL_LoadVGM(const char* szFileName, int* sampleRate, int* sampleSize, int* channels)
  {
    VGMSTREAM* result;

    if ((result = init_vgmstream(szFileName)) == NULL)
      return 0;

    *sampleRate = result->sample_rate;
    *sampleSize = 16;
    *channels = result->channels;
    return (long)result;
  }
Beispiel #3
0
int __stdcall LoadVgmStream(char *filename, XMPFILE file) {
	int i;
	vgmstream = init_vgmstream(filename);
 
	if (!vgmstream) return 0;
	 // just loop forever till we have configuration done

	Decoder_Is_Using_Lame_Hack = 0;

	for (i = 0; i < 5; i ++) {
		if (vgmstream->sample_rate == valid_freqs[i]) {
			Decoder_Is_Using_Lame_Hack = 1;
			break;
		}
	}

	return 1;
}
Beispiel #4
0
bool stream_file(const std::string& filename)
{
    if (filename.empty())
    {
        print("No file selected\n");
        return true;
    }

    VGMSTREAM* vgmstream = init_vgmstream(filename.c_str());
    if (!vgmstream)
    {
        print("Bad file %s\n", filename.c_str());
        return true;
    }

    const int channels = vgmstream->channels;
    u32 buffer_size = max_samples * vgmstream->channels * sizeof(sample);

    rawSampleBuffer = static_cast<sample*>(linearAlloc(buffer_size));
    sample* buffer = static_cast<sample*>(linearAlloc(buffer_size));
    sample* buffer2 = static_cast<sample*>(linearAlloc(buffer_size));
    playBuffer1.samples = max_samples;
    playBuffer2.samples = max_samples;
    for (int i = 0; i < channels; i++)
    {
        playBuffer1.channels.push_back(buffer + i * max_samples);
        playBuffer2.channels.push_back(buffer2 + i * max_samples);
    }

    stream_filename strm_file;
    strm_file.filename = filename;
    strm_file.stream = vgmstream;

    runThreads = true;

    s32 prio = 0;
    Thread musicThread;
    Thread produceThread;
    svcGetThreadPriority(&prio, CUR_THREAD_HANDLE);
    musicThread = threadCreate(streamMusic, &strm_file, 4 * 1024, prio-1, -2, false);
    produceThread = threadCreate(decodeThread, &strm_file, 4 * 1024, prio-1, -2, false);

    bool ret = false;
    while (aptMainLoop())
    {
        hidScanInput();
        u32 kDown = hidKeysDown();
        if (kDown & KEY_START || kDown & KEY_B)
        {
            ret = kDown & KEY_START;
            break;
        }
        gfxFlushBuffers();
        gfxSwapBuffers();

        gspWaitForVBlank();
    }

    runThreads = false;
    svcSignalEvent(bufferReadyProduceRequest);
    svcSignalEvent(bufferReadyConsumeRequest);
    threadJoin(musicThread, U64_MAX);
    threadJoin(produceThread, U64_MAX);
    threadFree(musicThread);
    threadFree(produceThread);
    svcClearEvent(bufferReadyConsumeRequest);
    svcClearEvent(bufferReadyProduceRequest);


    linearFree(rawSampleBuffer);
    linearFree(buffer);
    linearFree(buffer2);
    playBuffer1.channels.clear();
    playBuffer2.channels.clear();

    close_vgmstream(vgmstream);

    return ret;
}