コード例 #1
0
ファイル: getinfo.cpp プロジェクト: hrydgard/pspautotests
static void testGetInfoTwice(Atrac3File &src) {
	checkpointNext("With second buffer:");

	Atrac3File looped((size_t)0);
	CreateLoopedAtracFrom(src, looped, 2048, 200000);

	u8 *buffer = new u8[looped.Size() / 2];
	memcpy(buffer, looped.Data(), looped.Size() / 2);

	int atracID = sceAtracSetDataAndGetID(buffer, looped.Size() / 2);

	u32 secondOff = 0, secondSize = 0;
	sceAtracGetSecondBufferInfo(atracID, &secondOff, &secondSize);
	u8 *secondBuffer = new u8[secondSize];
	memcpy(secondBuffer, looped.Data() + secondOff, secondSize);

	int result = sceAtracSetSecondBuffer(atracID, secondBuffer, secondSize);
	checkpoint("  Set buffer: %08x", result);

	testGetInfo("  With second buffer", atracID);
	sceAtracReleaseAtracID(atracID);

	delete [] buffer;
	delete [] secondBuffer;
}
コード例 #2
0
ファイル: getinfo.cpp プロジェクト: hrydgard/pspautotests
static void testGetInfo(const char *title, int atracID) {
	u32 pos = -1337;
	u32 size = -1337;
	int result = sceAtracGetSecondBufferInfo(atracID, &pos, &size);
	if (atracID >= 0) {
		if (result >= 0) {
			checkpoint("%s: OK (%08x) pos=%08x, size=%08x", title, result, pos, size);
		} else {
			checkpoint("%s: Failed (%08x) pos=%08x, size=%08x", title, result, pos, size);
		}
	} else {
		checkpoint("%s: Invalid (%08x, %08x) pos=%08x, size=%08x", title, atracID, result, pos, size);
	}
}
コード例 #3
0
ファイル: atractest.c プロジェクト: Falaina/cspspemu
int main(int argc, char *argv[]) {
	char *at3_data;
	int at3_size;

	char *decode_data;
	int decode_size;
	int n;

	FILE *file;

	int atracID;
	int maxSamples = 0;
	int result;
	int channel;
	
	u32 puiPosition;
	u32 puiDataByte;
	
	if ((file = fopen("sample.at3", "rb")) != NULL) {
		fseek(file, 0, SEEK_END);
		at3_size = ftell(file);
		
		fseek(file, 0, SEEK_SET);
		
		at3_data = malloc(at3_size);
		decode_data = malloc(decode_size = 512 * 1024);
		memset(at3_data, 0, at3_size);
		memset(decode_data, 0, decode_size);
		
		fread(at3_data, at3_size, 1, file);

		fclose(file);
	}

	pspSdkLoadStartModule("flash0:/kd/audiocodec.prx", PSP_MEMORY_PARTITION_KERNEL);
	pspSdkLoadStartModule("flash0:/kd/libatrac3plus.prx", PSP_MEMORY_PARTITION_KERNEL);
	
	printf("at3: %08X, %08X\n", (unsigned int)at3_data, at3_size);
	printf("Header: %s\n", (char *)at3_data);
		
	atracID = sceAtracSetDataAndGetID(at3_data, at3_size);
	
	result = sceAtracSetLoopNum(atracID, 2);
	printf("sceAtracSetLoopNum: %08X\n", result);

	printf("sceAtracSetDataAndGetID: %08X\n", atracID);
	
	result = sceAtracGetMaxSample(atracID, &maxSamples);
	printf("sceAtracGetMaxSample: %08X, %d\n", result, maxSamples);
	
	channel = sceAudioChReserve(0, maxSamples, PSP_AUDIO_FORMAT_STEREO);
	
	result = sceAtracGetSecondBufferInfo(atracID, &puiPosition, &puiDataByte);
	printf("sceAtracGetSecondBufferInfo: %08X, %u, %u\n", result, (unsigned int)puiPosition, (unsigned int)puiDataByte);
	
	int end = 0;
	int steps = 0;
	while (!end) {
		//int remainFrame = -1;
		int remainFrame = 0;
		//int decodeBufferPosition = 0;
		int samples = 0;
		int nextSample = 0;
		u32 nextPosition = 0;
		
		if (steps < 4) {
			result = sceAtracGetNextSample(atracID, &nextSample);
			printf("sceAtracGetNextSample(%d): %d\n", result, nextSample);
			result = sceAtracGetNextDecodePosition(atracID, &nextPosition);
			printf("sceAtracGetNextDecodePosition(%d): %u\n", result, (unsigned int)nextPosition);
		}

		result = sceAtracDecodeData(atracID, (u16 *)decode_data, &samples, &end, &remainFrame);
		
		if (steps < 4) {
			
		}
		
		sceAudioSetChannelDataLen(channel, samples);
		sceAudioOutputBlocking(channel, 0x8000, decode_data);
		
		result = sceAtracGetRemainFrame(atracID, &remainFrame);

		if (steps < 4) {
			printf("sceAtracDecodeData: %08X, at3_size: %d, decode_size: %d, samples: %d, end: %d, remainFrame: %d\n\n", result, at3_size, decode_size, samples, end, remainFrame);
			if (steps == 1) {
				for (n = 0; n < 32; n++) printf("%04X ", (u16)decode_data[n]);
			}
			printf("sceAtracGetRemainFrame: %08X\n", result);
		}

		steps++;
	}
	
	sceAudioChRelease(channel);
	result = sceAtracReleaseAtracID(atracID);
	printf("sceAtracGetRemainFrame: %08X\n", result);

	return 0;
}