Esempio n. 1
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FilterOptionsString: Fills compression level in "File Info"
/////////////////////////////////////////////////////////////
__declspec(dllexport) DWORD FAR PASCAL FilterOptionsString(HANDLE hInput, LPSTR szString)
{ 
    // default
    strcpy(szString, "Compression Level: Normal");

    // fill in from decoder
    IAPEDecompress* pAPEDecompress = (IAPEDecompress*) hInput;
    if (pAPEDecompress != NULL) 
    {
        char Title[256]; strcpy(Title, "Compression Level: ");
        
        switch (pAPEDecompress->GetInfo(APE_INFO_COMPRESSION_LEVEL))
        {
        case COMPRESSION_LEVEL_FAST: strcat(Title, "Fast"); break;
        case COMPRESSION_LEVEL_NORMAL: strcat(Title, "Normal"); break;
        case COMPRESSION_LEVEL_HIGH: strcat(Title, "High"); break;
        case COMPRESSION_LEVEL_EXTRA_HIGH: strcat(Title, "Extra High"); break;
        }

        Title[30] = 0x00;
        strcpy(szString, Title);
    }

    // return compression level
    return FilterOptions(hInput);
}
Esempio n. 2
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//OpenFilterInput: Open the file for reading
////////////////////////////////////////////
__declspec(dllexport) int FAR PASCAL FilterGetFileSize(HANDLE hInput)
{    
    IAPEDecompress* pAPEDecompress = (IAPEDecompress*) hInput;
    if (hInput == NULL) return 0;
    
    int BytesPerSample = pAPEDecompress->GetInfo(APE_INFO_BYTES_PER_SAMPLE);
    if (BytesPerSample == 3) BytesPerSample = 4;
    return pAPEDecompress->GetInfo(APE_INFO_TOTAL_BLOCKS) * pAPEDecompress->GetInfo(APE_INFO_CHANNELS) * BytesPerSample;
}
Esempio n. 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;
}
Esempio n. 4
0
bool CMyAPEInfo::ReadFileData(CSongMetaData & MetaData) const
{
	int nRetVal=0;
	IAPEDecompress * pAPEDecompress = CreateIAPEDecompress(MetaData.Filename.GetFullPath().wc_str(wxConvFile), &nRetVal);
	if (pAPEDecompress != NULL)
	{
		MetaData.nBitrate = pAPEDecompress->GetInfo(APE_INFO_AVERAGE_BITRATE);
		MetaData.nDuration_ms = pAPEDecompress->GetInfo(APE_DECOMPRESS_LENGTH_MS);
		MetaData.nFilesize = pAPEDecompress->GetInfo(APE_INFO_APE_TOTAL_BYTES);
		delete pAPEDecompress; /* Delete IAPEDecompress interface */
		return true;
	}
	return false;
}
Esempio n. 5
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//FilterOptions: Returns the compression level for this wave
////////////////////////////////////////////////////////////
__declspec(dllexport) DWORD FAR PASCAL FilterOptions(HANDLE hInput)
{ 
    int nCompressionLevel = 2;

    IAPEDecompress* pAPEDecompress = (IAPEDecompress*) hInput;
    if (pAPEDecompress != NULL) 
    {
        switch (pAPEDecompress->GetInfo(APE_INFO_COMPRESSION_LEVEL))
        {
        case COMPRESSION_LEVEL_FAST: nCompressionLevel = 1; break;
        case COMPRESSION_LEVEL_NORMAL: nCompressionLevel = 2; break;
        case COMPRESSION_LEVEL_HIGH: nCompressionLevel = 3; break;
        case COMPRESSION_LEVEL_EXTRA_HIGH: nCompressionLevel = 4; break;
        }
    }
    
    return nCompressionLevel;
}        
Esempio n. 6
0
///////////////////////////////////////////////////////////////////////////////////////////////////////////////
//ReadFilterInput: Effective Reading
////////////////////////////////////
__declspec(dllexport) DWORD FAR PASCAL ReadFilterInput(HANDLE hInput, unsigned char far *buf, int lBytes)
{
    IAPEDecompress* pAPEDecompress = (IAPEDecompress*) hInput;
    if (hInput == NULL) return 0;

    int nBlocksDecoded = 0;
    int nBlocksToDecode = lBytes / pAPEDecompress->GetInfo(APE_INFO_BLOCK_ALIGN);

    if (pAPEDecompress->GetInfo(APE_INFO_BYTES_PER_SAMPLE) == 3)
    {
        ///////////////////////////////////////////////////////////////////////////////
        // 24 bit decode (convert to 32 bit)
        //////////////////////
        
        nBlocksToDecode = (nBlocksToDecode * 3) / 4;
        if (pAPEDecompress->GetData((char*) buf, nBlocksToDecode, &nBlocksDecoded) != ERROR_SUCCESS)
            return 0;

        // expand to 32 bit
        unsigned char* p24Bit = (unsigned char*) &buf[(nBlocksDecoded * pAPEDecompress->GetInfo(APE_INFO_BLOCK_ALIGN)) - 3];
        float* p32Bit = (float*) &buf[(nBlocksDecoded * pAPEDecompress->GetInfo(APE_INFO_CHANNELS) * 4) - 4];

        while (p32Bit >= (float*) &buf[0])
        {
            float fValue = (float) (*p24Bit + *(p24Bit + 1) * 256 + *(p24Bit + 2) * 65536) / 256;
            if (fValue > 32768) fValue -= 65536;
            *p32Bit = fValue;

            p24Bit -= 3;
            p32Bit--;
        }
    }
    else
    {
        ///////////////////////////////////////////////////////////////////////////////
        // 8 and 16 bits decode
        //////////////////////
        if (pAPEDecompress->GetData((char*) buf, nBlocksToDecode, &nBlocksDecoded) != ERROR_SUCCESS)
            return 0;
    }

    int BytesPerSample = pAPEDecompress->GetInfo(APE_INFO_BYTES_PER_SAMPLE);
    if (BytesPerSample == 3) BytesPerSample = 4;
    return nBlocksDecoded * pAPEDecompress->GetInfo(APE_INFO_CHANNELS) * BytesPerSample;
}
Esempio n. 7
0
__declspec(dllexport) HANDLE FAR PASCAL OpenFilterInput( LPSTR lpstrFilename, int far *lSamprate, 
                                            WORD far *wBitsPerSample, WORD far *wChannels, HWND hWnd, int far *lChunkSize)
{
    ///////////////////////////////////////////////////////////////////////////////
    // open the APE file
    ///////////////////////////////////////////////////////////////////////////////    
    CSmartPtr<wchar_t> spUTF16(CAPECharacterHelper::GetUTF16FromANSI(lpstrFilename), TRUE);
    IAPEDecompress * pAPEDecompress = CreateIAPEDecompress(spUTF16);
    if (pAPEDecompress == NULL)
        return NULL;
    
    *lSamprate= pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE);
    *wChannels=(WORD) pAPEDecompress->GetInfo(APE_INFO_CHANNELS);
    *wBitsPerSample=(WORD) pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE);
    
    if (*wBitsPerSample == 24) *wBitsPerSample = 32;
    
    // this doesn't matter (but must be careful to avoid alignment problems)
    *lChunkSize = 16384 * (*wBitsPerSample / 8) * *wChannels;

    return (HANDLE) pAPEDecompress;
}
Esempio n. 8
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);
	}
Esempio n. 9
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;
}
Esempio n. 10
0
/***************************************************************************************
The dialog procedure
***************************************************************************************/
LRESULT CALLBACK CAPEInfoDialog::DialogProc(HWND hDlg, UINT message, WPARAM wParam, LPARAM lParam)
{
    // get the class
    IAPEDecompress * pAPEDecompress = g_pAPEDecompressDialog->m_pAPEDecompress;

    int wmID, wmEvent;

    switch (message)
    {
        case WM_INITDIALOG:
        {
            // variable declares
            TCHAR cTemp[1024] = { 0 };

            // set info
            wchar_t cFilename[MAX_PATH + 1] = {0};
            GET_IO(pAPEDecompress)->GetName(&cFilename[0]);

            SetDlgItemText(hDlg, FILE_NAME_EDIT, cFilename);
            
            switch (pAPEDecompress->GetInfo(APE_INFO_COMPRESSION_LEVEL))
            {
                case COMPRESSION_LEVEL_FAST: _stprintf(cTemp, _T("Mode: Fast")); break;
                case COMPRESSION_LEVEL_NORMAL: _stprintf(cTemp, _T("Mode: Normal")); break;
                case COMPRESSION_LEVEL_HIGH: _stprintf(cTemp, _T("Mode: High")); break;
                case COMPRESSION_LEVEL_EXTRA_HIGH: _stprintf(cTemp, _T("Mode: Extra High")); break;
                case COMPRESSION_LEVEL_INSANE: _stprintf(cTemp, _T("Mode: Insane")); break;
                default: _stprintf(cTemp, _T("Mode: Unknown")); break;
            }
            SetDlgItemText(hDlg, COMPRESSION_LEVEL_STATIC, cTemp);
            
            _stprintf(cTemp, _T("Version: %.2f"), float(pAPEDecompress->GetInfo(APE_INFO_FILE_VERSION)) / float(1000));
            SetDlgItemText(hDlg, ENCODER_VERSION_STATIC, cTemp);

            _stprintf(cTemp, _T("Format Flags: %d"), pAPEDecompress->GetInfo(APE_INFO_FORMAT_FLAGS));
            SetDlgItemText(hDlg, FORMAT_FLAGS_STATIC, cTemp);
            
            _stprintf(cTemp, _T("Sample Rate: %d"), pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE));
            SetDlgItemText(hDlg, SAMPLE_RATE_STATIC, cTemp);
            
            _stprintf(cTemp, _T("Channels: %d"), pAPEDecompress->GetInfo(APE_INFO_CHANNELS));
            SetDlgItemText(hDlg, CHANNELS_STATIC, cTemp);

            _stprintf(cTemp, _T("Bits Per Sample: %d"), pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE));
            SetDlgItemText(hDlg, BITS_PER_SAMPLE_STATIC, cTemp);

            int nSeconds = pAPEDecompress->GetInfo(APE_INFO_LENGTH_MS) / 1000; int nMinutes = nSeconds / 60; nSeconds = nSeconds % 60; int nHours = nMinutes / 60; nMinutes = nMinutes % 60;
            if (nHours > 0)    _stprintf(cTemp, _T("Length: %d:%02d:%02d"), nHours, nMinutes, nSeconds);
            else if (nMinutes > 0) _stprintf(cTemp, _T("Length: %d:%02d"), nMinutes, nSeconds);
            else _stprintf(cTemp, _T("Length: 0:%02d"), nSeconds);
            SetDlgItemText(hDlg, TRACK_LENGTH_STATIC, cTemp);

            int nPeakLevel = pAPEDecompress->GetInfo(APE_INFO_PEAK_LEVEL);
            if (nPeakLevel >= 0) _stprintf(cTemp, _T("Peak Level: %d"), nPeakLevel);
            else _stprintf(cTemp, _T("Peak Level: ?"));
            SetDlgItemText(hDlg, PEAK_LEVEL_STATIC, cTemp);

            // the file size
            _stprintf(cTemp, _T("APE: %.2f MB"), float(pAPEDecompress->GetInfo(APE_INFO_APE_TOTAL_BYTES)) / float(1048576));
            SetDlgItemText(hDlg, APE_SIZE_STATIC, cTemp);
            
            _stprintf(cTemp, _T("WAV: %.2f MB"), float(pAPEDecompress->GetInfo(APE_INFO_WAV_TOTAL_BYTES)) / float(1048576));
            SetDlgItemText(hDlg, WAV_SIZE_STATIC, cTemp);
            
            // the compression ratio
            _stprintf(cTemp, _T("Compression: %.2f%%"), float(pAPEDecompress->GetInfo(APE_INFO_AVERAGE_BITRATE) * 100) / float(pAPEDecompress->GetInfo(APE_INFO_DECOMPRESSED_BITRATE)));
            SetDlgItemText(hDlg, COMPRESSION_RATIO_STATIC, cTemp);

            // the has tag
            BOOL bHasID3Tag = GET_TAG(pAPEDecompress)->GetHasID3Tag();
            BOOL bHasAPETag = GET_TAG(pAPEDecompress)->GetHasAPETag();
                        
            if (!bHasID3Tag && !bHasAPETag)
                _stprintf(cTemp, _T("Tag: None"));
            else if (bHasID3Tag && !bHasAPETag)
                _stprintf(cTemp, _T("Tag: ID3v1.1"));
            else if (!bHasID3Tag && bHasAPETag)
                _stprintf(cTemp, _T("Tag: APE Tag"));
            else
                _stprintf(cTemp, _T("Tag: Corrupt"));
            SetDlgItemText(hDlg, HAS_TAG_STATIC, cTemp);
                
            wchar_t cBuffer[256];
            int nBufferBytes = 256;

            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_TITLE, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, TITLE_EDIT, cBuffer);
            
            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_ARTIST, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, ARTIST_EDIT, cBuffer);
            
            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_ALBUM, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, ALBUM_EDIT, cBuffer);
            
            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_COMMENT, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, COMMENT_EDIT, cBuffer);
            
            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_YEAR, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, YEAR_EDIT, cBuffer);
            
            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_TRACK, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, TRACK_EDIT, cBuffer);
            
            g_pAPEDecompressDialog->FillGenreComboBox(hDlg, GENRE_COMBOBOX, NULL);

            nBufferBytes = 256;
            GET_TAG(pAPEDecompress)->GetFieldString(APE_TAG_FIELD_GENRE, cBuffer, &nBufferBytes);
            SetDlgItemText(hDlg, GENRE_COMBOBOX, cBuffer);
            
            return TRUE;
            break;
        }
        case WM_COMMAND:
            wmID = LOWORD(wParam);
            wmEvent = HIWORD(wParam);
            
            switch (wmID)
            {
                case IDCANCEL: 
                    // traps the [esc] key
                    EndDialog(hDlg, 0);
                    return TRUE;
                    break;
                case CANCEL_BUTTON:
                    EndDialog(hDlg, 0);
                     return TRUE;
                    break;
                case REMOVE_TAG_BUTTON:
                {
                    // make sure you really wanted to
                    int nRetVal = ::MessageBox(hDlg, _T("Are you sure you want to permanently remove the tag?"), _T("Are You Sure?"), MB_YESNO | MB_ICONQUESTION);
                    if (nRetVal == IDYES)
                    {
                        // remove the ID3 tag...
                        if (GET_TAG(pAPEDecompress)->Remove() != 0) 
                        {
                            MessageBox(hDlg, _T("Error removing tag. (could the file be read-only?)"), _T("Error Removing Tag"), MB_OK | MB_ICONEXCLAMATION);
                            return TRUE;
                        }
                        else 
                        {
                            EndDialog(hDlg, 0);
                             return TRUE;
                        }
                    }
                    break;
                }
                case SAVE_TAG_BUTTON:
                    
                    // make the id3 tag
                    TCHAR cBuffer[256]; int z;

                    #define SAVE_FIELD(ID, Field)                            \
                        for (z = 0; z < 256; z++) { cBuffer[z] = 0; }        \
                        GetDlgItemText(hDlg, ID, cBuffer, 256);                \
                        GET_TAG(pAPEDecompress)->SetFieldString(Field, cBuffer);

                    SAVE_FIELD(TITLE_EDIT, APE_TAG_FIELD_TITLE)
                    SAVE_FIELD(ARTIST_EDIT, APE_TAG_FIELD_ARTIST)
                    SAVE_FIELD(ALBUM_EDIT, APE_TAG_FIELD_ALBUM)
                    SAVE_FIELD(COMMENT_EDIT, APE_TAG_FIELD_COMMENT)
                    SAVE_FIELD(TRACK_EDIT, APE_TAG_FIELD_TRACK)
                    SAVE_FIELD(YEAR_EDIT, APE_TAG_FIELD_YEAR)
                    SAVE_FIELD(GENRE_COMBOBOX, APE_TAG_FIELD_GENRE)
                    
                    if (GET_TAG(pAPEDecompress)->Save() != 0) 
                    {
                        MessageBox(hDlg, _T("Error saving tag. (could the file be read-only?)"), _T("Error Saving Tag"), MB_OK | MB_ICONEXCLAMATION);
                        return TRUE;
                    }

                    EndDialog(hDlg, 0);
                    break;
            }
            break;
        case WM_CLOSE:
            EndDialog(hDlg, 0);
            return TRUE;
            break;
    }
    
    return FALSE;
}
Esempio n. 11
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
		
	///////////////////////////////////////////////////////////////////////////////
	// open the file and error check
	///////////////////////////////////////////////////////////////////////////////
	pAPEDecompress = CreateIAPEDecompress(pFilename, &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: %d\r\n", pAPEDecompress->GetInfo(APE_INFO_SAMPLE_RATE));
	printf("\tBits per sample: %d\r\n", pAPEDecompress->GetInfo(APE_INFO_BITS_PER_SAMPLE));
	printf("\tNumber of channels: %d\r\n", pAPEDecompress->GetInfo(APE_INFO_CHANNELS));
	printf("\tPeak level: %d\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): %d\r\n", pAPEDecompress->GetInfo(APE_INFO_LENGTH_MS) / 1000);
	printf("\tFile Size (kb): %d\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)
	{
		// iterate through all the tag fields
		BOOL bFirst = TRUE;
		CAPETagField * pTagField;
		while (pAPETag->GetNextTagField(bFirst, &pTagField))
		{
			bFirst = FALSE;
			
			// 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", pTagField->GetFieldName());
			}
			else
			{
				printf("\t%s: %s\r\n", pTagField->GetFieldName(), pTagField->GetFieldValue());
			}
		}
	}
	else 
	{
		printf("\tNot tagged\r\n\r\n");
	}
	
	///////////////////////////////////////////////////////////////////////////////
	// cleanup (just delete the object
	///////////////////////////////////////////////////////////////////////////////
	delete pAPEDecompress;

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