Example #1
0
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;
}
Example #2
0
static void testGetInfo(const char *title, Atrac3File &src) {
	u8 *buffer = new u8[src.Size() / 2];
	memcpy(buffer, src.Data(), src.Size() / 2);

	int atracID = sceAtracSetDataAndGetID(buffer, src.Size() / 2);
	testGetInfo(title, atracID);
	sceAtracReleaseAtracID(atracID);

	delete [] buffer;
}
Example #3
0
extern "C" int main(int argc, char *argv[]) {
	LoadAtrac();

	sceAtracReinit(0, 3);

	Atrac3File at3("../sample.at3");
	at3.Require();

	int atracID = sceAtracSetDataAndGetID(at3.Data(), at3.Size());

	checkpointNext("Atrac IDs:");
	testGetInfo("  Normal", atracID);
	testGetInfo("  Invalid ID", -1);
	testGetInfo("  Unused ID", 1);

	checkpointNext("Other states:");
	int withoutDataID = sceAtracGetAtracID(0x1000);
	testGetInfo("  No data", withoutDataID);
	sceAtracReleaseAtracID(withoutDataID);
	forceAtracState(atracID, 8);
	testGetInfo("  State 8", atracID);
	forceAtracState(atracID, 16);
	testGetInfo("  State 16", atracID);
	forceAtracState(atracID, 1);
	sceAtracReleaseAtracID(atracID);

	checkpointNext("Stream types:");
	int halfwayID = sceAtracSetHalfwayBufferAndGetID(at3.Data(), at3.Size() / 2, at3.Size());
	testGetInfo("  Halfway", atracID);
	sceAtracReleaseAtracID(halfwayID);
	testGetInfo("  No loop", at3);
	testGetInfoWithLooped("  End loop", at3, 2048, 249548);
	testGetInfoWithLooped("  Middle loop", at3, 2048, 200000);
	testGetInfoWithLooped("  Late loop", at3, 200000, 249548);

	checkpointNext("Loop end cutoff:");
	testGetInfoWithLooped("  200335", at3, 2048, 200335);
	testGetInfoWithLooped("  200336", at3, 2048, 200336);

	testGetInfoTwice(at3);

	UnloadAtrac();
	return 0;
}
int LoadAt3(char* filename,int channel)
{
	if ((channel<0)||(channel>1))
	{
		return PSPAALIB_ERROR_AT3_INVALID_CHANNEL;
	}
	if (streamsAt3[channel].initialized)
	{
		UnloadAt3(channel);
	}
	SceUID file=sceIoOpen(filename,PSP_O_RDONLY,0777);
	if (file<=0)
	{
		return PSPAALIB_ERROR_AT3_INVALID_FILE;
	}
	streamsAt3[channel].dataSize=sceIoLseek(file,0,PSP_SEEK_END);
	sceIoLseek(file,0,PSP_SEEK_SET);
	streamsAt3[channel].data=malloc(streamsAt3[channel].dataSize);
	if (!streamsAt3[channel].data)
	{
		sceIoClose(file);
		return PSPAALIB_ERROR_AT3_INSUFFICIENT_RAM;
	}
	sceIoRead(file,streamsAt3[channel].data,streamsAt3[channel].dataSize);
	sceIoClose(file);
	streamsAt3[channel].id=sceAtracSetDataAndGetID(streamsAt3[channel].data,streamsAt3[channel].dataSize);
	if (streamsAt3[channel].id<0)
	{
		free(streamsAt3[channel].data);
		sceIoClose(file);
		return PSPAALIB_ERROR_AT3_GET_ID;
	}
	streamsAt3[channel].bufSize=0;
	streamsAt3[channel].paused=TRUE;
	streamsAt3[channel].autoloop=FALSE;
	streamsAt3[channel].initialized=TRUE;
	streamsAt3[channel].stopReason=PSPAALIB_STOP_JUST_LOADED;
	return PSPAALIB_SUCCESS;
}
Example #5
0
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;
}