コード例 #1
0
int __stdcall TagFileSimple(const str_ansi * pFilename, const char * pArtist, const char * pAlbum, const char * pTitle, const char * pComment, const char * pGenre, const char * pYear, const char * pTrack, BOOL bClearFirst, BOOL bUseOldID3)
{
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);

	IO_CLASS_NAME FileIO;
	if (FileIO.Open(spFilename) != 0)
		return -1;
	
	CAPETag APETag(&FileIO, TRUE);

	if (bClearFirst)
		APETag.ClearFields();	
	
	APETag.SetFieldString(APE_TAG_FIELD_ARTIST, pArtist, TRUE);
	APETag.SetFieldString(APE_TAG_FIELD_ALBUM, pAlbum, TRUE);
	APETag.SetFieldString(APE_TAG_FIELD_TITLE, pTitle, TRUE);
	APETag.SetFieldString(APE_TAG_FIELD_GENRE, pGenre, TRUE);
	APETag.SetFieldString(APE_TAG_FIELD_YEAR, pYear, TRUE);
	APETag.SetFieldString(APE_TAG_FIELD_COMMENT, pComment, TRUE);
	APETag.SetFieldString(APE_TAG_FIELD_TRACK, pTrack, TRUE);
	
	if (APETag.Save(bUseOldID3) != 0)
	{
		return -1;
	}
	
	return 0;
}
コード例 #2
0
int __stdcall RemoveTag(char * pFilename)
{
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);

	int nErrorCode = ERROR_SUCCESS;
	CSmartPtr<IAPEDecompress> spAPEDecompress(CreateIAPEDecompress(spFilename, &nErrorCode));
	if (spAPEDecompress == NULL) return -1;
	GET_TAG(spAPEDecompress)->Remove(FALSE);
	return 0;
}
コード例 #3
0
long __stdcall c_GetAPEDuration(const str_ansi * pFilename)
{
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);
  int error;
	IAPEDecompress *pDecompress = CreateIAPEDecompress(spFilename, &error);
  if (!pDecompress)
    return 0;
	long ret = pDecompress->GetInfo(APE_INFO_LENGTH_MS, 0, 0);
  delete pDecompress;
  return ret;
}
コード例 #4
0
ファイル: APETag.cpp プロジェクト: ariasrodolfo/monkeys-audio
int CAPETag::GetFieldString(const str_utf16 * pFieldName, str_utf16 * pBuffer, int * pBufferCharacters)
{
    if (m_bAnalyzed == FALSE) { Analyze(); }

    int nRetVal = ERROR_UNDEFINED;

    if (*pBufferCharacters > 0)
    {
        CAPETagField * pAPETagField = GetTagField(pFieldName);
        if (pAPETagField == NULL)
        {
            // the field doesn't exist -- return an empty string
            memset(pBuffer, 0, *pBufferCharacters * sizeof(str_utf16));
            *pBufferCharacters = 0;
        }
        else if (pAPETagField->GetIsUTF8Text() || (m_nAPETagVersion < 2000))
        {
            // get the value in UTF-16 format
            CSmartPtr<str_utf16> spUTF16;
            if (m_nAPETagVersion >= 2000)
                spUTF16.Assign(GetUTF16FromUTF8((str_utf8 *) pAPETagField->GetFieldValue()), TRUE);
            else
                spUTF16.Assign(GetUTF16FromANSI(pAPETagField->GetFieldValue()), TRUE);

            // get the number of characters
            int nCharacters = (wcslen(spUTF16) + 1);
            if (nCharacters > *pBufferCharacters)
            {
                // we'll fail here, because it's not clear what would get returned (null termination, size, etc.)
                // and we really don't want to cause buffer overruns on the client side
                *pBufferCharacters = nCharacters;
            }
            else
            {
                // just copy in
                *pBufferCharacters = nCharacters;
                memcpy(pBuffer, spUTF16.GetPtr(), *pBufferCharacters * sizeof(str_utf16));
                nRetVal = ERROR_SUCCESS;
            }
        }
        else
        {
            // memset the whole buffer to NULL (so everything left over is NULL terminated)
            memset(pBuffer, 0, *pBufferCharacters * sizeof(str_utf16));

            // do a binary dump (need to convert from wchar's to bytes)
            int nBufferBytes = (*pBufferCharacters - 1) * sizeof(str_utf16);
            nRetVal = GetFieldBinary(pFieldName, pBuffer, &nBufferBytes);
            *pBufferCharacters = (nBufferBytes / sizeof(str_utf16)) + 1;
        }
    }

    return nRetVal;
}
コード例 #5
0
IAPETag* __stdcall c_GetAPETag(const str_ansi * pFilename, bool bCheckID3Tag)
{
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);

	IO_CLASS_NAME FileIO;
	if (FileIO.Open(spFilename) != 0)
		return NULL;
		
	CAPETag *pAPETag = new CAPETag(&FileIO, TRUE);
	printf("CREATED tag: %p\n", pAPETag);
	return pAPETag;
}
コード例 #6
0
int __stdcall GetID3Tag(const str_ansi * pFilename, ID3_TAG * pID3Tag)
{
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);

	IO_CLASS_NAME FileIO;
	if (FileIO.Open(spFilename) != 0)
		return -1;
	
	CAPETag APETag(&FileIO, TRUE);
	
	return APETag.CreateID3Tag(pID3Tag);
}
コード例 #7
0
bool MUSIKAPEDecoder::OpenMedia(const char *FileName)
{

	int nRetVal=0;
	CSmartPtr<wchar_t> wsFileName;
	wsFileName.Assign(GetUTF16FromANSI(FileName),TRUE);
	IAPEDecompress * pAPEDecompress = CreateIAPEDecompress(wsFileName, &nRetVal);
	if (pAPEDecompress != NULL)
	{
		m_ApeInfo.pAPEDecompress = pAPEDecompress;
		m_Info.bitrate = pAPEDecompress->GetInfo(APE_INFO_AVERAGE_BITRATE);
		m_Info.bits_per_sample = pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE);
		m_Info.channels = pAPEDecompress->GetInfo(APE_INFO_CHANNELS);
		m_Info.frequency = pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE);
		m_Info.SampleCount = pAPEDecompress->GetInfo(APE_DECOMPRESS_TOTAL_BLOCKS);
		int bytesPerBlock = m_Info.channels * (m_Info.bits_per_sample >> 3);
		int decoder_buffer_size = bytesPerBlock * (int)((APEDecodeBufferSec * pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE)) + 0.5);
		m_Info.FileSize = pAPEDecompress->GetInfo(APE_INFO_APE_TOTAL_BYTES);
		return CreateBuffer(decoder_buffer_size);
	}
コード例 #8
0
int __stdcall ShowFileInfoDialog(const str_ansi * pFilename, HWND hwndWindow)
{
  #if 0
   	// convert the filename
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);

	// make sure the file exists
	WIN32_FIND_DATA FindData = { 0 };
	HANDLE hFind = FindFirstFile(spFilename, &FindData);
	if (hFind == INVALID_HANDLE_VALUE) 
	{
		MessageBox(hwndWindow, _T("File not found."), _T("File Info"), MB_OK);
		return 0;
	}
	else 
	{
		FindClose(hFind);
	}
    	
    // see what type the file is
	if ((_tcsicmp(&spFilename[_tcslen(spFilename) - 4], _T(".ape")) == 0) ||
		(_tcsicmp(&spFilename[_tcslen(spFilename) - 4], _T(".apl")) == 0)) 
	{
		CAPEInfoDialog APEInfoDialog;
		APEInfoDialog.ShowAPEInfoDialog(spFilename, GetModuleHandle(_T("MACDll.dll")), (LPCTSTR) IDD_APE_INFO, hwndWindow);
		return 0;
	}
	else if (_tcsicmp(&spFilename[_tcslen(spFilename) - 4], _T(".wav")) == 0) 
	{
		CWAVInfoDialog WAVInfoDialog;
		WAVInfoDialog.ShowWAVInfoDialog(spFilename, GetModuleHandle(_T("MACDll.dll")), (LPCTSTR) IDD_WAV_INFO, hwndWindow);
		return 0;
	}
	else 
	{
		MessageBox(hwndWindow, _T("File type not supported. (only .ape, .apl, and .wav files currently supported)"), _T("File Info: Unsupported File Type"), MB_OK);
		return 0;
	};
	#endif
	return 0;
}
コード例 #9
0
ファイル: Console.cpp プロジェクト: dan-huang/CUETools
/***************************************************************************************
Main (the main function)
***************************************************************************************/
int main(int argc, char * argv[])
{
	// variable declares
	CSmartPtr<wchar_t> spInputFilename; CSmartPtr<wchar_t> spOutputFilename;
	int nRetVal = ERROR_UNDEFINED;
	int nMode = UNDEFINED_MODE;
	int nCompressionLevel;
	int nPercentageDone;
		
	// output the header
	fprintf(stderr, CONSOLE_NAME);
	
	// make sure there are at least four arguments (could be more for EAC compatibility)
	if (argc < 3) 
	{
		DisplayProperUsage(stderr);
		exit(-1);
	}

	// store the input file
	spInputFilename.Assign(GetUTF16FromANSI(argv[1]), TRUE);
	
	// store the output file
	spOutputFilename.Assign(GetUTF16FromANSI(argv[2]), TRUE);

	// verify that the input file exists
	if (!FileExists(spInputFilename))
	{
		fprintf(stderr, "Input File Not Found...\n\n");
		exit(-1);
	}

	// if the output file equals '-v', then use this as the next argument
	char cMode[256];
	strcpy(cMode, argv[2]);

	if (_strnicmp(cMode, "-v", 2) != 0)
	{
		// verify is the only mode that doesn't use at least the third argument
		if (argc < 4) 
		{
			DisplayProperUsage(stderr);
			exit(-1);
		}

		// check for and skip if necessary the -b XXXXXX arguments (3,4)
		strcpy(cMode, argv[3]);
	}

	// get the mode
	nMode = UNDEFINED_MODE;
	if (_strnicmp(cMode, "-c", 2) == 0)
		nMode = COMPRESS_MODE;
	else if (_strnicmp(cMode, "-d", 2) == 0)
		nMode = DECOMPRESS_MODE;
	else if (_strnicmp(cMode, "-v", 2) == 0)
		nMode = VERIFY_MODE;
	else if (_strnicmp(cMode, "-n", 2) == 0)
		nMode = CONVERT_MODE;

	// error check the mode
	if (nMode == UNDEFINED_MODE) 
	{
		DisplayProperUsage(stderr);
		exit(-1);
	}

	// get and error check the compression level
	if (nMode == COMPRESS_MODE || nMode == CONVERT_MODE) 
	{
		nCompressionLevel = atoi(&cMode[2]);
		if (nCompressionLevel != 1000 && nCompressionLevel != 2000 && 
			nCompressionLevel != 3000 && nCompressionLevel != 4000 &&
			nCompressionLevel != 5000) 
		{
			DisplayProperUsage(stderr);
			return -1;
		}
	}

	// set the initial tick count
	TICK_COUNT_READ(g_nInitialTickCount);
	
	// process
	int nKillFlag = 0;
	if (nMode == COMPRESS_MODE) 
	{
		char cCompressionLevel[16];
		if (nCompressionLevel == 1000) { strcpy(cCompressionLevel, "fast"); }
		if (nCompressionLevel == 2000) { strcpy(cCompressionLevel, "normal"); }
		if (nCompressionLevel == 3000) { strcpy(cCompressionLevel, "high"); }
		if (nCompressionLevel == 4000) { strcpy(cCompressionLevel, "extra high"); }
		if (nCompressionLevel == 5000) { strcpy(cCompressionLevel, "insane"); }

		fprintf(stderr, "Compressing (%s)...\n", cCompressionLevel);
		nRetVal = CompressFileW(spInputFilename, spOutputFilename, nCompressionLevel, &nPercentageDone, ProgressCallback, &nKillFlag);
	}
	else if (nMode == DECOMPRESS_MODE) 
	{
		fprintf(stderr, "Decompressing...\n");
		nRetVal = DecompressFileW(spInputFilename, spOutputFilename, &nPercentageDone, ProgressCallback, &nKillFlag);
	}	
	else if (nMode == VERIFY_MODE) 
	{
		fprintf(stderr, "Verifying...\n");
		nRetVal = VerifyFileW(spInputFilename, &nPercentageDone, ProgressCallback, &nKillFlag);
	}	
	else if (nMode == CONVERT_MODE) 
	{
		fprintf(stderr, "Converting...\n");
		nRetVal = ConvertFileW(spInputFilename, spOutputFilename, nCompressionLevel, &nPercentageDone, ProgressCallback, &nKillFlag);
	}

	if (nRetVal == ERROR_SUCCESS) 
		fprintf(stderr, "\nSuccess...\n");
	else 
		fprintf(stderr, "\nError: %i\n", nRetVal);

	return nRetVal;
}
コード例 #10
0
ファイル: Sample1.cpp プロジェクト: cristiklein/monkeys-audio
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;
}
コード例 #11
0
int __stdcall c_APECompress_Start(APE_COMPRESS_HANDLE hAPECompress, const char * pOutputFilename, const WAVEFORMATEX * pwfeInput, int nMaxAudioBytes, int nCompressionLevel, const void * pHeaderData, int nHeaderBytes)
{
	CSmartPtr<wchar_t> spOutputFilename(GetUTF16FromANSI(pOutputFilename), TRUE);
	return ((IAPECompress *) hAPECompress)->Start(spOutputFilename, pwfeInput, nMaxAudioBytes, nCompressionLevel, pHeaderData, nHeaderBytes);
}
コード例 #12
0
/*****************************************************************************************
CAPEDecompress wrapper(s)
*****************************************************************************************/
APE_DECOMPRESS_HANDLE __stdcall c_APEDecompress_Create(const str_ansi * pFilename, int * pErrorCode)
{
	CSmartPtr<wchar_t> spFilename(GetUTF16FromANSI(pFilename), TRUE);
	return (APE_DECOMPRESS_HANDLE) CreateIAPEDecompress(spFilename, pErrorCode);
}