Beispiel #1
0
bool CMyAPEInfo::GetFieldAsUtf8(wchar_t *pFieldName,CAPETag &tag, CSongMetaData::StringData &s)
{
	CAPETagField * pAPETagField = tag.GetTagField(pFieldName);
	if (pAPETagField == NULL)
	{
		return false;
	}
	else if (pAPETagField->GetIsUTF8Text() || (tag.GetAPETagVersion() < 2000))
	{
		if (tag.GetAPETagVersion() >= 2000)
			s = pAPETagField->GetFieldValue();
		else
			s = ConvFromISO8859_1ToUTF8(pAPETagField->GetFieldValue());

	}
	else
	{
		wxASSERT(false);
		return false;
	}
	return true;
}
Beispiel #2
0
int main(int argc, char* argv[]) 
{
	///////////////////////////////////////////////////////////////////////////////
	// error check the command line parameters
	///////////////////////////////////////////////////////////////////////////////
	if (argc != 2) 
	{
		printf("~~~Improper Usage~~~\r\n\r\n");
		printf("Usage Example: Sample 1.exe 'c:\\1.ape'\r\n\r\n");
		return 0;
	}

	///////////////////////////////////////////////////////////////////////////////
	// variable declares
	///////////////////////////////////////////////////////////////////////////////
	int					nRetVal = 0;										// generic holder for return values
	char				cTempBuffer[256]; ZeroMemory(&cTempBuffer[0], 256);	// generic buffer for string stuff
	char *				pFilename = argv[1];								// the file to open
	IAPEDecompress *	pAPEDecompress = NULL;								// APE interface
	CSmartPtr<wchar_t> spInput;

	spInput.Assign(GetUTF16FromANSI(argv[1]), TRUE);
	
//*
	///////////////////////////////////////////////////////////////////////////////
	// open the file and error check
	///////////////////////////////////////////////////////////////////////////////
	pAPEDecompress = CreateIAPEDecompress(spInput, &nRetVal);
	if (pAPEDecompress == NULL) 
	{
		printf("Error opening APE file. (error code %d)\r\n\r\n", nRetVal);
		return 0;
	}


	///////////////////////////////////////////////////////////////////////////////
	// display some information about the file
	///////////////////////////////////////////////////////////////////////////////
	printf("Displaying information about '%s':\r\n\r\n", pFilename);

	// file format information
	printf("File Format:\r\n");
	printf("\tVersion: %.2f\r\n", float(pAPEDecompress->GetInfo(APE_INFO_FILE_VERSION)) / float(1000));
	switch (pAPEDecompress->GetInfo(APE_INFO_COMPRESSION_LEVEL))
	{
		case COMPRESSION_LEVEL_FAST: printf("\tCompression level: Fast\r\n\r\n"); break;
		case COMPRESSION_LEVEL_NORMAL: printf("\tCompression level: Normal\r\n\r\n"); break;
		case COMPRESSION_LEVEL_HIGH: printf("\tCompression level: High\r\n\r\n"); break;
		case COMPRESSION_LEVEL_EXTRA_HIGH: printf("\tCompression level: Extra High\r\n\r\n"); break;
	}

	// audio format information
	printf("Audio Format:\r\n");
	printf("\tSamples per second: %" PRIiPTR "\r\n", pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE));
	printf("\tBits per sample: %" PRIiPTR "\r\n", pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE));
	printf("\tNumber of channels: %" PRIiPTR "\r\n", pAPEDecompress->GetInfo(APE_INFO_CHANNELS));
	printf("\tPeak level: %" PRIiPTR "\r\n\r\n", pAPEDecompress->GetInfo(APE_INFO_PEAK_LEVEL));

	// size and duration information
	printf("Size and Duration:\r\n");
	printf("\tLength of file (s): %" PRIiPTR "\r\n", pAPEDecompress->GetInfo(APE_INFO_LENGTH_MS) / 1000);
	printf("\tFile Size (kb): %" PRIiPTR "\r\n\r\n", pAPEDecompress->GetInfo(APE_INFO_APE_TOTAL_BYTES) / 1024);
	
	// tag information
	printf("Tag Information:\r\n");
	
	CAPETag * pAPETag = (CAPETag *) pAPEDecompress->GetInfo(APE_INFO_TAG);
	BOOL bHasID3Tag = pAPETag->GetHasID3Tag();
	BOOL bHasAPETag = pAPETag->GetHasAPETag();

	
	if (bHasID3Tag || bHasAPETag)
	{
	    printf("\tID3 Tag: %s, APE Tag: %s", bHasID3Tag ? "Yes" : "No", bHasAPETag ? "" : "No");
	    if (bHasAPETag)
	    {
		printf("%d", pAPETag->GetAPETagVersion() / 1000);
	    }
	    printf("\n\n");
		// iterate through all the tag fields
		//BOOL bFirst = TRUE;
		CAPETagField * pTagField;
//		while (pAPETag->GetNextTagField(bFirst, &pTagField))
		int index = 0;
		while ((pTagField = pAPETag->GetTagField(index)) != NULL)
		{
			//bFirst = FALSE;
			index ++;
			
			// output the tag field properties (don't output huge fields like images, etc.)
			if (pTagField->GetFieldValueSize() > 128)
			{
				printf("\t%s: --- too much data to display ---\r\n", GetANSIFromUTF16(pTagField->GetFieldName()));
			}
			else
			{
/*
			    const wchar_t *fieldName;
			    char *name;
			    wchar_t fieldValue[255];
			    char *value;

			    fieldName = pTagField->GetFieldName();
			    name = GetANSIFromUTF16(fieldName);

			    memset(fieldValue, 0, 255 * sizeof(wchar_t));
			    int len;
			    pAPETag->GetFieldString(fieldName, fieldValue, &len);
			    
			    value = GetANSIFromUTF16(fieldValue);
*/
			    const wchar_t *fieldName;
			    char *name;
			    const char *fieldValue;
			    char *value;

			    fieldName = pTagField->GetFieldName();
			    name = GetANSIFromUTF16(fieldName);

			    fieldValue = pTagField->GetFieldValue();
			    if (pAPETag->GetAPETagVersion() == CURRENT_APE_TAG_VERSION)
			    {
				value = GetANSIFromUTF8((unsigned char *)fieldValue);
			    }
			    else
			    {
				value = (char *)fieldValue;
			    }
			    printf("\t%s : %s\n", name, value);
			}
		}
	}
	else 
	{
		printf("\tNot tagged\r\n\r\n");
	}
	
	///////////////////////////////////////////////////////////////////////////////
	// cleanup (just delete the object
	///////////////////////////////////////////////////////////////////////////////
	delete pAPEDecompress;

	///////////////////////////////////////////////////////////////////////////////
	// quit
	///////////////////////////////////////////////////////////////////////////////
	return 0;
}